From 5523b28a83b972c41bab55bea46e4a163895b5fb Mon Sep 17 00:00:00 2001 From: zawz Date: Wed, 20 Oct 2021 17:35:06 +0200 Subject: [PATCH] add ZPASS_RAND_SET config --- src/config.sh | 1 + src/help.sh | 1 + src/operation.sh | 7 ++++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/config.sh b/src/config.sh index 802ce43..8d03a93 100644 --- a/src/config.sh +++ b/src/config.sh @@ -33,6 +33,7 @@ ZPASS_KEY_CACHE_TIME=${ZPASS_KEY_CACHE_TIME-60} ZPASS_CLIPBOARD_TIME=${ZPASS_CLIPBOARD_TIME-30} ZPASS_UNK_OP_CALL=${ZPASS_UNK_OP_CALL-copy} ZPASS_RAND_LEN=${ZPASS_RAND_LEN-20} +ZPASS_RAND_SET=${ZPASS_RAND_SET-'a-zA-Z0-9\!-.'} # datapath resolution # remove tildes diff --git a/src/help.sh b/src/help.sh index 9c28e9a..d5df196 100644 --- a/src/help.sh +++ b/src/help.sh @@ -37,6 +37,7 @@ usage() ZPASS_CLIPBOARD_TIME '30' Time until clipboard gets cleared after copy, in seconds ZPASS_UNK_OP_CALL 'copy' Operation to call on unrecognized first argument ZPASS_RAND_LEN '20' Length of random passwords generated by 'new' + ZPASS_RAND_SET 'a-zA-Z0-9\!-.' Character set to use for 'new' generation ZPASS_REMOTE_METHOD 'scp' Method to use for remote file. scp/sftp/ftps/webdav ZPASS_REMOTE_ADDR Server the file is on ZPASS_REMOTE_PORT Server port diff --git a/src/operation.sh b/src/operation.sh index 31730b2..f13340f 100644 --- a/src/operation.sh +++ b/src/operation.sh @@ -47,13 +47,14 @@ new() [ $# -lt 1 ] && return 1 archive_exec sh -c '#LXSH_PARSE_MINIFY len=$1 - shift 1 + rset=$2 + shift 2 for N do mkdir -p "$(dirname "$N")" || exit $? - { tr -cd "a-zA-Z0-9\!-." < /dev/urandom | head -c$len && echo; } > "$N" || exit $? + { tr -cd "$rset" < /dev/urandom | head -c$len && echo; } > "$N" || exit $? done - ' zpass "$ZPASS_RAND_LEN" "$@" + ' zpass "$ZPASS_RAND_LEN" "$ZPASS_RAND_SET" "$@" } # $1 = path , $@ = value