summaryrefslogtreecommitdiff
path: root/localresetpasswd
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2018-10-14 16:40:15 +0200
committerJonas Smedegaard <dr@jones.dk>2018-10-14 16:40:26 +0200
commitf8ff219c9104d327534dbecfd04a05e0e1e1c8e0 (patch)
tree353b01c835d193febcbc9550bfd3420a342fadb1 /localresetpasswd
parent3e84a76eac19ee01c4ffb8722e1263bea2ecd7fe (diff)
Add and favor xkcdpass passphrase.
Diffstat (limited to 'localresetpasswd')
-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"