[pass] [PATCH] generate: optionally edit generated password file
Micha Rosenbaum
micha at rosetree.de
Sat Feb 6 23:02:54 CET 2016
Will the following patch be merged or does something speak against it?
On Fri, Dec 18, 2015 at 01:38:43AM -0500, Nathan Wallace wrote:
> This enables users to generate a password and immediately edit the
> password file. This would simplify the process of generating a password
> and storing other information in the password file (like username, or
> email)
> ---
> src/password-store.sh | 15 +++++++++------
> tests/t0010-generate-tests.sh | 8 ++++++++
> 2 files changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/src/password-store.sh b/src/password-store.sh
> index d535a74..fb14f44 100755
> --- a/src/password-store.sh
> +++ b/src/password-store.sh
> @@ -234,11 +234,12 @@ cmd_usage() {
> overwriting existing password unless forced.
> $PROGRAM edit pass-name
> Insert a new password or edit an existing password using ${EDITOR:-vi}.
> - $PROGRAM generate [--no-symbols,-n] [--clip,-c] [--in-place,-i | --force,-f] pass-name pass-length
> + $PROGRAM generate [--no-symbols,-n] [--clip,-c] [--in-place,-i | --force,-f] [--edit,-e] pass-name pass-length
> Generate a new password of pass-length with optionally no symbols.
> Optionally put it on the clipboard and clear board after $CLIP_TIME seconds.
> Prompt before overwriting existing password unless forced.
> Optionally replace only the first line of an existing file with a new password.
> + Optionally edit the password file using ${EDITOR:-vi}.
> $PROGRAM rm [--recursive,-r] [--force,-f] pass-name
> Remove existing password or directory, optionally forcefully.
> $PROGRAM mv [--force,-f] old-path new-path
> @@ -429,8 +430,8 @@ cmd_edit() {
> }
>
> cmd_generate() {
> - local opts clip=0 force=0 symbols="-y" inplace=0
> - opts="$($GETOPT -o ncif -l no-symbols,clip,in-place,force -n "$PROGRAM" -- "$@")"
> + local opts clip=0 force=0 symbols="-y" inplace=0 edit=0
> + opts="$($GETOPT -o ncife -l no-symbols,clip,in-place,force,edit -n "$PROGRAM" -- "$@")"
> local err=$?
> eval set -- "$opts"
> while true; do case $1 in
> @@ -438,10 +439,11 @@ cmd_generate() {
> -c|--clip) clip=1; shift ;;
> -f|--force) force=1; shift ;;
> -i|--in-place) inplace=1; shift ;;
> + -e|--edit) edit=1; shift ;;
> --) shift; break ;;
> esac done
>
> - [[ $err -ne 0 || $# -ne 2 || ( $force -eq 1 && $inplace -eq 1 ) ]] && die "Usage: $PROGRAM $COMMAND [--no-symbols,-n] [--clip,-c] [--in-place,-i | --force,-f] pass-name pass-length"
> + [[ $err -ne 0 || $# -ne 2 || ( $force -eq 1 && $inplace -eq 1 ) ]] && die "Usage: $PROGRAM $COMMAND [--no-symbols,-n] [--clip,-c] [--in-place,-i | --force,-f] [--edit,-e] pass-name pass-length"
> local path="$1"
> local length="$2"
> check_sneaky_paths "$path"
> @@ -469,10 +471,11 @@ cmd_generate() {
> [[ $inplace -eq 1 ]] && verb="Replace"
> git_add_file "$passfile" "$verb generated password for ${path}."
>
> - if [[ $clip -eq 0 ]]; then
> + if [[ $clip -eq 0 && $edit -eq 0 ]]; then
> printf "\e[1m\e[37mThe generated password for \e[4m%s\e[24m is:\e[0m\n\e[1m\e[93m%s\e[0m\n" "$path" "$pass"
> else
> - clip "$pass" "$path"
> + [[ $edit -eq 1 ]] && cmd_edit "$path"
> + [[ $clip -eq 1 ]] && clip "$pass" "$path"
> fi
> }
>
> diff --git a/tests/t0010-generate-tests.sh b/tests/t0010-generate-tests.sh
> index cadb76f..cdda325 100755
> --- a/tests/t0010-generate-tests.sh
> +++ b/tests/t0010-generate-tests.sh
> @@ -16,4 +16,12 @@ test_expect_success 'Test replacement of first line' '
> [[ $("$PASS" show cred2) == "$(printf "This is a fake password\\npassword\\nwith\\nmany\\nlines\\nin it bla bla")" ]]
> '
>
> +test_expect_success 'Test "generate" and edit' '
> + export FAKE_EDITOR_PASSWORD="overwritten" &&
> + export PATH="$TEST_HOME:$PATH"
> + export EDITOR="fake-editor-change-password.sh" &&
> + "$PASS" generate -e cred1 10 &&
> + [[ $("$PASS" show cred1) == "$FAKE_EDITOR_PASSWORD" ]]
> +'
> +
> test_done
> --
> 2.5.0
>
> _______________________________________________
> Password-Store mailing list
> Password-Store at lists.zx2c4.com
> http://lists.zx2c4.com/mailman/listinfo/password-store
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20160206/dc4b2622/attachment-0001.asc>
More information about the Password-Store
mailing list