summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-x[-rw-r--r--]scripts/install-system14
-rw-r--r--scripts/snmp/vyatta-snmp.pl2
-rwxr-xr-xscripts/standalone_root_pw_reset27
3 files changed, 23 insertions, 20 deletions
diff --git a/scripts/install-system b/scripts/install-system
index ff7a5d41..e4464ede 100644..100755
--- a/scripts/install-system
+++ b/scripts/install-system
@@ -854,6 +854,11 @@ copy_config () {
fi
}
+set_encrypted_password() {
+ sed -i \
+ -e "/ user $1 {/,/}/s/encrypted-password .*\$/encrypted-password \"$2\"/" $3
+}
+
change_password() {
local user=$1
local pwd1="1"
@@ -861,9 +866,9 @@ change_password() {
until [ "$pwd1" == "$pwd2" ]
do
- read -p "Enter $user password:" -r -s pwd1 <>/dev/tty 1>&0
+ read -p "Enter $user password:" -r -s pwd1 <>/dev/tty 2>&0
echo
- read -p "Retype $user password:" -r -s pwd2 <>/dev/tty 1>&0
+ read -p "Retype $user password:" -r -s pwd2 <>/dev/tty 2>&0
echo
if [ "$pwd1" != "$pwd2" ]
@@ -873,10 +878,7 @@ change_password() {
# escape any slashes in resulting password
local epwd=$(mkpasswd -H md5 "$pwd1" | sed 's:/:\\/:g')
-
- sed -i \
- -e "/ user $user {/,/}/s/encrypted-password:.*\$/encrypted-password: \"$epwd\"/" \
- $rootfsdir$ofrconfdir/config.boot
+ set_encrypted_password $user $epwd $rootfsdir$ofrconfdir/config.boot
}
system_setup () {
diff --git a/scripts/snmp/vyatta-snmp.pl b/scripts/snmp/vyatta-snmp.pl
index 6de63fb0..58dc374f 100644
--- a/scripts/snmp/vyatta-snmp.pl
+++ b/scripts/snmp/vyatta-snmp.pl
@@ -163,7 +163,7 @@ sub snmp_write_snmpv3_user {
my $vyatta_user = shift;
my $user = "rouser $vyatta_user\n";
- system ("sed -i '/user[[:space:]]*vyatta[[:alnum:]]*/d' $snmp_snmpv3_user_conf;");
+ system ("sed -i '/user[[:space:]]*vyatta[[:alnum:]]*/d' $snmp_snmpv3_user_conf 2>/dev/null;");
open(my $fh, '>>', $snmp_snmpv3_user_conf) || die "Couldn't open $snmp_snmpv3_user_conf - $!";
print $fh $user;
close $fh;
diff --git a/scripts/standalone_root_pw_reset b/scripts/standalone_root_pw_reset
index f08bf7d6..d089b50d 100755
--- a/scripts/standalone_root_pw_reset
+++ b/scripts/standalone_root_pw_reset
@@ -23,6 +23,11 @@
# The Vyatta config file:
CF=/opt/vyatta/etc/config/config.boot
+set_encrypted_password() {
+ sed -i \
+ -e "/ user $1 {/,/}/s/encrypted-password.*\$/encrypted-password \"$2\"/" $3
+}
+
change_password() {
local user=$1
local pwd1="1"
@@ -30,9 +35,9 @@ change_password() {
until [ "$pwd1" == "$pwd2" ]
do
- read -p "Enter $user password:" -r -s pwd1 <>/dev/tty 1>&0
+ read -p "Enter $user password: " -r -s pwd1
echo
- read -p "Retype $user password:" -r -s pwd2 <>/dev/tty 1>&0
+ read -p "Retype $user password: " -r -s pwd2
echo
if [ "$pwd1" != "$pwd2" ]
@@ -42,10 +47,7 @@ change_password() {
# escape any slashes in resulting password
local epwd=$(mkpasswd -H md5 "$pwd1" | sed 's:/:\\/:g')
-
- sed -i \
- -e "/ user $user {/,/}/s/encrypted-password:.*\$/encrypted-password: \"$epwd\"/" \
- $CF
+ set_encrypted_password $user $epwd $CF
}
echo "Standalone root password recovery tool."
@@ -63,21 +65,18 @@ fi
# OK, now we know we are running in standalone mode. Talk to the
# user.
#
-echo "Do you wish to reset the root password"
-echo -n "to the original default value (vyatta)? (Yes/No) [No]: "
-read response
+read -p "Do you wish to change the root password? " response
response=${response:0:1}
if [ "$response" != "y" -a "$response" != "Y" ]; then
- echo "OK, the root password will not be reset."
+ echo "OK, the root password will not be changed."
echo -n "Rebooting in 5 seconds..."
sleep 5
echo
/sbin/reboot -f
fi
-
-echo "Starting process to reset the root password..."
+echo "Starting process to change the root password..."
echo "Re-mounting root filesystem read/write..."
mount -o remount,rw /
@@ -92,8 +91,10 @@ fi
echo "Saving backup copy of config.boot..."
cp $CF ${CF}.before_pwrecovery
-echo "Setting the root password..."
+echo
+change_password root
+echo "Root password changed"
echo $(date "+%b%e %T") $(hostname) "Root password changed" \
| tee -a /var/log/auth.log >>/var/log/messages