[pass] [PATCH 1/2] check for pwgen's existance before using

Brian Mattern rephorm at rephorm.com
Thu Sep 20 07:26:34 CEST 2012


also, move executable name to a var so it can be configured if needed
---
 src/password-store.sh |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/password-store.sh b/src/password-store.sh
index f0b965a..0cbff15 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -110,6 +110,7 @@ tmpdir() {
 }
 GPG="gpg"
 GETOPT="getopt"
+PWGEN="pwgen"
 
 # source /path/to/platform-defined-functions
 #
@@ -285,6 +286,8 @@ case "$command" in
 		git_add_file "$passfile" "$action password for $path using ${EDITOR:-vi}."
 		;;
 	generate)
+		command -v $PWGEN >/dev/null 2>&1 || { echo "The 'pwgen' utility must be installed to generate passwords."; exit 1; }
+
 		clip=0
 		symbols="-y"
 
@@ -308,7 +311,7 @@ case "$command" in
 			exit 1
 		fi
 		mkdir -p -v "$PREFIX/$(dirname "$path")"
-		pass="$(pwgen -s $symbols $length 1)"
+		pass="$($PWGEN -s $symbols $length 1)"
 		passfile="$PREFIX/$path.gpg"
 		$GPG -e -r "$ID" -o "$passfile" $GPG_OPTS <<<"$pass"
 		git_add_file "$passfile" "Added generated password for $path to store."
-- 
1.7.9.5




More information about the Password-Store mailing list