summaryrefslogtreecommitdiff
path: root/localresetpasswdexpiry
diff options
context:
space:
mode:
Diffstat (limited to 'localresetpasswdexpiry')
-rwxr-xr-xlocalresetpasswdexpiry35
1 files changed, 35 insertions, 0 deletions
diff --git a/localresetpasswdexpiry b/localresetpasswdexpiry
new file mode 100755
index 0000000..f4b6223
--- /dev/null
+++ b/localresetpasswdexpiry
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# /usr/local/bin/localresetpasswdexpiry
+# Copyright 2006 Jonas Smedegaard <dr@jones.dk>
+#
+# $Id: localresetpasswdexpiry,v 1.1 2006-08-31 22:51:03 jonas Exp $
+#
+# (re)set password expiry through sudo
+#
+# TODO: Check for bad arguments
+# TODO: Use getopts to offer help
+# TODO: Support overriding options in /etc/local file
+#
+
+set -e
+
+pass_expire=365
+pass_warn=14
+pass_lastday="`date --date='11 months ago' '+%F'`"
+
+verbose=1
+#simulate=true
+interactive=0
+
+# echo something, but only if in verbose mode
+vecho() {
+ test -n "$verbose" && echo "$@" >&2
+}
+
+u=$1
+shift
+
+vecho -n "Setting password expiry limits (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\""
+vecho " Done!"