[BUG] pinentry-{gnome3, gtk-2} should set g_log_writer_default_set_use_stderr(true)

Kernc kerncece at gmail.com
Fri Jul 17 15:52:24 CEST 2026


pinentry-gnome3 and pinentry-gtk-2's debug messages are printed to
stdout, interfering with gpg-agent/pinentry stdout-stream-oriented
IPC.

For example:

    $ G_MESSAGES_DEBUG=all  pinentry-gnome3 2>/dev/null
    (process:21577): Gcr-DEBUG: 13:45:40.878: opening prompt
    (process:21577): Gcr-DEBUG: 13:45:40.878: connecting to bus
    (process:21577): Gcr-DEBUG: 13:45:40.881: connected to bus
    (process:21577): Gcr-DEBUG: 13:45:40.882: calling BeginPrompting
method on prompter
    (process:21577): Gcr-DEBUG: 13:45:40.925: registered prompt
org.gnome.keyring.SystemPrompter: /org/gnome/keyring/Prompt/p0
    (process:21577): Gcr-DEBUG: 13:45:40.984: creating new secret exchange
    (process:21577): Gcr-DEBUG: 13:45:40.984: automatically selecting
secret exchange protocol
    (process:21577): Gcr-DEBUG: 13:45:40.984: receiving secret exchange: ...
    (process:21577): Gcr-DEBUG: 13:45:40.984: generating public key
    (process:21577): Gcr-DEBUG: 13:45:40.989: deriving shared transport key
    (process:21577): Gcr-DEBUG: 13:45:40.989: deriving transport key
    (process:21577): Gcr-DEBUG: 13:45:40.995: closing prompt
    (process:21577): Gcr-DEBUG: 13:45:40.995: Calling the prompter
StopPrompting method
    OK Pleased to meet you, process 21577

When the variable G_MESSAGES_DEBUG is thusly set, the printed debug
messages wholly break pinentry IPC in a very confusing manner.

IMHO, both pinentry-gnome3 and pinentry-gtk-2 should issue
`g_log_writer_default_set_use_stderr(true)` [1] somewhere early in
their `main()`. While the default glib behavior seems aptly
nonsensical, the function docs do warn:

> By default, log messages of levels G_LOG_LEVEL_INFO and G_LOG_LEVEL_DEBUG are sent to stdout, and other log messages are sent to stderr. This is problematic for applications that intend to reserve stdout for structured output such as JSON or XML.

Several related stale bug reports are available on the GnuPG issue
tracker. [2, 3, 4, 5]

There's a bug open on Gcr [6], the lib that pinentry uses, but I'm not
really sure it's their bug. More like Glib's, but nobody can out-argue
IBM.

If somebody can ACK it, happy to send in a patch!
_____
[1]: https://gnome.pages.gitlab.gnome.org/gtk/glib/func.log_writer_default_set_use_stderr.html

[2]: https://dev.gnupg.org/T2397.html
[3]: https://dev.gnupg.org/T6177.html
[4]: https://dev.gnupg.org/T4144.html
[5]: https://dev.gnupg.org/T2243.html

[6]: https://gitlab.gnome.org/GNOME/gcr/-/work_items/142



More information about the Gnupg-devel mailing list