diff options
author | Mark O'Brien <mobrien@firebolt.vyatta.com> | 2008-07-09 13:43:32 -0700 |
---|---|---|
committer | Mark O'Brien <mobrien@firebolt.vyatta.com> | 2008-07-09 13:43:32 -0700 |
commit | bcfbf5b462faa5e0e13c82c8a367e8df698b6c20 (patch) | |
tree | dbaf63ba4719590fa5016cc105f4f73eef3c722b /scripts/standalone_root_pw_reset | |
parent | cceaba487befe7103ecb058c4dbf3e3a46102dc3 (diff) | |
parent | 4e213e1a8148d755bb3921cae3caee847901b54e (diff) | |
download | vyatta-cfg-quagga-bcfbf5b462faa5e0e13c82c8a367e8df698b6c20.tar.gz vyatta-cfg-quagga-bcfbf5b462faa5e0e13c82c8a367e8df698b6c20.zip |
Merge branch 'hollywood' of git:/git/vyatta-cfg-system into hollywood
Diffstat (limited to 'scripts/standalone_root_pw_reset')
-rwxr-xr-x | scripts/standalone_root_pw_reset | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/scripts/standalone_root_pw_reset b/scripts/standalone_root_pw_reset index 0dc65fd2..b173f22d 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,39 @@ 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 -echo "Root password has been reset." -echo "Logging the activity..." -echo "`date`: Root password reset to factory value" >> /var/log/messages +# 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 $(date "+%b%e %T") $(hostname) "Root password reset to factory value" \ + | tee -a /var/log/auth.log >>/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 |