pass show --clip bug

Judd Montgomery judd at jpilot.org
Fri Jan 13 03:13:03 UTC 2023


Hi,

I have a secret that is over 1000 lines long and each line is on average
24 characters.  I noticed that the pass show -c[line-number] option only
works when trying to clip lines numbers greater than 850 or so.  Any
line number less than this fails with a return code of 141.  I suspect
this will vary depending on Linux kernel versions, tuning and buffer
sizes and I will try to explain why.

The error code 141 that gets returned in this case is pipefail. At the
top of the pass script is a "set -o pipefail" and that causes the script
to exit in this case.  This happens because the output of a tail command
is piped into a head -n 1 which closes the read pipe as soon as it reads
one line.  If the tail command is not done writing then it fails with a
pipefail (141) because its writing to a closed pipe.  Normally this is
not noticed or unexpected behavior.  When I show/clip lines near the end
of the file it succeeds because tail is done writing.  If I show/clip
lines early in the file then the tail command gets its pipe "rudely"
shutdown ;-)

I am attaching a patch that I tested.  I didn't write a test.

Here is an explanation I initially found
https://stackoverflow.com/questions/22464786/ignoring-bash-pipefail-for-error-code-141

Judd

-------------- next part --------------
A non-text attachment was scrubbed...
Name: password-store.sh-pipefile.patch
Type: text/x-patch
Size: 1154 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20230113/aa120d23/attachment.bin>


More information about the Password-Store mailing list