base-files: remind users to set root password
authorJohn Crispin <john@phrozen.org>
Sat, 17 Sep 2016 02:21:25 +0000 (04:21 +0200)
committerJohn Crispin <john@phrozen.org>
Mon, 19 Sep 2016 13:30:32 +0000 (15:30 +0200)
print a warning when a shell spawns, telling users to set a root password.

Signed-off-by: John Crispin <john@phrozen.org>
package/base-files/files/etc/profile

index f2def7fc0bacee2f398656bad4bb142756b104bf..d70bafca49ed0991d903be3f1b63f75a9282aa1b 100644 (file)
@@ -29,3 +29,16 @@ alias ll='ls -alF --color=auto'
        done
        unset FILE
 }
+
+if ( grep -qsE '^root:[!x]?:' /etc/shadow && \
+     grep -qsE '^root:[!x]?:' /etc/passwd  && \
+     [ -z "$FAILSAFE" ] )
+then
+cat << EOF
+=== WARNING! =====================================
+There is no root password defined on this device!
+Use the "passwd" command to set up a new password
+in order to prevent unauthorized SSH logins.
+--------------------------------------------------
+EOF
+fi