How to get rid of the "The GNOME keyring manager hijacked the GnuPG agent." warning

There is a new annoying feature in gnupg -- it warns you when you're using gnome-keyring:

$ gpg --decrypt somefile.gpg
[...]
gpg: WARNING: The GNOME keyring manager hijacked the GnuPG agent.
gpg: WARNING: GnuPG will not work properly - please configure that tool to not interfere with the GnuPG system!
[...]

Nevertheless, gnupg still works properly -- and I really don't want to disable gnome-keyring, as it also manages my SSH keys. So, how do we get rid of the warning? As it turns out, gnupg specifically checks for gnome-keyring in g10/call-agent.c:

/* Check whether gnome-keyring hijacked the gpg-agent.  */
static void
check_hijacking (assuan_context_t ctx)
{ 
  membuf_t mb;
  char *string;

  init_membuf (&mb, 64);

  /* AGENT_ID is a command implemented by gnome-keyring-daemon.  IT
     does not reatun any data but an OK line with a remark.  */
  if (assuan_transact (ctx, "AGENT_ID",
                       membuf_data_cb, &mb, NULL, NULL, NULL, NULL))
    { 
      xfree (get_membuf (&mb, NULL));
      return; /* Error - Probably not hijacked.  */
    }
  put_membuf (&mb, "", 1);
  string = get_membuf (&mb, NULL);
  if (!string || !*string)
    { 
      /* Definitely hijacked - show a warning prompt.  */

So you can just comment out this misfeature; or if you don't want to compile your own version of gnupg, all you need to do is change the AGENT_ID string to a command that gnome-keyring doesn't implement, say AGENX_ID:

sed -i s/AGENT_ID/AGENX_ID/ `which gpg2`

Comments !

social