Getting EGD socket name from command-line
gnupg-devel at thewrittenword.com
gnupg-devel at thewrittenword.com
Mon Mar 5 18:11:01 CET 2001
Ok, here's a version that adds a new command-line option,
--egd-socket=PATH, to override the pre-compiled
--with-egd-socket=PATH.
One ugliness below is the dependency on g10/options.o in
tools/Makefile.am. Anyone have a better workaround?
It also moves the global 'opt' variable from g10/g10.c to
g10/options.c. GnuPG does a bad thing and redefines global variables.
There should be *one* definition. Every other .c file should have the
variable defined EXTERN. Many linkers do not report duplicate symbol
errors (the result of this). IRIX does:
ld32: WARNING 15 : Multiply defined:(iobuf_debug_mode) in shmtest.o
and ../util/libutil.a(logger.o) (2nd definition ignored).
ld32: WARNING 15 : Multiply defined:(memory_debug_mode) in shmtest.o
and ../util/libutil.a(logger.o) (2nd definition ignored).
ld32: WARNING 15 : Multiply defined:(memory_stat_debug_mode) in
shmtest.o and ../util/libutil.a(logger.o) (2nd definition ignored).
ld32: WARNING 15 : Multiply defined:(mpi_debug_mode) in shmtest.o and
../util/libutil.a(logger.o) (2nd definition ignored).
ld32: WARNING 15 : Multiply defined:(iobuf_debug_mode) in shmtest.o
and ../util/libutil.a(ttyio.o) (2nd definition ignored).
ld32: WARNING 15 : Multiply defined:(memory_debug_mode) in shmtest.o
and ../util/libutil.a(ttyio.o) (2nd definition ignored).
ld32: WARNING 15 : Multiply defined:(memory_stat_debug_mode) in
shmtest.o and ../util/libutil.a(ttyio.o) (2nd definition ignored).
...
--
albert chin (china at thewrittenword.com)
-- snip snip
--- /dev/null Sat Nov 11 12:59:35 2000
+++ g10/options.c Mon Mar 5 10:53:27 2001
@@ -0,0 +1,28 @@
+/* options.c - Define command-line options
+ * Copyright (C) 2001 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+
+/* The following causes "options.h" to produce definitions of all
+ the global variables, rather than just "extern" definitions
+ of them.
+ */
+#define GLOBAL
+#include "options.h"
--- cipher/rndegd.c.orig Sun Mar 4 23:48:44 2001
+++ cipher/rndegd.c Mon Mar 5 09:16:48 2001
@@ -35,6 +35,7 @@
#include "ttyio.h"
#include "dynload.h"
#include "cipher.h"
+#include "options.h"
#ifdef IS_MODULE
#define _(a) (a)
@@ -118,9 +119,12 @@
char *name;
struct sockaddr_un addr;
int addr_len;
-
+
#ifdef EGD_SOCKET_NAME
- bname = EGD_SOCKET_NAME;
+ if (opt.egd_socket)
+ bname = opt.egd_socket;
+ else
+ bname = EGD_SOCKET_NAME;
#endif
if ( !bname || !*bname )
bname = "entropy";
--- g10/g10.c.orig Mon Mar 5 08:54:43 2001
+++ g10/g10.c Mon Mar 5 09:34:22 2001
@@ -65,6 +65,7 @@
oUser = 'u',
oVerbose = 'v',
oCompress = 'z',
+ oEgdSocket = 'E',
oNotation = 'N',
oBatch = 500,
aClearsign,
@@ -310,6 +311,7 @@
{ oCompressAlgo, "compress-algo", 1 , N_("|N|use compress algorithm N")},
{ oThrowKeyid, "throw-keyid", 0, N_("throw keyid field of encrypted packets")},
{ oNotation, "notation-data", 2, N_("|NAME=VALUE|use this notation data")},
+ { oEgdSocket, "egd-socket", 2, N_("|PATH|override pre-compiled path to EGD socket")},
{ 302, NULL, 0, N_(
"@\n(See the man page for a complete listing of all commands and options)\n"
@@ -632,6 +634,7 @@
opt.max_cert_depth = 5;
opt.pgp2_workarounds = 1;
opt.auto_key_retrieve = 1;
+ opt.egd_socket = NULL;
#ifdef __MINGW32__
opt.homedir = read_w32_registry_string( NULL, "Software\\GNU\\GnuPG", "HomeDir" );
#else
@@ -937,7 +940,7 @@
case oMergeOnly: opt.merge_only = 1; break;
case oTryAllSecrets: opt.try_all_secrets = 1; break;
case oTrustedKey: register_trusted_key( pargs.r.ret_str ); break;
-
+ case oEgdSocket: opt.egd_socket = m_strdup( pargs.r.ret_str ); break;
default : pargs.err = configfp? 1:2; break;
}
}
--- g10/options.h.orig Mon Mar 5 09:02:10 2001
+++ g10/options.h Mon Mar 5 09:14:40 2001
@@ -24,8 +24,15 @@
#undef ENABLE_COMMENT_PACKETS /* don't create comment packets */
+/* GLOBAL is defined to empty in g10.c only, and left alone
+ in other *.c modules. Here, we merely set it to "extern" if
+ it is not already set.
+ */
+#ifndef GLOBAL
+#define GLOBAL extern
+#endif
-struct {
+GLOBAL struct {
int verbose;
int quiet;
unsigned debug;
@@ -96,6 +103,7 @@
int show_session_key;
int merge_only;
int try_all_secrets;
+ const char *egd_socket; /* override pre-compiled path to EGD socket */
} opt;
--- g10/gpgv.c.orig Mon Mar 5 09:28:55 2001
+++ g10/gpgv.c Mon Mar 5 09:33:27 2001
@@ -35,7 +35,14 @@
#include "memory.h"
#include "util.h"
#include "main.h"
+
+/* The following causes "options.h" to produce definitions of all
+ the global variables, rather than just "extern" definitions
+ of them.
+ */
+#define GLOBAL
#include "options.h"
+
#include "keydb.h"
#include "trustdb.h"
#include "mpi.h"
--- cipher/Makefile.am.orig Mon Mar 5 09:17:51 2001
+++ cipher/Makefile.am Mon Mar 5 09:18:04 2001
@@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in
-INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl
+INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl -I$(top_srcdir)/g10
noinst_LIBRARIES = libcipher.a
--- tools/Makefile.am.orig Mon Mar 5 09:21:50 2001
+++ tools/Makefile.am Mon Mar 5 09:52:10 2001
@@ -2,7 +2,7 @@
EXTRA_DIST = lspgpot ring-a-party mail-signed-keys
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl
-needed_libs = ../cipher/libcipher.a \
+needed_libs = ../g10/options.o ../cipher/libcipher.a \
../mpi/libmpi.a ../util/libutil.a @INTLLIBS@
noinst_PROGRAMS = mpicalc bftest clean-sat mk-tdata shmtest
--- g10/Makefile.am.orig Mon Mar 5 09:35:08 2001
+++ g10/Makefile.am Mon Mar 5 09:35:26 2001
@@ -25,6 +25,7 @@
mdfilter.c \
textfilter.c \
misc.c \
+ options.c \
options.h \
openfile.c \
keyid.c \
--- Makefile.am.orig Mon Mar 5 09:59:30 2001
+++ Makefile.am Mon Mar 5 09:59:40 2001
@@ -6,7 +6,7 @@
checks = checks
endif
-SUBDIRS = intl zlib util mpi cipher tools g10 po doc ${checks}
+SUBDIRS = intl zlib util mpi cipher g10 tools po doc ${checks}
EXTRA_DIST = VERSION PROJECTS BUGS
# gettext never gets it right, so we take here care of deleting the
# symlink.
More information about the Gnupg-devel
mailing list