carnager/rofi-pass

rofi-pass doesn't follow symlinks with new versions of Bash

justinsteven opened this issue · 1 comments

Bash's globstar used to follow symlinks. Symlinks are well supported by pass in my experience. This support might be accidental or intentional - but I use it heavily.

Newer versions of Bash no longer follow symlinks when doing a globstar match (See https://unix.stackexchange.com/a/220138)

This breaks list_passwords() and listgpg() functions in rofi-pass when the PASSWORD_STORE_DIR contains symlinks to other directories.

Consider the following reproducer:

#!/bin/bash

bash --version | head -n1

shopt -s nullglob globstar
list_passwords() {
    # borrowed from rofi-pass
    pushd "$1" >/dev/null || exit
    pw_list=(**/*.gpg)
    printf '%s\n' "${pw_list[@]%.gpg}" | sort -n
    popd >/dev/null
}

export PASSWORD_STORE_DIR=$(mktemp -d)
echo "PASSWORD_STORE_DIR: $PASSWORD_STORE_DIR"
PASSWORD_STORE_REMOTE=$(mktemp -d)

pass init ${GPG_KEY:-0xfc541779}
echo

uuidgen -r | pass insert -e mypass1
uuidgen -r | pass insert -e mypass2

ln -s $PASSWORD_STORE_REMOTE $PASSWORD_STORE_DIR/remote

uuidgen -r | pass insert -e remote/mypass3
uuidgen -r | pass insert -e remote/mypass4

echo "--- BEGIN pass ---"
pass
echo "--- END pass ---"
echo

echo "--- BEGIN list_passwords ---"
list_passwords $PASSWORD_STORE_DIR
echo "--- END list_passwords ---"
echo

echo "Running rofi-pass"
./rofi-pass

Running this on Debian Stretch (currently "oldstable") gives:

% ./repro.bsh 
GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
PASSWORD_STORE_DIR: /tmp/tmp.TGaOswPOMX
Password store initialized for 0xfc541779

--- BEGIN pass ---
Password Store
├── mypass1
├── mypass2
└── remote -> /tmp/tmp.b86f9QiW6R
    ├── mypass3
    └── mypass4
--- END pass ---

--- BEGIN list_passwords ---
mypass1
mypass2
remote/mypass3
remote/mypass4
--- END list_passwords ---

Running rofi-pass
[... rofi-pass pops up and shows all four passwords ...]

This demonstrates good support for symlinks.

However, running it on Debian Buster (currently "stable") gives:

% ./repro.bsh 
GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)
PASSWORD_STORE_DIR: /tmp/tmp.eeXBQowSCc
Password store initialized for 0xfc541779

--- BEGIN pass ---
Password Store
├── mypass1
├── mypass2
└── remote -> /tmp/tmp.B8UYJXxGIm
    ├── mypass3
    └── mypass4
--- END pass ---

--- BEGIN list_passwords ---
mypass1
mypass2
--- END list_passwords ---

Running rofi-pass
[... rofi-pass pops up and only shows 'mypass1' and 'mypass2' ...]

This demonstrates no support for symlinks.

Fixed by #179