Commit 30944c05 authored by Alessandro Rubini's avatar Alessandro Rubini

root-password: fix for corner cases

The apply_dot-config script was wrong: it wouldn't force on the
empty root password. Thus, if it is set to something non-empty
and then changed (by a network dot-config) to empty, it won't work.

This bug only revealed on nfs-root setups.

Now, it's stupid to keep two symbols (ROOT_PWD_CLEAR and ROOT_PWD_CYPHER),
and I could simplify the script. And re-test. And change docs. No thanks.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent ed251e9c
......@@ -42,18 +42,15 @@ fi
##### Actual configuration actions start here.
# Root password
passwd=""
if [ ! -z "$CONFIG_ROOT_PWD_CLEAR" ]; then
passwd=$(/wr/bin/mkpasswd --method=md5 "$CONFIG_ROOT_PWD_CLEAR")
fi
# Root password. The default is an empty password (if old dot-config active)
if [ ! -z "$CONFIG_ROOT_PWD_IS_ENCRYPTED" ]; then
#problem: the password includes '$', so the shell assignment failed.
passwd=$(busybox awk '-F"' '/PWD_CYPHER/ {print $2}' /wr/etc/dot-config)
else
# Note: CONFIG_ROOT_PWD_CLEAR may be an empty string
passwd=$(/wr/bin/mkpasswd --method=md5 "$CONFIG_ROOT_PWD_CLEAR")
fi
if [ ! -z "$passwd" ]; then
sed -i "s,^root:[^:]*:,root:$passwd:," /etc/shadow
fi
sed -i "s,^root:[^:]*:,root:$passwd:," /etc/shadow
# A non-existent wr_date.conf means no NTP. So "rm" if unconfigured
if [ ! -z "$CONFIG_NTP_SERVER" ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment