password-store

Simple password manager using gpg and ordinary unix directories
git clone https://git.zx2c4.com/password-store
Log | Files | Refs | README | LICENSE

commit 0f0483f789e4819b029cf2f9d8168a6172da4d92
parent 04ff6261ca172aceb09bad926da68c41ba17b78e
Author: Jason A. Donenfeld <Jason@zx2c4.com>
Date:   Fri, 18 Apr 2014 12:38:52 +0200

init: allow deinitialization

Diffstat:
Mman/pass.1 | 4+++-
Msrc/password-store.sh | 16+++++++++++++++-
2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/man/pass.1 b/man/pass.1 @@ -63,7 +63,9 @@ Note that use of is recommended so that the batch decryption does not require as much user intervention. If \fI--path\fP or \fI-p\fP is specified, along with an argument, a specific gpg-id or set of gpg-ids is assigned for that specific sub folder of -the password store. +the password store. If only one \fIgpg-id\fP is given, and it is an empty string, +then the current \fI.gpg-id\fP file for the specified \fIsub-folder\fP (or root if +unspecified) is removed. .TP \fBls\fP \fIsubfolder\fP List names of passwords inside the tree at diff --git a/src/password-store.sh b/src/password-store.sh @@ -263,8 +263,22 @@ cmd_init() { fi fi - mkdir -v -p "$PREFIX/$id_path" local gpg_id="$PREFIX/$id_path/.gpg-id" + + if [[ $# -eq 1 && -z $1 ]]; then + if [[ ! -f "$gpg_id" ]]; then + echo "Error: $gpg_id does not exist and so cannot be removed." + exit 1 + fi + rm -v -f "$gpg_id" || exit 1 + if [[ -d $GIT_DIR ]]; then + git rm -qr "$gpg_id" + git_commit "Deinitialized ${gpg_id}." + fi + exit 0 + fi + + mkdir -v -p "$PREFIX/$id_path" printf "%s\n" "$@" > "$gpg_id" local id_print="$(printf "%s, " "$@")" echo "Password store initialized for ${id_print%, }"