<html><head></head><body><div class="yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div>There appears to be a regression from 2.5.20: a decryption filename is passed when decrypting a file, which doesn't seem to preserve the file mode under some circumstances. The particular circumstance is that I call the decryption twice on the same input. The first time, I provide the entire input to be decrypted, and get a satisfactory response from gpg. The second call, to test a failure condition, makes the same call again, but doesn't provide the input data. In this case gpg returns an exit code of 2 (expected) but resets the file mode of the output file to 0100644, where it had originally been set to 0100700. Under 2.5.20, the mode of the file wasn't changed. So the behaviour has changed between 2.5.20 and 2.5.21: is there a good reason for this regression, or should an issue be raised? In case it is helpful, I show below some relevant messages from gpg and the test harness for both cases.</div><div><br></div><div dir="ltr" data-setdir="false">Kind regards,</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">Vinay Sajip</div><div><br></div><div>Results with 2.5.21:<br><br><font face=""lucida console", sans-serif"># Issue --list-config to get version<br>gpg2 --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir /tmp/keys-o279dt6b --list-config --with-colons<br># Chunk read from gpg:<br>b'cfg:version:2.5.21\ncfg:pubkey:1;8;16;17;18;19;22\ncfg:pubkeyname:RSA;Kyber;ELG;DSA;ECDH;ECDSA;EDDSA\ncfg:cipher:1;2;3;4;7;8;9;10;11;12;13\ncfg:ciphername:IDEA;3DES;CAST5;BLOWFISH;AES;AES192;AES256;TWOFISH;CAMELLIA128;CAMELLIA192;CAMELLIA256\ncfg:digest:2;3;8;9'<br># Set mode of output file to 0100700<br># Print mode and filename<br>Setting mode to 0o100700<br>Decrypting to: '/tmp/pygpg-test-gi5r5i66.dec'<br># First decryption call, all data provided<br>gpg2 --pinentry-mode loopback --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir /tmp/keys-o279dt6b --passphrase-fd 0 --debug-quick-random --decrypt --yes --output /tmp/pygpg-test-gi5r5i66.dec<br>[GNUPG:] ENC_TO 5B4383C7F494798C 16 0<br>[GNUPG:] ENC_TO 855C4BBE6268DE68 16 0<br>[GNUPG:] KEY_CONSIDERED C374DE3046D96CDB36368AC34EA7B9009176963B 0<br>gpg: encrypted with elg2048 key, ID 855C4BBE6268DE68, created 2026-07-13<br>      "Barbara Brown (A test user (insecure!)) <barbara.brown@beta.com>"<br>[GNUPG:] KEY_CONSIDERED 2C671107DCCB8D91E3A1D7F42DFD6E3937922755 0<br>gpg: encrypted with elg2048 key, ID 5B4383C7F494798C, created 2026-07-13<br>      "Andrew Able (A test user (insecure!)) <andrew.able@alpha.com>"<br>[GNUPG:] KEY_CONSIDERED 2C671107DCCB8D91E3A1D7F42DFD6E3937922755 0<br>[GNUPG:] KEY_CONSIDERED C374DE3046D96CDB36368AC34EA7B9009176963B 0<br>[GNUPG:] KEY_CONSIDERED C374DE3046D96CDB36368AC34EA7B9009176963B 0<br>[GNUPG:] DECRYPTION_KEY 493F33691752246E2EB3CA24855C4BBE6268DE68 C374DE3046D96CDB36368AC34EA7B9009176963B u<br>[GNUPG:] NO_SECKEY 5B4383C7F494798C<br>[GNUPG:] BEGIN_DECRYPTION<br>[GNUPG:] DECRYPTION_INFO 0 9 2 0<br>[GNUPG:] PLAINTEXT 62 1783966624<br>[GNUPG:] PLAINTEXT_LENGTH 13<br>[GNUPG:] DECRYPTION_OKAY<br>[GNUPG:] GOODMDC<br>[GNUPG:] END_DECRYPTION<br># Second decryption call, don't provide encrypted data (to test error condition)<br>gpg2 --pinentry-mode loopback --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir /tmp/keys-o279dt6b --passphrase-fd 0 --debug-quick-random --decrypt --yes --output /tmp/pygpg-test-gi5r5i66.dec<br>[GNUPG:] NODATA 2<br>[GNUPG:] FAILURE decrypt 4294967295<br>gpg: decrypt_message failed: Unknown system error<br># Message from test harness<br>gpg returned a non-zero error code: 2<br># Mode of decryption output changed!<br>Mode changed for /tmp/pygpg-test-gi5r5i66.dec: 0o100664 vs. 0o100700<br></font><br>Results with 2.5.20:<br><br><font face=""lucida console", sans-serif"># Issue --list-config to get version<br>gpg2 --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir /tmp/keys-_cyzu8yh --list-config --with-colons<br># Chunk read from gpg:<br>b'cfg:version:2.5.20\ncfg:pubkey:1;8;16;17;18;19;22\ncfg:pubkeyname:RSA;Kyber;ELG;DSA;ECDH;ECDSA;EDDSA\ncfg:cipher:1;2;3;4;7;8;9;10;11;12;13\ncfg:ciphername:IDEA;3DES;CAST5;BLOWFISH;AES;AES192;AES256;TWOFISH;CAMELLIA128;CAMELLIA192;CAMELLIA256\ncfg:digest:2;3;8;9'<br># Set mode of output file to 0100700<br># Print mode and filename<br>Setting mode to 0o100700<br>Decrypting to: '/tmp/pygpg-test-k9qni_nf.dec'<br># First decryption call, all data provided<br>gpg2 --pinentry-mode loopback --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir /tmp/keys-_cyzu8yh --passphrase-fd 0 --debug-quick-random --decrypt --yes --output /tmp/pygpg-test-k9qni_nf.dec<br>[GNUPG:] ENC_TO 7E265E8E78FAABE4 16 0<br>[GNUPG:] ENC_TO BC4907D9EA72A531 16 0<br>[GNUPG:] KEY_CONSIDERED 1B20FE90ADACD65EB49B83F92BA447C36E27A956 0<br>gpg: encrypted with elg2048 key, ID BC4907D9EA72A531, created 2026-07-13<br>      "Barbara Brown (A test user (insecure!)) <barbara.brown@beta.com>"<br>[GNUPG:] KEY_CONSIDERED 5B2F6F9C0E80D37C639FB4669941678A4D185900 0<br>gpg: encrypted with elg2048 key, ID 7E265E8E78FAABE4, created 2026-07-13<br>      "Andrew Able (A test user (insecure!)) <andrew.able@alpha.com>"<br>[GNUPG:] KEY_CONSIDERED 5B2F6F9C0E80D37C639FB4669941678A4D185900 0<br>[GNUPG:] KEY_CONSIDERED 1B20FE90ADACD65EB49B83F92BA447C36E27A956 0<br>[GNUPG:] KEY_CONSIDERED 1B20FE90ADACD65EB49B83F92BA447C36E27A956 0<br>[GNUPG:] DECRYPTION_KEY FAA65753EE4B871BCC824B6ABC4907D9EA72A531 1B20FE90ADACD65EB49B83F92BA447C36E27A956 u<br>[GNUPG:] NO_SECKEY 7E265E8E78FAABE4<br>[GNUPG:] BEGIN_DECRYPTION<br>[GNUPG:] DECRYPTION_INFO 0 9 2 0<br>[GNUPG:] PLAINTEXT 62 1783980806<br>[GNUPG:] PLAINTEXT_LENGTH 13<br>[GNUPG:] DECRYPTION_OKAY<br>[GNUPG:] GOODMDC<br>[GNUPG:] END_DECRYPTION<br># Second decryption call, don't provide encrypted data (to test error condition)<br>gpg2 --pinentry-mode loopback --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --with-colons --homedir /tmp/keys-_cyzu8yh --passphrase-fd 0 --debug-quick-random --decrypt --yes --output /tmp/pygpg-test-k9qni_nf.dec<br>[GNUPG:] NODATA 2<br>[GNUPG:] FAILURE decrypt 4294967295<br># Message from test harness<br>gpg: decrypt_message failed: Unknown system error<br># Message from test harness<br>gpg returned a non-zero error code: 2<br># No more output, as mode didn't change.</font><br><br><br><br></div></div></body></html>