Bug : 100% under macOS if /usr/local/bin is not in the PATH

Bergoin Richard r.bergoin at openium.fr
Fri Apr 10 16:35:43 CEST 2020


First of all, thanks for this simple and easy way to securely share password across our team (and have an inventory of them)

I spotted a bug that makes bash hitting 100% cpu

to reproduce this issue :

    export PATH=/usr/bin:/bin:/usr/sbin:/sbin
    /usr/local/bin/pass ls
    /usr/local/bin/pass: line 350: /usr/local/bin/getopt: No such file or directory
      # 100 % cpu
    Killed: 9

adding a `set -x` points me to :

    /usr/local/bin/pass: line 352: /usr/local/bin/getopt: No such file or directory

so I fixed the getopt PATH in src/platform/darwin.sh (as `brew --prefix gnu-getopt` returns : "/usr/local/opt/gnu-getopt”, but as brew isn’t in the PATH...):

-GETOPT="$(brew --prefix gnu-getopt 2>/dev/null || { which port &>/dev/null && echo /opt/local; } || echo /usr/local)/bin/getopt"
+GETOPT="$(brew --prefix gnu-getopt 2>/dev/null || { which port &>/dev/null && echo /opt/local; } || echo /usr/local/opt/gnu-getopt)/bin/getopt”

Launched `/usr/local/bin/pass ls` again :

    /usr/local/bin/pass: line 385: tree: command not found

same issue with gpg not in the PATH:

    /usr/local/bin/pass show lists.zx2c4.com/r.bergoin at openium.fr
    /usr/local/bin/pass: line 367: gpg: command not found

Fixed by adding a TREE var to password-store.sh, and fixing them by adding in src/platform/darwin.sh :

+GPG="$(which gpg)"
+[[ -z "$TREE" ]] && TREE="/usr/local/bin/gpg"
+TREE="$(which tree)"
+[[ -z "$TREE" ]] && TREE="/usr/local/bin/tree”


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-infinite-loop-on-darwin.patch
Type: application/octet-stream
Size: 2441 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20200410/879a59dc/attachment.obj>
-------------- next part --------------

More information about the Password-Store mailing list