[patch] --command-fd won't work (1.0.2 and earlier)

Michael Tokarev mjt at tls.msk.ru
Fri Aug 4 17:15:54 CEST 2000

Here is a small patch to current gnupg to allow usage of --command-fd
flag that just won't work.  I'm not shure if I'm right here, since
I'm not quite understand the logic in g10/status.c file.  At a first
glance, it's (file) purpose is to give some info to user (misc.
output routines), but _reading_ from user also there.
There is one static variable, fd, to output status info.  But it
is used also for reading from user in do_get_from_fd() routine.
When I use --command-fd=10, opt.command_fd initializes to that 10,
but `fd' in status.c still -1, and when do_get_from_fd() attempts
to read from it, it receive EBADF since fd=-1.  So I changed reference
to `fd' in do_get_from_fd() to opt.command_fd.  Patch is trivial.

-------------- next part --------------
--- gnupg-1.0.2/g10/status.c.orig	Tue Jun 27 13:25:15 2000
+++ gnupg-1.0.2/g10/status.c	Mon Jul 31 16:00:48 2000
@@ -364,7 +364,7 @@
 	/* Hmmm: why not use our read_line function here */
-	if( read( fd, string+i, 1) != 1 || string[i] == '\n' )
+	if( read( opt.command_fd, string+i, 1) != 1 || string[i] == '\n' )
     string[i] = 0;

More information about the Gnupg-devel mailing list