Opened 6 months ago

Last modified 2 months ago

#80 new task

possible race condition

Reported by: jamie Owned by:
Priority: major Milestone:
Component: usability Version: 2.0.0
Keywords: Cc:


I've been battling this weird problem for over a year and I have finally seem to have found a work-around.

Here's a description of the problem: sometimes when I use append-batch, I get an error:

gpg: no valid OpenPGP data found.
gpg: block_filter 0x00005595421fb850: read error (size=15267,a->size=15267)
gpg: encrypted_mdc packet with unknown version 255
:encrypted data packet: [unknown version]
gpg: block_filter: pending bytes!

Typically, after another user has added a new password, I'm able to successfully add a new password myself. However, if I try to add a second password I get the error.

This problem doesn't seem to affect other members of the team.

Change History (2)

comment:1 Changed 6 months ago by jamie

Results of additional debugging:

I narrowed the problem down to a failure to properly decrypt the file in actions/decrypt.

I finally fixed it with:

0 jamie@turkey:keyringer$ git diff actions/decrypt
diff --git a/lib/keyringer/actions/decrypt b/lib/keyringer/actions/decrypt
index e17f0e0..7442b29 100755
--- a/lib/keyringer/actions/decrypt
+++ b/lib/keyringer/actions/decrypt
@@ -11,7 +11,7 @@ source "$LIB" read $* || exit 1
 keyringer_get_file "$2"
 # Decrypt
-$GPG --use-agent -d "$KEYDIR/$FILE"
+cat "$KEYDIR/$FILE" | $GPG --use-agent -d -
 # Exit
 exit "$?"
0 jamie@turkey:keyringer$ 

I don't exactly know why this is happening but my theory is:

  • append-batch combines a decrypt with a pipe to then encrypt, using the same file name
  • perhaps ... when the file is signed with my key it is decrypted a tiny bit faster and/or since I have SSD disks things happen just a tiny bit faster - which results in the new file being written two before it is fully read

I'm not sure that's what is happening, but it's the only logical reason.

In any event, my fix above seems to do the trick.

comment:2 Changed 2 months ago by Silvio Rhatto

Patch applied as commit dbc0b92c6e32a0b9ca41e57aa58f76e61c71a9cd, thanks :)

Note: See TracTickets for help on using tickets.