commit 21d2c808587776b6c9c6b5357c79a3e43c8593c7
parent 1fd83c19a3b709e0132231d2e0b9337ad7b3c239
Author: Jaromil <jaromil@dyne.org>
Date:   Tue, 18 Apr 2017 08:58:55 +0200
password-store moved in $MAILDIRS
configurable via $JARO_PASSWORD_STORE_DIR env var
Diffstat:
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/jaro b/src/jaro
@@ -102,10 +102,11 @@ DRYRUN=${DRYRUN:-0}
 CALLMUTT=${CALLMUTT:-1}
 
 # use gnome-keyring for passwords on GNU systems
-vars+=(PASS GNOMEKEY SECRET_TOOL)
+vars+=(PASS GNOMEKEY SECRET_TOOL PASSWORD_STORE_DIR)
 PASS=${PASS:-0}
 GNOMEKEY=${GNOMEKEY:-0}
 SECRET_TOOL=${SECRET_TOOL:-0}
+PASSWORD_STORE_DIR=${JARO_PASSWORD_STORE_DIR:-$MAILDIRS/.password-store}
 
 # global variables for binaries called
 vars+=(rm mkdir mutt SQL OS)
@@ -346,11 +347,8 @@ check_bin() {
 		# check for pass, else fallback
 		if isfound pass; then
 			act "keyring in use: pass (auto-detected)"
-			export PASSWORD_STORE_DIR=${PASSWORD_STORE_DIR:-$HOME/.password-store}
-			[[ -d $PASSWORD_STORE_DIR ]] || {
-				error "the 'pass' keyring is found but not initialised"
-				error "run 'pass init your-gpg-id' or uninstall it to use other keyrings"
-			}
+			[[ -d $PASSWORD_STORE_DIR ]] ||
+				warning "the 'pass' keyring is found but not initialised"
 
 			PASS=1
 
diff --git a/src/zlibs/accounts b/src/zlibs/accounts
@@ -31,7 +31,7 @@ read_account() {
         host login transport auth cert options folders exclude
     # parse arguments
 
-    { test "$account" = "" } && { account="default" }
+    [[ "$account" = "" ]] && account="default"
 
     # find the account
     func "read_account looking for $account"
diff --git a/src/zlibs/keyring b/src/zlibs/keyring
@@ -21,6 +21,12 @@
 # Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 
+# pass wrapper to set all env
+_pass() {
+	fn pass $*
+	PASSWORD_STORE_DIR=$PASSWORD_STORE_DIR pass $*
+}
+
 # we use pinentry
 # comes from gpg project and is secure
 # it also conveniently uses the right toolkit
@@ -65,7 +71,7 @@ ask_password() {
         GNU)
             if [[ $PASS = 1 ]]; then
                 act "looking for password in password-store"
-                password=`pass show ${login}`
+                password=`_pass show ${login}`
                 [[ $? = 0 ]] && act "password found in password-store"
             elif [[ $SECRET_TOOL = 1 ]]; then
                 act "looking for password in secret-tool"
@@ -134,7 +140,7 @@ new_password() {
             # USE PASS
             if [[ $PASS = 1 ]]; then
                 act "using pass for password-store"
-                print "$password\n" | pass insert -e ${login}
+                print "$password\n" | _pass insert -e ${login}
                 if [[ $? = 0 ]]; then
                     notice "New password saved in password-store"
                 else