Page MenuHome GnuPG

"gpg --logger-fd 1" doesn't override log-file in gpg.conf
Open, NormalPublic

Description

Prior to https://dev.gnupg.org/rG584b65ad7e937710a4fc6db42d6849bb3449d6ef, running gpg --decrypt --list-only --verbose --logger-fd 1 test.asc with log-file set in gpg.conf would produce output like:

gpg: public key is 0xA1F9838CBD46A1A8
gpg: using subkey 0xA1F9838CBD46A1A8 instead of primary key 0xDFE691AE331BA3DB
gpg: encrypted with 4096-bit RSA key, ID 0xA1F9838CBD46A1A8, created 2011-12-05
      "James McCoy (Debian) <jamessan@debian.org>"

After that commit, there is no output at all because it all gets redirected to the log file.

This breaks users of the vim-gnupg plugin that have log-file set in their config, since I now cannot determine whether a file was encrypted symmetrically or asymmetrically.

Typically, command-line options override ones from the config file, but these are treated as separate options so log-file wins out.

I'm also open to suggestions of better ways to handle this that are backward compatible with older gpg versions, if there's a more stable way to handle this (like --fixed-list-mode for querying keys).

Details

Event Timeline

Why are you using the log output for scripting? This is not its intended use. You need to use --status-fd. Log output is purely for human consumption it not a stable API. BTW, --fixed-list-mode has gone ages ago but it does not harm.

For example this is the output for a symmetric only decryption:

[GNUPG:] NEED_PASSPHRASE_SYM 7 3 2
[GNUPG:] BEGIN_DECRYPTION
[GNUPG:] DECRYPTION_INFO 2 7 0
[GNUPG:] PLAINTEXT 62 1645374780 
[GNUPG:] PLAINTEXT_LENGTH 6
hello
[GNUPG:] DECRYPTION_OKAY
[GNUPG:] GOODMDC
[GNUPG:] END_DECRYPTION

You might grep for the NEED_PASSPHRASE_SYM line to detect that the -c case. This has been here before version 1.0.0

Thanks! This plugin has been around for a long time, and this is one aspect I inherited from the original code. I'll look into reworking it to use the status output.

werner triaged this task as Normal priority.Feb 21 2022, 10:31 AM
werner edited projects, added Support, gnupg; removed Bug Report.

Feel free to ask me by PM if you run into problems (wk at gnupg.org). Two of my colleagues are Vim users and thus have an interest in a well working plugin :-). Thanks.