summaryrefslogtreecommitdiff
path: root/localresetpasswdexpiry
diff options
context:
space:
mode:
authorJonas <dr@jones.dk>2013-11-16 16:42:12 +0100
committerJonas <dr@jones.dk>2013-11-16 16:42:12 +0100
commitde91cb7bfb38a9ad14f2f4c614cbcef51e5c8e69 (patch)
treed8f18665aa6a561c1bb7e236a86fd86bd9b21252 /localresetpasswdexpiry
parent8fdbfa672945f45614d6b11c0b229757145d1a84 (diff)
Avoid sudo when executing as root.
Diffstat (limited to 'localresetpasswdexpiry')
-rwxr-xr-xlocalresetpasswdexpiry5
1 files changed, 4 insertions, 1 deletions
diff --git a/localresetpasswdexpiry b/localresetpasswdexpiry
index 6d01eb2..93b26e7 100755
--- a/localresetpasswdexpiry
+++ b/localresetpasswdexpiry
@@ -30,6 +30,9 @@ vecho() {
u=$1
shift
+sudo=sudo
+[ "$(id -u)" -ne 0 ] || sudo=
+
vecho -n "Set password aging for $u (expire: $pass_expire, warn: $pass_warn, lastday: $pass_lastday)..."
-eval $simulate sudo "/usr/bin/chage -M$pass_expire -W$pass_warn -d$pass_lastday \"$u\""
+eval $simulate $sudo "/usr/bin/chage -M$pass_expire -W$pass_warn -d$pass_lastday \"$u\""
vecho " Done!"