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 72f3e6acde61d73dc2ca7a96c0d59716cc3c1d48
parent 0fb529fc0ea2e6ff1f5ed88902510322e2c8a693
Author: Jason A. Donenfeld <Jason@zx2c4.com>
Date:   Wed, 21 Dec 2016 16:27:07 +0100

extensions: introduce system extensions

Diffstat:
MMakefile | 4++--
Msrc/password-store.sh | 19++++++++++++++-----
2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile @@ -40,12 +40,12 @@ ifneq ($(strip $(wildcard $(PLATFORMFILE))),) install: install-common @install -v -d "$(DESTDIR)$(LIBDIR)/password-store" && install -m 0644 -v "$(PLATFORMFILE)" "$(DESTDIR)$(LIBDIR)/password-store/platform.sh" @install -v -d "$(DESTDIR)$(BINDIR)/" - sed 's:.*PLATFORM_FUNCTION_FILE.*:source "$(DESTDIR)$(LIBDIR)/password-store/platform.sh":' src/password-store.sh > "$(DESTDIR)$(BINDIR)/pass" + sed 's:.*PLATFORM_FUNCTION_FILE.*:source "$(LIBDIR)/password-store/platform.sh":;s:^SYSTEM_EXTENSION_DIR=.*:SYSTEM_EXTENSION_DIR="$(LIBDIR)/password-store/extensions":' src/password-store.sh > "$(DESTDIR)$(BINDIR)/pass" @chmod 0755 "$(DESTDIR)$(BINDIR)/pass" else install: install-common @install -v -d "$(DESTDIR)$(BINDIR)/" - sed '/PLATFORM_FUNCTION_FILE/d' src/password-store.sh > "$(DESTDIR)$(BINDIR)/pass" + sed '/PLATFORM_FUNCTION_FILE/d;s:^SYSTEM_EXTENSION_DIR=.*:SYSTEM_EXTENSION_DIR="$(LIBDIR)/password-store/extensions":' src/password-store.sh > "$(DESTDIR)$(BINDIR)/pass" @chmod 0755 "$(DESTDIR)$(BINDIR)/pass" endif diff --git a/src/password-store.sh b/src/password-store.sh @@ -603,12 +603,21 @@ cmd_extension_or_show() { cmd_show "$@" fi } + +SYSTEM_EXTENSION_DIR="" cmd_extension() { - [[ $PASSWORD_STORE_ENABLE_EXTENSIONS == true ]] || return 1 - local extension="$EXTENSIONS/$1.bash" - check_sneaky_paths "$extension" - [[ -f $extension && -x $extension ]] || return 1 - verify_file "$extension" + check_sneaky_paths "$1" + local user_extension system_extension extension + [[ -n $SYSTEM_EXTENSION_DIR ]] && system_extension="$SYSTEM_EXTENSION_DIR/$1.bash" + [[ $PASSWORD_STORE_ENABLE_EXTENSIONS == true ]] && user_extension="$EXTENSIONS/$1.bash" + if [[ -n $user_extension && -f $user_extension && -x $user_extension ]]; then + verify_file "$user_extension" + extension="$user_extension" + elif [[ -n $system_extension && -f $system_extension && -x $system_extension ]]; then + extension="$system_extension" + else + return 1 + fi shift source "$extension" "$@" return 0