GnuPG locks when reading keyring in an automated script

Robert J. Hansen rjh at sixdemonbag.org
Fri Apr 21 23:26:17 CEST 2006


For a class project in human-computer interaction, I'm writing a key
manager interface for GnuPG.  We're using Java/SWT (runs just fine in
GCJ), and use GnuPG via the command line.

One of the beta users has run into a persistent problem where GnuPG
blocks indefinitely at some point in giving us the key information.
Recently, this problem has been reproducible on my own setup, too.

A quick outline of the code, and how we are invoking GnuPG, follows.

GnuPG is being invoked with "--fixed-list-mode --with-colons
--fingerprint --fingerprint --command-fd 0 --status-fd 1 --list-keys".
The loop of Java code which reads in this data looks as such:


// rv is an ArrayList
// ir is an input reader (really, a BufferedReader)

String line = ir.readLine();
while (line != null) {
  System.out.println(line);
  if (! line.equals("")) {
    String[] elems = line.split(":");
    ArrayList row = new ArrayList();
    for (int x = 0 ; x < elems.length ; x++)
      row.add(elems[x]);
    rv.add(row);
  }
  System.out.print("Reading... ");
  line = ir.readLine();
}

The output statements here are only for purposes of showing the error,
of course.

The output which I am getting looks like--trimming the output both for
sake of brevity and to protect the privacy of this person's email address--

Reading... uid:-::::1072805884::E63E9873ED6...
Reading... uid:-::::1072805999::4E82073DB5D...
Reading... uid:-::::1072805979::2B2EEEC3B23...
Reading... uid:-::::1072806025::66D07D8ACCD...
Reading... uid:-::::1072805917::26D9960CD42...
Reading...

... Doing this same thing at the command-line works fine.  It's only
when trying to read this from Java that it gets wedged.  Doing this from
the command-line, it appears GnuPG is wedging about 35% of the way
through my keyring.  The beta user who originally reported this problem
had it hit him when he was entirely done with the keyring--GnuPG would
block instead of closing the filehandle.

This behavior exists with GnuPG 1.4.3.  It didn't manifest in 1.4.2.2,
but that may not be saying much, given the error appears somewhat
nondeterministic.

The code works without any error on OS X, several Linux distros and
FreeBSD (OS X using Java 5, Linux using both Java 5 and GCJ, FreeBSD
using GCJ).

Thus, a couple of questions:

1.  Can anyone point me towards a solution or workaround?

2.  Does anyone know precisely what I'm doing wrong?  (Please note that
I don't claim to be a brilliant Win32 programmer; I try to avoid Win32
when possible.  Thus, it's very possible I'm doing something that makes
sense in UNIX which is stupid in Windows.)

3.  If this is a GnuPG bug, what additional information can I give to
help track this one down?




More information about the Gnupg-devel mailing list