[pass] [BUG?] pass allows both "x" and "x/y" bit hides "x"

Brian Mattern rephorm at rephorm.com
Mon May 20 18:47:46 CEST 2013


Here is a patch that fixes this behavior.

In your example, given x.gpg and x/y.gpg, `pass x` will show the
contents of x.gpg. `pass x/` will show a tree rooted at the x subfolder.

Brian

On Fri, 17 May 2013, Mark Lawrence wrote:

> First of all I'd like to say this is a great tool, thanks for writing
> and distributing it.
> 
> I believe I have observed undesirable behavior with regards passwords
> stored at one level, and then additional passwords created at a sub
> level.
> 
>     mark at lifebook:$ pass insert x
>     Enter password for x: 
>     Retype password for x: 
>     [master d42c10c] Added given password for x to store.
>      1 file changed, 0 insertions(+), 0 deletions(-)
>      create mode 100644 x.gpg
> 
>     mark at lifebook:$ pass x
>     password X
> 
> So far all well and good. If I now create a sublevel password I can
> read that sublevel password back:
> 
>     mark at lifebook:$ pass insert x/y
>     mkdir: created directory `/home/mark/.password-store/x'
>     Enter password for x/y: 
>     Retype password for x/y: 
>     [master 5078544] Added given password for x/y to store.
>      1 file changed, 0 insertions(+), 0 deletions(-)
>      create mode 100644 x/y.gpg
> 
>     mark at lifebook:~$ pass x/y
>     password X/Y
> 
> However I can no longer read the toplevel password as it returns a tree
> list instead:
> 
>     mark at lifebook:~$ pass x
>     x
>     `-- y
> 
> I would prefer a different behaviour (namely that "pass x" also
> displays a password if it exists) or at least doesn't allow the
> creation of the sublevel when the top level already exists.
> 
> Alternatively perhaps a configuration variable could be set somewhere
> to change the behavior one way or the other?
> 
> Mark.
> -- 
> Mark Lawrence
> _______________________________________________
> Password-Store mailing list
> Password-Store at lists.zx2c4.com
> http://lists.zx2c4.com/mailman/listinfo/password-store
-------------- next part --------------
From 42da89092c9f279fff85e4619291fe72de7582a1 Mon Sep 17 00:00:00 2001
From: Brian Mattern <rephorm at rephorm.com>
Date: Mon, 20 May 2013 09:44:33 -0700
Subject: [PATCH] check if a passfile exists before checking for directory

---
 src/password-store.sh | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/src/password-store.sh b/src/password-store.sh
index d7b00b7..e080627 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -207,19 +207,8 @@ case "$command" in
 		fi
 
 		path="$1"
-		if [[ -d $PREFIX/$path ]]; then
-			if [[ -z $path ]]; then
-				echo "Password Store"
-			else
-				echo "${path%\/}"
-			fi
-			tree -l --noreport "$PREFIX/$path" | tail -n +2 | sed 's/\.gpg$//'
-		else
-			passfile="$PREFIX/$path.gpg"
-			if [[ ! -f $passfile ]]; then
-				echo "$path is not in the password store."
-				exit 1
-			fi
+		passfile="$PREFIX/$path.gpg"
+		if [[ -f $passfile ]]; then
 			if [[ $clip -eq 0 ]]; then
 				exec gpg2 -d $GPG_OPTS "$passfile"
 			else
@@ -227,6 +216,16 @@ case "$command" in
 				[[ -n $pass ]] || exit 1
 				clip "$pass" "$path"
 			fi
+		elif [[ -d $PREFIX/$path ]]; then
+			if [[ -z $path ]]; then
+				echo "Password Store"
+			else
+				echo "${path%\/}"
+			fi
+			tree -l --noreport "$PREFIX/$path" | tail -n +2 | sed 's/\.gpg$//'
+		else
+			echo "$path is not in the password store."
+			exit 1
 		fi
 		;;
 	insert)
-- 
1.8.2



More information about the Password-Store mailing list