diff options
author | Jonas <dr@jones.dk> | 2013-11-16 16:42:12 +0100 |
---|---|---|
committer | Jonas <dr@jones.dk> | 2013-11-16 16:42:12 +0100 |
commit | de91cb7bfb38a9ad14f2f4c614cbcef51e5c8e69 (patch) | |
tree | d8f18665aa6a561c1bb7e236a86fd86bd9b21252 /localresetpasswd | |
parent | 8fdbfa672945f45614d6b11c0b229757145d1a84 (diff) |
Avoid sudo when executing as root.
Diffstat (limited to 'localresetpasswd')
-rwxr-xr-x | localresetpasswd | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/localresetpasswd b/localresetpasswd index 17f41fe..638e047 100755 --- a/localresetpasswd +++ b/localresetpasswd @@ -39,8 +39,11 @@ vecho -n "Generating random password..." pass=$(randompass) vecho " Done!" +sudo=sudo +[ "$(id -u)" -ne 0 ] || sudo= + vecho -n "Applying new password to account $u..." -echo "$u:$pass" | eval $simulate sudo "/usr/sbin/chpasswd" +echo "$u:$pass" | eval $simulate $sudo "/usr/sbin/chpasswd" vecho " Done!" eval $simulate localresetpasswdexpiry "$u" |