summaryrefslogtreecommitdiff
path: root/etc/init.d
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2019-12-02 14:33:10 -0600
committerJohn Klug <john.klug@multitech.com>2019-12-02 14:33:10 -0600
commitc2d9d4d291bef71a61cb6f496d42bd7adec1aa26 (patch)
tree9b5a2558f32762528d1295e174d8038eedd58bac /etc/init.d
parent222c163ed5ca6e1933262a6563c903154b6168e1 (diff)
downloadcommissioning-c2d9d4d291bef71a61cb6f496d42bd7adec1aa26.tar.gz
commissioning-c2d9d4d291bef71a61cb6f496d42bd7adec1aa26.tar.bz2
commissioning-c2d9d4d291bef71a61cb6f496d42bd7adec1aa26.zip
Check passwords for commissioning
Diffstat (limited to 'etc/init.d')
-rwxr-xr-xetc/init.d/commissioning13
1 files changed, 13 insertions, 0 deletions
diff --git a/etc/init.d/commissioning b/etc/init.d/commissioning
index 11b0eb3..4f54267 100755
--- a/etc/init.d/commissioning
+++ b/etc/init.d/commissioning
@@ -10,10 +10,23 @@ PIDFILE=/var/run/lighttpd-commission.pid
ENABLED=yes
[ -f /etc/default/$NAME ] && . /etc/default/$NAME
+
+# If we are not enabled, see if anybody has a password
+if [[ ENABLED == no ]] ; then
+ PASSWORDS=$(passwd -Sa | egrep '^[^[:space:]]+[[:space:]]P[[:space:]]' | wc -l)
+ if (($PASSWORDS == 0)) ; then
+ # No password, so turn on commissioning
+ rm /etc/default/$NAME
+ ENABLED="yes"
+ fi
+fi
+
# /etc/default/no-${NAME} should point at /etc/default/.no-${NAME}
# and contain ENABLED="no".
# This will prevent commissioning on a factory reset
# but not on an image update for tighter security.
+# If the device is to have no password at all, this file and
+# link must be created, and ENABLED must be set to "no"
[ -f "/etc/default/no-${NAME}" ] && . "/etc/config/no-${NAME}"