pass show --clip bug

Kjetil Torgrim Homme kjetil.homme at redpill-linpro.com
Wed Jan 18 16:07:34 UTC 2023


Den 13/01/2023 04:13, skreiv Judd Montgomery:
> 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
> 

the patch looks good to me, much simpler and safer, and guaranteed to 
not trigger EPIPE.  you should however move your comments from the patch 
into a commit message, I don't think we want history like that in the 
script itself.

-- 
Kjetil T. Homme
Redpill Linpro - Changing the game



More information about the Password-Store mailing list