diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-06-30 15:46:18 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-06-30 15:46:18 -0700 |
commit | c0aa9cfa7e3d57e0b0554033dd5f099584e7fdda (patch) | |
tree | 12f20244ab8ddb3184aa0187b8022a2cd95f07b0 /scripts/standalone_root_pw_reset | |
parent | 627740906020fbf209ce9608c0aa7b0e251f5379 (diff) | |
download | vyatta-cfg-system-c0aa9cfa7e3d57e0b0554033dd5f099584e7fdda.tar.gz vyatta-cfg-system-c0aa9cfa7e3d57e0b0554033dd5f099584e7fdda.zip |
Make standalone password reset work
Address the problems in bugs 3398 and 3399 as well as some
left over stuff from VC 3.0.
Diffstat (limited to 'scripts/standalone_root_pw_reset')
-rwxr-xr-x | scripts/standalone_root_pw_reset | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/scripts/standalone_root_pw_reset b/scripts/standalone_root_pw_reset index 0dc65fd2..7b04a9ba 100755 --- a/scripts/standalone_root_pw_reset +++ b/scripts/standalone_root_pw_reset @@ -24,7 +24,7 @@ CF=/opt/vyatta/etc/config/config.boot echo "Standalone root password recovery tool." - +echo # # Check to see if we are running in standalone mode. We'll # know that we are if our pid is 1. @@ -38,12 +38,8 @@ fi # OK, now we know we are running in standalone mode. Talk to the # user. # -echo "Do you wish to reset the reset the root password to its" -echo -n "factory setting value of \"vyatta\"? (Yes/No) [No]: " - -# -# Parse the user's response -# +echo "Do you wish to reset the root password" +echo -n "to the original default value (vyatta)? (Yes/No) [No]: " read response response=${response:0:1} @@ -55,26 +51,38 @@ if [ "$response" != "y" -a "$response" != "Y" ]; then /sbin/reboot -f fi + echo "Starting process to reset the root password..." echo "Re-mounting root filesystem read/write..." mount -o remount,rw / -echo "Mounting the config filesystem..." -mount /opt/vyatta/etc/config/ +# Leftover from V3.0 +if grep -q /opt/vyatta/etc/config /etc/fstab +then + echo "Mounting the config filesystem..." + mount /opt/vyatta/etc/config/ +fi echo "Saving backup copy of config.boot..." cp $CF ${CF}.before_pwrecovery echo "Reseting the root password..." -sed -i -e "/^.* user root {/,/^.* }/s/encrypted-password: .*$/encrypted-password: \"\$1\$\$Ht7gBYnxI1xCdO\/JOnodh.\"/" $CF + +# change system first +newpwd=$(mkpasswd -H md5 vyatta) +usermod --password "$newpwd" root + +# escape / in encrypted passwd +pw=$(echo $newpwd | sed 's:/:\\/:g') +sed -i \ + -e "/^.* user root {/,/}/s/encrypted-password:.*\$/encrypted-password: \"$pw\"/" \ + $CF echo "Root password has been reset." -echo "Logging the activity..." echo "`date`: Root password reset to factory value" >> /var/log/messages - -echo -n "Machine will reboot in 5 seconds..." sync -sleep 5 -echo + +echo "System will reboot in 10 seconds..." +sleep 10 /sbin/reboot -f |