Page MenuHome GnuPG

--use-agent + no agent + successfull operation = failure return value
Closed, ResolvedPublic

Description

Release: 1.4.1

Environment

Debian GNU/Linux

  • System Information: Debian Release: 3.1 APT prefers testing APT policy: (300, 'testing'), (200, 'unstable'), (1, 'experimental') Architecture: i386 (i686) Kernel: Linux 2.6.11 Locale: LANG=fr_LU.UTF-8, LC_CTYPE=fr_LU.UTF-8 (charmap=UTF-8)

    Versions of packages gnupg depends on: ii libbz2-1.0 1.0.2-7 high-quality block-sorting file co ii libc6 2.3.5-3 GNU C Library: Shared libraries an ii libldap2 2.1.30-8 OpenLDAP libraries ii libreadline5 5.0-10 GNU readline and history libraries ii libusb-0.1-4 2:0.1.10a-9.sarge.1 userspace USB programming library ii makedev 2.3.1-77 creates device files in /dev ii zlib1g 1:1.2.2-4.sarge.2 compression library - runtime

Description

When one uses --use-agent, but no agent is present, GnuPG falls back
to asking for a passphrase the old way. So far, so good. If one enters
the right passphrase, GnuPG successfully does the operation
(e.g. sign), but then exits with a failure exit code:

master@tofu:~/src/hylafax$ gpg --sign capi4hylafax_01.03.00-1.dsc
You need a passphrase to unlock the secret key for
user: "Lionel Elie Mamane <lionel@mamane.lu>"
1024-bit DSA key, ID 3E7B4B73, created 1998-12-02

gpg: gpg-agent is not available in this session

master@tofu:~/src/hylafax$ echo $?
2

master@tofu:~/src/hylafax$ gpg --no-use-agent --sign capi4hylafax_01.03.00-1.dsc

You need a passphrase to unlock the secret key for
user: "Lionel Elie Mamane <lionel@mamane.lu>"
1024-bit DSA key, ID 3E7B4B73, created 1998-12-02

File `capi4hylafax_01.03.00-1.dsc.gpg' exists. Overwrite? (y/N) y
master@tofu:~/src/hylafax$ echo $?
0

The operation was done successfully, hence it should exit with return
code 0, not non-zero.

This breaks scripts that call gnupg and check the return value for success or failure.

How To Repeat

See description.

Fix

Make it return 0 if the operation is successful

Release Note

Fixed in my working copy:

  • passphrase.c (agent_open): Print a warning and not an error in case of a missing agent. Should fix Debian bug #325578.

    Patch already sent to the Debian tracker.

Event Timeline

From: owner@bugs.debian.org (Debian Bug Tracking System)
To: bug-any@bugs.gnupg.org
Cc:
Subject: Bug#325578: Info received (was gnupg/528)
Date: Tue, 30 Aug 2005 10:18:09 -0700

Thank you for the additional information you have supplied regarding
this problem report. It has been forwarded to the package maintainer(s)
and to other interested parties to accompany the original report.

Your message has been sent to the package maintainer(s):
James Troup <james@nocrew.org>

If you wish to continue to submit further information on your problem,
please send it to 325578@bugs.debian.org, as before.

Please do not reply to the address at the top of this message,
unless you wish to report a problem with the Bug-tracking system.

Debian bug tracking system administrator
(administrator, Debian Bugs database)

From: Lionel Elie Mamane <lmamane@debian.org>
To: bug-any@bugs.gnupg.org
Cc: gnupg-hackers@gnupg.org, gnats-admin@trithemius.gnupg.org, wk@gnupg.org,
325578@bugs.debian.org
Subject: Re: gnupg/528
Date: Tue, 30 Aug 2005 20:12:09 +0200

--PNTmBPCT7hxwcZjr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Aug 30, 2005 at 07:03:05PM +0200, wk@gnupg.org wrote:

Synopsis: --use-agent + no agent + successfull operation = failure return value

State-Changed-From-To: open->feedback
State-Changed-By: werner
State-Changed-When: Tue, 30 Aug 2005 19:03:05 +0200
State-Changed-Why:
Patch sent to Debian BTS.

The patch sent there doesn't apply to the Debian package; the code
looks different. The one attached here applies, seems to be what you
meant and seems to work.

Lionel

--PNTmBPCT7hxwcZjr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="gnupg_debian.patch"

  • g10/passphrase.c~ 2005-08-30 19:56:35.000000000 +0200

+++ g10/passphrase.c 2005-08-30 19:58:27.000000000 +0200
@@ -475,7 +475,7 @@

if ( !(infostr = read_w32_registry_string(NULL, "Software\\GNU\\GnuPG",
                                          "agentPID")) 
     || *infostr == '0') {
  • log_error( _("gpg-agent is not available in this session\n"));

+ log_info( _("gpg-agent is not available in this session\n"));

	return -1;
}
free(infostr);

@@ -522,7 +522,7 @@

{
  infostr = getenv ( "GPG_AGENT_INFO" );
  if ( !infostr ) {
  • log_error (_("gpg-agent is not available in this session\n"));

+ log_info (_("gpg-agent is not available in this session\n"));

  opt.use_agent = 0;
  return -1;
}

--PNTmBPCT7hxwcZjr--

Patch sent to Debian BTS.

werner removed a project: Restricted Project.