From 93c025c69aac8867916bbd0f5813765fac7d852b Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 21 Sep 2012 03:32:09 +0200 Subject: Add option to init to reencrypt all passwords. Reported-by: Simon KP --- src/password-store.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/password-store.sh') diff --git a/src/password-store.sh b/src/password-store.sh index 9923907..f137f55 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -30,8 +30,9 @@ usage() { cat <<_EOF Usage: - $program init gpg-id + $program init [--reencrypt,-e] gpg-id Initialize new password storage and use gpg-id for encryption. + Optionally reencrypt existing passwords using new gpg-id. $program [ls] [subfolder] List passwords. $program [show] [--clip,-c] pass-name @@ -134,15 +135,34 @@ fi case "$command" in init) + reencrypt=0 + + opts="$($GETOPT -o e -l reencrypt -n "$program" -- "$@")" + err=$? + eval set -- "$opts" + while true; do case $1 in + -e|--reencrypt) reencrypt=1; shift ;; + --) shift; break ;; + esac done + if [[ $# -ne 1 ]]; then - echo "Usage: $program $command gpg-id" + echo "Usage: $program $command [--reencrypt,-e] gpg-id" exit 1 fi + gpg_id="$1" mkdir -v -p "$PREFIX" echo "$gpg_id" > "$ID" echo "Password store initialized for $gpg_id." git_add_file "$ID" "Set GPG id to $gpg_id." + + if [[ $reencrypt -eq 1 ]]; then + find "$PREFIX" -iname '*.gpg' | while read passfile; do + $GPG -d $GPG_OPTS "$passfile" | $GPG -e -r "$gpg_id" -o "$passfile.new" $GPG_OPTS && + mv -v "$passfile.new" "$passfile" + done + git_add_file "$PREFIX" "Reencrypted entire store using new GPG id $gpg_id." + fi exit 0 ;; help|--help) -- cgit v1.2.3-54-g00ecf git/log/i18n'>
Commit message (Expand)AuthorFilesLines
2009-10-23Change the new_version plugin to use git.René 'Necoro' Neumann2-32/+33
2009-10-15Objectified all the functional stuff in backend.__init__.René 'Necoro' Neumann2-32/+34
2009-10-08Enhance the splash window handling.René 'Necoro' Neumann2-2/+9
2009-10-08Enhance the splash window handling.René 'Necoro' Neumann2-2/+9
2009-10-05Some more stuff to ignoreRené 'Necoro' Neumann1-0/+3
2009-10-05Renamed the ignore fileRené 'Necoro' Neumann1-0/+0
2009-10-05Update NEWSRené 'Necoro' Neumann1-0/+1
2009-10-05Also allow 'unselect all' in the PkgListRené 'Necoro' Neumann1-1/+10
2009-10-05Now have it the sorted way in PkgListsRené 'Necoro' Neumann2-3/+9
2009-10-05Enhanced system.sort_package_list to also sort CPVsRené 'Necoro' Neumann5-27/+38
2009-10-05Added an PkgList window and rewrote UpdateWindow and WorldListWindow to use itRené 'Necoro' Neumann3-39/+63
2009-10-05Add uninstall button and rename to PkgListWindowRené 'Necoro' Neumann1-2/+17
2009-10-05First quick hack to have a world listRené 'Necoro' Neumann3-2/+24