[svn] GnuPG - r5335 - in trunk: agent doc tests/openpgp

svn author wk cvs at cvs.gnupg.org
Tue May 11 20:00:31 CEST 2010


Author: wk
Date: 2010-05-11 20:00:31 +0200 (Tue, 11 May 2010)
New Revision: 5335

Added:
   trunk/tests/openpgp/gpg-agent.conf.tmpl
Modified:
   trunk/agent/ChangeLog
   trunk/agent/agent.h
   trunk/agent/command.c
   trunk/agent/gpg-agent.c
   trunk/doc/gpg-agent.texi
   trunk/tests/openpgp/ChangeLog
   trunk/tests/openpgp/Makefile.am
   trunk/tests/openpgp/defs.inc
   trunk/tests/openpgp/genkey1024.test
Log:
Update tests.


Modified: trunk/agent/ChangeLog
===================================================================
--- trunk/agent/ChangeLog	2010-05-11 18:00:12 UTC (rev 5334)
+++ trunk/agent/ChangeLog	2010-05-11 18:00:31 UTC (rev 5335)
@@ -1,3 +1,12 @@
+2010-05-11  Werner Koch  <wk at g10code.com>
+
+	* agent.h (opt): Add field USE_STANDARD_SOCKET.
+	* gpg-agent.c (use_standard_socket): Remove.  Use new option instead.
+
+	* command.c (cmd_killagent, cmd_reloadagent): Provide command also
+	for non-W32 platforms.
+	(cmd_getinfo): New subcommands std_session_env and std_startup_env.
+
 2010-05-03  Werner Koch  <wk at g10code.com>
 
 	* gpg-agent.c (check_own_socket_thread): Do not release SOCKNAME

Modified: trunk/tests/openpgp/ChangeLog
===================================================================
--- trunk/tests/openpgp/ChangeLog	2010-05-11 18:00:12 UTC (rev 5334)
+++ trunk/tests/openpgp/ChangeLog	2010-05-11 18:00:31 UTC (rev 5335)
@@ -1,3 +1,13 @@
+2010-05-11  Werner Koch  <wk at g10code.com>
+
+	* genkey1024.test: Use GPG macro.
+
+	* gpg-agent.conf.tmpl: New.
+	* defs.inc: Create gpg-agent.conf
+	(GNUPGHOME): Set and export.
+	(GPG_AGENT_INFO): Unset.
+	* Makefile.am (CLEANFILES): Add S.gpg-agent
+
 2010-05-07  Werner Koch  <wk at g10code.com>
 
 	* import.test: Add test case for bug#1223.
@@ -48,7 +58,7 @@
 	we support.  This is safer than the previous setup which could
 	hide that some ciphers weren't being tested.  Plus, this
 	automatically tests any new ciphers libgcrypt supports.
-	(all_hash_algos): New. 
+	(all_hash_algos): New.
 	* sigs.test: Use it here, and also test with >=160 bit hashes for
 	DSA2.
 	* conventional.test, encrypt.test, encrypt-dsa.test,

Modified: trunk/agent/agent.h
===================================================================
--- trunk/agent/agent.h	2010-05-11 18:00:12 UTC (rev 5334)
+++ trunk/agent/agent.h	2010-05-11 18:00:31 UTC (rev 5335)
@@ -55,6 +55,9 @@
   int batch;           /* Batch mode */
   const char *homedir; /* Configuration directory name */
 
+  /* True if we are listening on the standard socket.  */
+  int use_standard_socket;
+
   /* Environment setting gathered at program start or changed using the
      Assuan command UPDATESTARTUPTTY. */
   session_env_t startup_env;

Modified: trunk/agent/command.c
===================================================================
--- trunk/agent/command.c	2010-05-11 18:00:12 UTC (rev 5334)
+++ trunk/agent/command.c	2010-05-11 18:00:31 UTC (rev 5335)
@@ -59,10 +59,8 @@
   char *keydesc;  /* Allocated description for the next key
                      operation. */
   int pause_io_logging; /* Used to suppress I/O logging during a command */
-#ifdef HAVE_W32_SYSTEM
   int stopme;    /* If set to true the agent will be terminated after
                     the end of this session.  */
-#endif
   int allow_pinentry_notify; /* Set if pinentry notifications should
                                 be done. */
 };
@@ -1591,18 +1589,20 @@
 
 
 
-#ifdef HAVE_W32_SYSTEM
 static const char hlp_killagent[] =
   "KILLAGENT\n"
   "\n"
-  "Under Windows we start the agent on the fly.  Thus it also make\n"
-  "sense to allow a client to stop the agent.";
+  "If the agent has been started using a standard socket\n"
+  "we allow a client to stop the agent.";
 static gpg_error_t
 cmd_killagent (assuan_context_t ctx, char *line)
 {
   ctrl_t ctrl = assuan_get_pointer (ctx);
 
   (void)line;
+  
+  if (!opt.use_standard_socket)
+    return set_error (GPG_ERR_NOT_SUPPORTED, "no --use-standard-socket");
 
   ctrl->server_local->stopme = 1;
   return gpg_error (GPG_ERR_EOF);
@@ -1612,8 +1612,8 @@
 static const char hlp_reloadagent[] =
   "RELOADAGENT\n"
   "\n"
-  "As signals are inconvenient under Windows, we provide this command\n"
-  "to allow reloading of the configuration.";
+  "This command is an alternative to SIGHUP\n"
+  "to reload the configuration.";
 static gpg_error_t
 cmd_reloadagent (assuan_context_t ctx, char *line)
 {
@@ -1623,7 +1623,6 @@
   agent_sighup_action ();
   return 0;
 }
-#endif /*HAVE_W32_SYSTEM*/
 
 
 
@@ -1639,11 +1638,14 @@
   "  ssh_socket_name - Return the name of the ssh socket.\n"
   "  scd_running - Return OK if the SCdaemon is already running.\n"
   "  s2k_count   - Return the calibrated S2K count.\n"
+  "  std_session_env - List the standard session environment.\n"
+  "  std_startup_env - List the standard startup environment.\n"
   "  cmd_has_option\n"
   "              - Returns OK if the command CMD implements the option OPT.";
 static gpg_error_t
 cmd_getinfo (assuan_context_t ctx, char *line)
 {
+  ctrl_t ctrl = assuan_get_pointer (ctx);
   int rc = 0;
 
   if (!strcmp (line, "version"))
@@ -1687,6 +1689,34 @@
       snprintf (numbuf, sizeof numbuf, "%lu", get_standard_s2k_count ());
       rc = assuan_send_data (ctx, numbuf, strlen (numbuf));
     }
+  else if (!strcmp (line, "std_session_env")
+           || !strcmp (line, "std_startup_env"))
+    {
+      int iterator;
+      const char *name, *value;
+      char *string;
+      
+      iterator = 0; 
+      while ((name = session_env_list_stdenvnames (&iterator, NULL)))
+        {
+          value = session_env_getenv_or_default
+            (line[5] == 't'? opt.startup_env:ctrl->session_env, name, NULL);
+          if (value)
+            {
+              string = xtryasprintf ("%s=%s", name, value); 
+              if (!string)
+                rc = gpg_error_from_syserror ();
+              else
+                {
+                  rc = assuan_send_data (ctx, string, strlen (string)+1);
+                  if (!rc)
+                    rc = assuan_send_data (ctx, NULL, 0);
+                }
+              if (rc)
+                break;
+            }
+        }
+    }
   else if (!strncmp (line, "cmd_has_option", 14)
            && (line[14] == ' ' || line[14] == '\t' || !line[14]))
     {
@@ -1883,10 +1913,8 @@
     { "GETVAL",         cmd_getval,    hlp_getval },
     { "PUTVAL",         cmd_putval,    hlp_putval },
     { "UPDATESTARTUPTTY",  cmd_updatestartuptty, hlp_updatestartuptty },
-#ifdef HAVE_W32_SYSTEM
     { "KILLAGENT",      cmd_killagent,  hlp_killagent },
     { "RELOADAGENT",    cmd_reloadagent,hlp_reloadagent },
-#endif
     { "GETINFO",        cmd_getinfo,   hlp_getinfo },
     { NULL }
   };
@@ -1993,10 +2021,8 @@
 
   /* Cleanup.  */
   assuan_release (ctx);
-#ifdef HAVE_W32_SYSTEM
   if (ctrl->server_local->stopme)
     agent_exit (0);
-#endif
   xfree (ctrl->server_local);
   ctrl->server_local = NULL;
 }

Modified: trunk/agent/gpg-agent.c
===================================================================
--- trunk/agent/gpg-agent.c	2010-05-11 18:00:12 UTC (rev 5334)
+++ trunk/agent/gpg-agent.c	2010-05-11 18:00:31 UTC (rev 5335)
@@ -219,9 +219,6 @@
 /* Counter for the currently running own socket checks.  */
 static int check_own_socket_running;
 
-/* True if we are listening on the standard socket.  */
-static int use_standard_socket;
-
 /* It is possible that we are currently running under setuid permissions */
 static int maybe_setuid = 1;
 
@@ -631,7 +628,7 @@
   /* Set default options.  */
   parse_rereadable_options (NULL, 0); /* Reset them to default values. */
 #ifdef USE_STANDARD_SOCKET
-  use_standard_socket = 1;
+  opt.use_standard_socket = 1;
 #endif
   
   shell = getenv ("SHELL");
@@ -782,8 +779,8 @@
         case oXauthority: default_xauthority = xstrdup (pargs.r.ret_str);
           break;
 
-        case oUseStandardSocket: use_standard_socket = 1; break;
-        case oNoUseStandardSocket: use_standard_socket = 0; break;
+        case oUseStandardSocket:   opt.use_standard_socket = 1; break;
+        case oNoUseStandardSocket: opt.use_standard_socket = 0; break;
 
         case oFakedSystemTime:
           {
@@ -862,9 +859,9 @@
   
   if (gpgconf_list == 3)
     {
-      if (use_standard_socket && !opt.quiet)
+      if (opt.use_standard_socket && !opt.quiet)
         log_info ("configured to use the standard socket\n");
-      agent_exit (!use_standard_socket);
+      agent_exit (!opt.use_standard_socket);
     }
   else if (gpgconf_list == 2)
     agent_exit (0);
@@ -1438,7 +1435,7 @@
 {
   char *name, *p;
 
-  if (use_standard_socket)
+  if (opt.use_standard_socket)
     name = make_filename (opt.homedir, standard_name, NULL);
   else
     {
@@ -1504,7 +1501,7 @@
 
   /* Our error code mapping on W32CE returns EEXIST thus we also test
      for this. */
-  if (use_standard_socket && rc == -1 
+  if (opt.use_standard_socket && rc == -1 
       && (errno == EADDRINUSE
 #ifdef HAVE_W32_SYSTEM
           || errno == EEXIST
@@ -1542,7 +1539,7 @@
                  gpg_strerror (gpg_error_from_errno (errno)));
       
       assuan_sock_close (fd);
-      if (use_standard_socket)
+      if (opt.use_standard_socket)
         *name = 0; /* Inhibit removal of the socket by cleanup(). */
       agent_exit (2);
     }
@@ -2169,7 +2166,7 @@
   char *sockname;
   pth_attr_t tattr;
 
-  if (!use_standard_socket)
+  if (!opt.use_standard_socket)
     return; /* This check makes only sense in standard socket mode.  */
 
   if (check_own_socket_running || shutdown_pending)

Modified: trunk/doc/gpg-agent.texi
===================================================================
--- trunk/doc/gpg-agent.texi	2010-05-11 18:00:12 UTC (rev 5334)
+++ trunk/doc/gpg-agent.texi	2010-05-11 18:00:31 UTC (rev 5335)
@@ -433,13 +433,14 @@
 a random socket below a temporary directory.  Tools connecting to
 @command{gpg-agent} should first try to connect to the socket given in
 environment variable @var{GPG_AGENT_INFO} and then fall back to this
-socket.  This option may not be used if the home directory is mounted as
-a remote file system.  Note, that @option{--use-standard-socket} is the
-default on Windows systems.  The default may be changed at build time.
-It is possible to test at runtime whether the agent has been configured
-for use with the standard socket by issuing the command
- at command{gpg-agent --use-standard-socket-p} which returns success if the
-standard socket option has been enabled.
+socket.  This option may not be used if the home directory is mounted on
+a remote file system which does not support special files like fifos or
+sockets.  Note, that @option{--use-standard-socket} is the default on
+Windows systems.  The default may be changed at build time.  It is
+possible to test at runtime whether the agent has been configured for
+use with the standard socket by issuing the command @command{gpg-agent
+--use-standard-socket-p} which returns success if the standard socket
+option has been enabled.
 
 @item --display @var{string}
 @itemx --ttyname @var{string}

Modified: trunk/tests/openpgp/Makefile.am
===================================================================
--- trunk/tests/openpgp/Makefile.am	2010-05-11 18:00:12 UTC (rev 5334)
+++ trunk/tests/openpgp/Makefile.am	2010-05-11 18:00:31 UTC (rev 5335)
@@ -40,16 +40,20 @@
 TEST_FILES = pubring.asc secring.asc plain-1o.asc plain-2o.asc plain-3o.asc \
 	     plain-1.asc plain-2.asc plain-3.asc plain-1-pgp.asc \
 	     pubring.pkr.asc secring.skr.asc secdemo.asc pubdemo.asc \
-             gpg.conf.tmpl bug537-test.data.asc bug894-test.asc \
+             gpg.conf.tmpl gpg-agent.conf.tmpl \
+	     bug537-test.data.asc bug894-test.asc \
 	     bug1223-good.asc bug1223-bogus.asc
 
 DATA_FILES = data-500 data-9000 data-32000 data-80000 plain-large
 
 EXTRA_DIST = defs.inc $(TESTS) $(TEST_FILES) \
 	     mkdemodirs signdemokey
+
+# Note that removing S.gpg-agent forces a running gpg-agent to
+# terminate after some time.
 CLEANFILES = prepared.stamp x y yy z out err  $(DATA_FILES) \
 	     plain-1 plain-2 plain-3 trustdb.gpg *.lock .\#lk* \
-	     *.test.log gpg_dearmor gpg.conf \
+	     *.test.log gpg_dearmor gpg.conf gpg-agent.conf S.gpg-agent \
 	     pubring.gpg secring.gpg pubring.pkr secring.skr
 
 DISTCLEANFILES = pubring.gpg~ random_seed

Modified: trunk/tests/openpgp/defs.inc
===================================================================
--- trunk/tests/openpgp/defs.inc	2010-05-11 18:00:12 UTC (rev 5334)
+++ trunk/tests/openpgp/defs.inc	2010-05-11 18:00:31 UTC (rev 5335)
@@ -162,14 +162,26 @@
 [ -z "$srcdir" ] && fatal "not called from make"
 
 # Make sure we have a valid option files even with VPATH builds.
-if [ -f ./gpg.conf ]; then
-  :
-elif [ -f $srcdir/gpg.conf.tmpl ]; then
-  cat $srcdir/gpg.conf.tmpl >gpg.conf
-fi
+for f in gpg.conf gpg-agent.conf; do 
+  if [ -f ./$f ]; then
+    :
+  elif [ -f $srcdir/$f.tmpl ]; then
+    cat $srcdir/$f.tmpl >$f
+  fi
+done
 
-GPG="../../g10/gpg2 --no-permission-warning --homedir . "
+# Always work in the current directory
+GNUPGHOME=`pwd`
+export GNUPGHOME
 
+# We do not use an external info variable for gpg-agent because we use
+# a standard socket in the home directory.  This way gpg-agent will be
+# started as soon as needed.  It is terminated indirectly using a
+# Makefile rule.
+GPG_AGENT_INFO=
+
+GPG="../../g10/gpg2 --no-permission-warning "
+
 exec 5>&2 2>${pgmname}.log
 
 :

Modified: trunk/tests/openpgp/genkey1024.test
===================================================================
--- trunk/tests/openpgp/genkey1024.test	2010-05-11 18:00:12 UTC (rev 5334)
+++ trunk/tests/openpgp/genkey1024.test	2010-05-11 18:00:31 UTC (rev 5335)
@@ -10,7 +10,7 @@
 
 . $srcdir/defs.inc || exit 3
 
-../../g10/gpg2 --quiet --batch --debug-quick-random --homedir . --gen-key <<EOF
+$GPG --quiet --batch --debug-quick-random  --gen-key <<EOF
 Key-Type: DSA
 Key-Length: 1024
 Subkey-Type: ELG
@@ -24,7 +24,7 @@
 EOF
 
 if have_pubkey_algo "RSA"; then
-../../g10/gpg2 --quiet --batch --debug-quick-random --homedir . --gen-key <<EOF
+$GPG --quiet --batch --debug-quick-random --gen-key <<EOF
 Key-Type: RSA
 Key-Length: 1024
 Key-Usage: sign,encrypt

Added: trunk/tests/openpgp/gpg-agent.conf.tmpl
===================================================================
--- trunk/tests/openpgp/gpg-agent.conf.tmpl	                        (rev 0)
+++ trunk/tests/openpgp/gpg-agent.conf.tmpl	2010-05-11 18:00:31 UTC (rev 5335)
@@ -0,0 +1,2 @@
+use-standard-socket
+




More information about the Gnupg-commits mailing list