summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlocalresetpasswd10
1 files changed, 6 insertions, 4 deletions
diff --git a/localresetpasswd b/localresetpasswd
index a7733f1..924a925 100755
--- a/localresetpasswd
+++ b/localresetpasswd
@@ -5,7 +5,7 @@
#
# $Id: localresetpasswd,v 1.1 2006-08-31 22:51:03 jonas Exp $
#
-# Generate random password and apply to account through sudo
+# Generate random passphrase and apply to account through sudo
#
# TODO: Check for bad arguments
# TODO: Use getopts to offer help
@@ -15,6 +15,7 @@
set -eu
# these are overridable as environment variables
+PHRASE_LENGTH=${PHRASE_LENGTH:-4}
WORD_LENGTH=${WORD_LENGTH:-11}
VERBOSE=${VERBOSE:-yes}
SIMULATE=${SIMULATE:-}
@@ -27,6 +28,7 @@ vecho() {
}
randompass() {
+ xkcdpass -n "$PHRASE_LENGTH" 2>&- ||
gpw 1 "$WORD_LENGTH" 2>&- ||
pwgen "$WORD_LENGTH" 1 2>&- ||
tr -d '\000-\057\072-\100\133-\140\173-\377' < /dev/urandom |
@@ -36,17 +38,17 @@ randompass() {
u=$1
shift
-vecho -n "Generating random password..."
+vecho -n "Generating random passphrase..."
pass=$(randompass)
vecho " Done!"
sudo=sudo
[ "$(id -u)" -ne 0 ] || sudo=
-vecho -n "Applying new password to account $u..."
+vecho -n "Applying new passphrase to account $u..."
echo "$u:$pass" | $simulate $sudo "/usr/sbin/chpasswd"
vecho " Done!"
$simulate localresetpasswdexpiry "$u"
-vecho "New password is $pass"
+vecho "New passphrase is $pass"