[svn] GnuPG - r4527 - in trunk: . agent jnlib scd

svn author wk cvs at cvs.gnupg.org
Wed Jul 4 11:34:59 CEST 2007


Author: wk
Date: 2007-07-04 11:34:28 +0200 (Wed, 04 Jul 2007)
New Revision: 4527

Modified:
   trunk/ChangeLog
   trunk/agent/ChangeLog
   trunk/agent/Makefile.am
   trunk/agent/agent.h
   trunk/agent/call-pinentry.c
   trunk/agent/command.c
   trunk/agent/gpg-agent.c
   trunk/configure.ac
   trunk/jnlib/ChangeLog
   trunk/jnlib/argparse.c
   trunk/scd/ChangeLog
   trunk/scd/command.c
   trunk/scd/scdaemon.c
Log:
A bunch of minor changes for Windows.

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-06-26 13:48:44 UTC (rev 4526)
+++ trunk/ChangeLog	2007-07-04 09:34:28 UTC (rev 4527)
@@ -1,3 +1,7 @@
+2007-07-03  Werner Koch  <wk at g10code.com>
+
+	* configure.ac [W32]: Use ws2_32 instead of wsock32.
+
 2007-06-25  Werner Koch  <wk at g10code.com>
 
 	* gl/mkdtemp.c (gen_tempname) [MKDIR_TAKES_ONE_ARG]: Avoid

Modified: trunk/agent/ChangeLog
===================================================================
--- trunk/agent/ChangeLog	2007-06-26 13:48:44 UTC (rev 4526)
+++ trunk/agent/ChangeLog	2007-07-04 09:34:28 UTC (rev 4527)
@@ -1,3 +1,25 @@
+2007-07-04  Werner Koch  <wk at g10code.com>
+
+	* gpg-agent.c (TIMERTICK_INTERVAL): New.
+
+2007-07-03  Werner Koch  <wk at g10code.com>
+
+	* gpg-agent.c (handle_connections): Do not use FD_SETSIZE for
+	select but compute the correct number.
+
+2007-07-02  Werner Koch  <wk at g10code.com>
+
+	* command.c (cmd_reloadagent) [W32]: New.
+	(register_commands) [W32]: New command RELOADAGENT.
+
+	* Makefile.am (gpg_agent_SOURCES): Remove w32main.c and w32main.h.
+	(gpg_agent_res_ldflags): Remove icon file as we don't have a
+	proper icon yet.
+	* gpg-agent.c (main): do not include w32main.h.  Remove all calls
+	to w32main.c.
+	(agent_sighup_action): New.
+	(handle_signal): Use it.
+
 2007-06-26  Werner Koch  <wk at g10code.com>
 
 	* gpg-agent.c (create_directories) [W32]: Made it work.

Modified: trunk/agent/Makefile.am
===================================================================
--- trunk/agent/Makefile.am	2007-06-26 13:48:44 UTC (rev 4526)
+++ trunk/agent/Makefile.am	2007-07-04 09:34:28 UTC (rev 4527)
@@ -23,7 +23,7 @@
 libexec_PROGRAMS = gpg-protect-tool gpg-preset-passphrase
 noinst_PROGRAMS = $(TESTS)
 
-EXTRA_DIST = gpg-agent.ico gpg-agent-resource.rc
+# EXTRA_DIST = gpg-agent.ico gpg-agent-resource.rc
 
 AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl
 
@@ -47,25 +47,21 @@
 	call-scd.c \
 	learncard.c
 
-if HAVE_W32_SYSTEM
-gpg_agent_SOURCES += w32main.c w32main.h
-endif
-
 common_libs = ../jnlib/libjnlib.a $(libcommon) ../gl/libgnu.a
 commonpth_libs = ../jnlib/libjnlib.a $(libcommonpth) ../gl/libgnu.a
 pwquery_libs = ../common/libsimple-pwquery.a
 
-if HAVE_W32_SYSTEM
-.rc.o:
-	$(WINDRES) `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \
-	 sed -e 's/-I/--include-dir /g;s/-D/--define /g'` -i $< -o $@
-
-gpg_agent_res_ldflags = -Wl,gpg-agent-resource.o -Wl,--subsystem,windows
-gpg_agent_res_deps = gpg-agent-resource.o
-else
+#if HAVE_W32_SYSTEM
+#.rc.o:
+#	$(WINDRES) `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \
+#	 sed -e 's/-I/--include-dir /g;s/-D/--define /g'` -i $< -o $@
+#
+#gpg_agent_res_ldflags = -Wl,gpg-agent-resource.o -Wl,--subsystem,windows
+#gpg_agent_res_deps = gpg-agent-resource.o
+#else
 gpg_agent_res_ldflags =
 gpg_agent_res_deps =
-endif
+#endif
 
 
 gpg_agent_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_PTH_CFLAGS) $(PTH_CFLAGS)

Modified: trunk/agent/agent.h
===================================================================
--- trunk/agent/agent.h	2007-06-26 13:48:44 UTC (rev 4526)
+++ trunk/agent/agent.h	2007-07-04 09:34:28 UTC (rev 4527)
@@ -190,6 +190,7 @@
 void agent_exit (int rc) JNLIB_GCC_A_NR; /* Also implemented in other tools */
 const char *get_agent_socket_name (void);
 const char *get_agent_ssh_socket_name (void);
+void agent_sighup_action (void);
 
 /*-- command.c --*/
 gpg_error_t agent_write_status (ctrl_t ctrl, const char *keyword, ...);

Modified: trunk/agent/call-pinentry.c
===================================================================
--- trunk/agent/call-pinentry.c	2007-06-26 13:48:44 UTC (rev 4526)
+++ trunk/agent/call-pinentry.c	2007-07-04 09:34:28 UTC (rev 4527)
@@ -225,7 +225,7 @@
     pgmname++;
 
   /* OS X needs the entire file name in argv[0], so that it can locate
-     the resource bundle.  For other systems we stick to the the usual
+     the resource bundle.  For other systems we stick to the usual
      convention of supplying only the name of the program.  */
 #ifdef __APPLE__
   argv[0] = opt.pinentry_program;

Modified: trunk/agent/command.c
===================================================================
--- trunk/agent/command.c	2007-06-26 13:48:44 UTC (rev 4526)
+++ trunk/agent/command.c	2007-07-04 09:34:28 UTC (rev 4527)
@@ -1323,6 +1323,17 @@
   ctrl->server_local->stopme = 1;
   return 0;
 }
+
+/* RELOADAGENT
+
+   As signals are inconvenient under Windows, we provide this command
+   to allow reloading of the configuration.  */
+static int
+cmd_reloadagent (assuan_context_t ctx, char *line)
+{
+  agent_sighup_action ();
+  return 0;
+}
 #endif /*HAVE_W32_SYSTEM*/
 
 
@@ -1506,6 +1517,7 @@
     { "UPDATESTARTUPTTY",  cmd_updatestartuptty },
 #ifdef HAVE_W32_SYSTEM
     { "KILLAGENT",      cmd_killagent },
+    { "RELOADAGENT",    cmd_reloadagent },
 #endif
     { "GETINFO",        cmd_getinfo },
     { NULL }

Modified: trunk/agent/gpg-agent.c
===================================================================
--- trunk/agent/gpg-agent.c	2007-06-26 13:48:44 UTC (rev 4526)
+++ trunk/agent/gpg-agent.c	2007-07-04 09:34:28 UTC (rev 4527)
@@ -48,7 +48,6 @@
 #include "sysutils.h"
 #ifdef HAVE_W32_SYSTEM
 # include "../jnlib/w32-afunix.h"
-# include "w32main.h"
 #endif
 #include "setenv.h"
 
@@ -171,6 +170,14 @@
 #define MAX_CACHE_TTL_SSH     (120*60) /* 2 hours */
 #define MIN_PASSPHRASE_LEN    (8)      
 
+/* The timer tick used for housekeeping stuff.  For Windows we use a
+   longer period as the SetWaitableTimer seems to signal earlier than
+   the 2 seconds.  */
+#ifdef HAVE_W32_SYSTEM
+#define TIMERTICK_INTERVAL    (4)
+#else
+#define TIMERTICK_INTERVAL    (2)    /* Seconds.  */
+#endif
 
 /* flag to indicate that a shutdown was requested */
 static int shutdown_pending;
@@ -408,16 +415,9 @@
 }
 
 
-/* The main entry point.  For W32 another name is used as the real
-   entry points needs to be named WinMain and is defined in
-   w32main.c. */
-#ifdef HAVE_W32_SYSTEM
+/* The main entry point.  */
 int
-w32_main (int argc, char **argv )
-#else
-int
 main (int argc, char **argv )
-#endif
 {
   ARGPARSE_ARGS pargs;
   int orig_argc;
@@ -851,7 +851,6 @@
 #ifdef HAVE_W32_SYSTEM
       pid = getpid ();
       printf ("set GPG_AGENT_INFO=%s;%lu;1\n", socket_name, (ulong)pid);
-      w32_setup_taskbar ();
 #else /*!HAVE_W32_SYSTEM*/
       pid = fork ();
       if (pid == (pid_t)-1) 
@@ -1430,6 +1429,17 @@
 }
 
 
+/* A global fucntion which allows us to call the reload stuff from
+   other palces too.  This is only used when build for W32.  */
+void
+agent_sighup_action (void)
+{
+  agent_flush_cache ();
+  reread_configuration ();
+  agent_reload_trustlist ();
+}
+
+
 static void
 handle_signal (int signo)
 {
@@ -1439,9 +1449,7 @@
     case SIGHUP:
       log_info ("SIGHUP received - "
                 "re-reading configuration and flushing cache\n");
-      agent_flush_cache ();
-      reread_configuration ();
-      agent_reload_trustlist ();
+      agent_sighup_action ();
       break;
       
     case SIGUSR1:
@@ -1545,6 +1553,7 @@
   fd_set fdset, read_fdset;
   int ret;
   int fd;
+  int nfd;
 
   tattr = pth_attr_new();
   pth_attr_set (tattr, PTH_ATTR_JOINABLE, 0);
@@ -1562,24 +1571,25 @@
   pth_sigmask (SIG_UNBLOCK, &sigs, NULL);
   ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
 #else
-  ev = NULL;
-  signo = 0;
+  sigs = 0;
+  ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
 #endif
   time_ev = NULL;
 
   FD_ZERO (&fdset);
   FD_SET (listen_fd, &fdset);
+  nfd = listen_fd;
   if (listen_fd_ssh != -1)
-    FD_SET (listen_fd_ssh, &fdset);
+    {
+      FD_SET (listen_fd_ssh, &fdset);
+      if (listen_fd_ssh > nfd)
+        nfd = listen_fd_ssh;
+    }
 
   for (;;)
     {
       sigset_t oldsigs;
 
-#ifdef HAVE_W32_SYSTEM
-      w32_poll_events ();
-#endif
-
       if (shutdown_pending)
         {
           if (pth_ctrl (PTH_CTRL_GETTHREADS) == 1)
@@ -1596,7 +1606,8 @@
 
       /* Create a timeout event if needed. */
       if (!time_ev)
-        time_ev = pth_event (PTH_EVENT_TIME, pth_timeout (2, 0));
+        time_ev = pth_event (PTH_EVENT_TIME, 
+                             pth_timeout (TIMERTICK_INTERVAL, 0));
 
       /* POSIX says that fd_set should be implemented as a structure,
          thus a simple assignment is fine to copy the entire set.  */
@@ -1604,7 +1615,7 @@
 
       if (time_ev)
         pth_event_concat (ev, time_ev, NULL);
-      ret = pth_select_ev (FD_SETSIZE, &read_fdset, NULL, NULL, NULL, ev);
+      ret = pth_select_ev (nfd+1, &read_fdset, NULL, NULL, NULL, ev);
       if (time_ev)
         pth_event_isolate (time_ev);
 
@@ -1643,8 +1654,8 @@
 
       
       /* We now might create new threads and because we don't want any
-         signals - we are handling here - to be delivered to a new
-         thread. Thus we need to block those signals. */
+         signals (as we are handling them here) to be delivered to a
+         new thread.  Thus we need to block those signals. */
       pth_sigmask (SIG_BLOCK, &sigs, &oldsigs);
 
       if (FD_ISSET (listen_fd, &read_fdset))

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2007-06-26 13:48:44 UTC (rev 4526)
+++ trunk/configure.ac	2007-07-04 09:34:28 UTC (rev 4527)
@@ -1160,7 +1160,7 @@
 # requiring any network stuff but linking to code in libcommon which
 # tracks in winsock stuff (e.g. init_common_subsystems.
 if test "$have_w32_system" = yes; then
-   W32SOCKLIBS="-lwsock32"
+   W32SOCKLIBS="-lws2_32"
    NETLIBS="${NETLIBS} ${W32SOCKLIBS}"
 fi
 

Modified: trunk/jnlib/ChangeLog
===================================================================
--- trunk/jnlib/ChangeLog	2007-06-26 13:48:44 UTC (rev 4526)
+++ trunk/jnlib/ChangeLog	2007-07-04 09:34:28 UTC (rev 4527)
@@ -1,3 +1,9 @@
+2007-07-01  Werner Koch  <wk at g10code.com>
+
+	* argparse.c (strusage): Use id 10 for the license string;
+	default to GPL3+.  Change long note to version 3 or later.
+	(show_version): Print the license info.
+
 2007-06-19  Werner Koch  <wk at g10code.com>
 
 	* Makefile.am: Add support for regression tests.

Modified: trunk/jnlib/argparse.c
===================================================================
--- trunk/jnlib/argparse.c	2007-06-26 13:48:44 UTC (rev 4526)
+++ trunk/jnlib/argparse.c	2007-07-04 09:34:28 UTC (rev 4527)
@@ -844,64 +844,71 @@
 static void
 show_version()
 {
-    const char *s;
-    int i;
-    /* version line */
-    fputs(strusage(11), stdout);
-    if( (s=strusage(12)) )
-	printf(" (%s)", s );
-    printf(" %s\n", strusage(13) );
-    /* additional version lines */
-    for(i=20; i < 30; i++ )
-	if( (s=strusage(i)) )
-	    printf("%s\n", s );
-    /* copyright string */
-    if( (s=strusage(14)) )
-	printf("%s\n", s );
-    /* copying conditions */
-    if( (s=strusage(15)) )
-	fputs(s, stdout);
-    /* thanks */
-    if( (s=strusage(18)) )
-	fputs(s, stdout);
-    /* additional program info */
-    for(i=30; i < 40; i++ )
-	if( (s=strusage(i)) )
-	    fputs (s, stdout);
-    fflush(stdout);
+  const char *s;
+  int i;
+
+  /* Version line.  */
+  fputs (strusage (11), stdout);
+  if ((s=strusage (12)))
+    printf (" (%s)", s );
+  printf (" %s\n", strusage (13) );
+  /* Additional version lines. */
+  for (i=20; i < 30; i++)
+    if ((s=strusage (i)))
+      printf ("%s\n", s );
+  /* Copyright string.  */
+  if( (s=strusage (14)) )
+    printf("%s\n", s );
+  /* Licence string.  */
+  if( (s=strusage (10)) )
+    printf("%s\n", s );
+  /* Copying conditions. */
+  if ( (s=strusage(15)) )
+    fputs (s, stdout);
+  /* Thanks. */
+  if ((s=strusage(18)))
+    fputs (s, stdout);
+  /* Additional program info. */
+  for (i=30; i < 40; i++ )
+    if ( (s=strusage (i)) )
+      fputs (s, stdout);
+  fflush(stdout);
 }
 
 
 void
-usage( int level )
+usage (int level)
 {
-    if( !level ) {
-	fprintf(stderr,"%s %s; %s\n", strusage(11), strusage(13),
-						     strusage(14) );
-	fflush(stderr);
+  if (!level)
+    {
+      fprintf(stderr,"%s %s; %s\n", strusage(11), strusage(13), strusage (14));
+      fflush (stderr);
     }
-    else if( level == 1 ) {
-	fputs(strusage(40),stderr);
-	exit(2);
+  else if (level == 1)
+    {
+      fputs (strusage (40), stderr);
+      exit (2);
     }
-    else if( level == 2 ) {
-	puts(strusage(41));
-	exit(0);
+  else if (level == 2) 
+    {
+      puts (strusage(41));
+      exit (0);
     }
 }
 
 /* Level
- *     0: Copyright String auf stderr ausgeben
- *     1: Kurzusage auf stderr ausgeben und beenden
- *     2: Langusage auf stdout ausgeben und beenden
- *    11: name of program
- *    12: optional name of package which includes this program.
+ *     0: Print copyright string to stderr
+ *     1: Print a short usage hint to stderr and terminate
+ *     2: Print a long usage hint to stdout and terminate
+ *    10: Return license info string
+ *    11: Return the name of the program
+ *    12: Return optional name of package which includes this program.
  *    13: version  string
  *    14: copyright string
  *    15: Short copying conditions (with LFs)
  *    16: Long copying conditions (with LFs)
  *    17: Optional printable OS name
- *    18: Optional thanks list	 (with LFs)
+ *    18: Optional thanks list (with LFs)
  *    19: Bug report info
  *20..29: Additional lib version strings.
  *30..39: Additional program info (with LFs)
@@ -917,26 +924,27 @@
 	return p;
 
     switch( level ) {
+      case 10: p = ("License GPLv2+: GNU GPL version 2 or later "
+                    "<http://gnu.org/licenses/old-licenses/gpl-2.0.html>");
+        break;
       case 11: p = "foo"; break;
       case 13: p = "0.0"; break;
       case 14: p = "Copyright (C) 2007 Free Software Foundation, Inc."; break;
       case 15: p =
-"This program comes with ABSOLUTELY NO WARRANTY.\n"
-"This is free software, and you are welcome to redistribute it\n"
-"under certain conditions. See the file COPYING for details.\n"; break;
+"This is free software: you are free to change and redistribute it.\n"
+"There is NO WARRANTY, to the extent permitted by law.\n";
+        break;
       case 16:	p =
 "This is free software; you can redistribute it and/or modify\n"
 "it under the terms of the GNU General Public License as published by\n"
-"the Free Software Foundation; either version 2 of the License, or\n"
+"the Free Software Foundation; either version 3 of the License, or\n"
 "(at your option) any later version.\n\n"
 "It is distributed in the hope that it will be useful,\n"
 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
 "GNU General Public License for more details.\n\n"
 "You should have received a copy of the GNU General Public License\n"
-"along with this program; if not, write to the Free Software\n"
-"Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,\n"
-"USA.\n";
+"along with this software.  If not, see  <http://www.gnu.org/licenses/>.\n";
 	break;
       case 40: /* short and long usage */
       case 41: p = ""; break;

Modified: trunk/scd/ChangeLog
===================================================================
--- trunk/scd/ChangeLog	2007-06-26 13:48:44 UTC (rev 4526)
+++ trunk/scd/ChangeLog	2007-07-04 09:34:28 UTC (rev 4527)
@@ -1,3 +1,12 @@
+2007-07-04  Werner Koch  <wk at g10code.com>
+
+	* command.c (cmd_getinfo): New subcommand "version".
+
+	* scdaemon.c (TIMERTICK_INTERVAL): New.
+	(handle_connections) [W32]: Enable a dummy sigs event.
+	(handle_connections): Use a proper count for select and not
+	FD_SETSIZE.
+
 2007-06-21  Werner Koch  <wk at g10code.com>
 
 	* scdaemon.h (ctrl_t): Remove.  It is now declared in ../common/util.h.

Modified: trunk/scd/command.c
===================================================================
--- trunk/scd/command.c	2007-06-26 13:48:44 UTC (rev 4526)
+++ trunk/scd/command.c	2007-07-04 09:34:28 UTC (rev 4527)
@@ -1402,6 +1402,8 @@
    Multi purpose command to return certain information.  
    Supported values of WHAT are:
 
+   version     - Return the version of the program.
+
    socket_name - Return the name of the socket.
 
    status - Return the status of the current slot (in the future, may
@@ -1420,8 +1422,13 @@
 {
   int rc = 0;
 
-  if (!strcmp (line, "socket_name"))
+  if (!strcmp (line, "version"))
     {
+      const char *s = VERSION;
+      rc = assuan_send_data (ctx, s, strlen (s));
+    }
+  else if (!strcmp (line, "socket_name"))
+    {
       const char *s = scd_get_socket_name ();
 
       if (s)

Modified: trunk/scd/scdaemon.c
===================================================================
--- trunk/scd/scdaemon.c	2007-06-26 13:48:44 UTC (rev 4526)
+++ trunk/scd/scdaemon.c	2007-07-04 09:34:28 UTC (rev 4527)
@@ -150,7 +150,16 @@
 #define DEFAULT_PCSC_DRIVER "libpcsclite.so"
 #endif
 
+/* The timer tick used for housekeeping stuff.  For Windows we use a
+   longer period as the SetWaitableTimer seems to signal earlier than
+   the 2 seconds.  */
+#ifdef HAVE_W32_SYSTEM
+#define TIMERTICK_INTERVAL    (4)
+#else
+#define TIMERTICK_INTERVAL    (2)    /* Seconds.  */
+#endif
 
+
 /* Flag to indicate that a shutdown was requested. */
 static int shutdown_pending;
 
@@ -280,7 +289,7 @@
   FILE *configfp = NULL;
   char *configname = NULL;
   const char *shell;
-  unsigned configlineno;
+  unsigned int configlineno;
   int parse_debug = 0;
   const char *debug_level = NULL;
   int default_config =1;
@@ -1040,6 +1049,7 @@
   fd_set fdset, read_fdset;
   int ret;
   int fd;
+  int nfd;
 
   tattr = pth_attr_new();
   pth_attr_set (tattr, PTH_ATTR_JOINABLE, 0);
@@ -1055,13 +1065,18 @@
   pth_sigmask (SIG_UNBLOCK, &sigs, NULL);
   ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
 #else
-  ev = NULL;
+  sigs = 0;
+  ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
 #endif
   time_ev = NULL;
 
   FD_ZERO (&fdset);
+  nfd = 0;
   if (listen_fd != -1)
-    FD_SET (listen_fd, &fdset);
+    {
+      FD_SET (listen_fd, &fdset);
+      nfd = listen_fd;
+    }
 
   for (;;)
     {
@@ -1081,7 +1096,8 @@
 
       /* Create a timeout event if needed. */
       if (!time_ev)
-        time_ev = pth_event (PTH_EVENT_TIME, pth_timeout (2, 0));
+        time_ev = pth_event (PTH_EVENT_TIME,
+                             pth_timeout (TIMERTICK_INTERVAL, 0));
 
       /* POSIX says that fd_set should be implemented as a structure,
          thus a simple assignment is fine to copy the entire set.  */
@@ -1089,7 +1105,7 @@
 
       if (time_ev)
         pth_event_concat (ev, time_ev, NULL);
-      ret = pth_select_ev (FD_SETSIZE, &read_fdset, NULL, NULL, NULL, ev);
+      ret = pth_select_ev (nfd+1, &read_fdset, NULL, NULL, NULL, ev);
       if (time_ev)
         pth_event_isolate (time_ev);
 




More information about the Gnupg-commits mailing list