[svn] GnuPG - r4889 - in trunk: . agent doc g10 kbx scd sm tools

svn author wk cvs at cvs.gnupg.org
Tue Dec 9 09:58:03 CET 2008


Author: wk
Date: 2008-12-09 09:58:02 +0100 (Tue, 09 Dec 2008)
New Revision: 4889

Modified:
   trunk/NEWS
   trunk/agent/ChangeLog
   trunk/agent/command.c
   trunk/agent/gpg-agent.c
   trunk/agent/preset-passphrase.c
   trunk/agent/protect-tool.c
   trunk/doc/tools.texi
   trunk/g10/ChangeLog
   trunk/g10/cpr.c
   trunk/g10/gpg.c
   trunk/g10/gpgv.c
   trunk/g10/keylist.c
   trunk/kbx/ChangeLog
   trunk/kbx/kbxutil.c
   trunk/scd/ChangeLog
   trunk/scd/scdaemon.c
   trunk/sm/ChangeLog
   trunk/sm/gpgsm.c
   trunk/tools/ChangeLog
   trunk/tools/gpg-check-pattern.c
   trunk/tools/gpg-connect-agent.c
   trunk/tools/gpgconf.c
   trunk/tools/symcryptrun.c
Log:
Minor fixes.


Modified: trunk/agent/ChangeLog
===================================================================
--- trunk/agent/ChangeLog	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/agent/ChangeLog	2008-12-09 08:58:02 UTC (rev 4889)
@@ -1,3 +1,12 @@
+2008-12-09  Werner Koch  <wk at g10code.com>
+
+	* gpg-agent.c (main): Call i18n_init before init_common_subsystems.
+	* preset-passphrase.c (main): Ditto.
+	* protect-tool.c (main): Ditto.
+
+	* command.c (cmd_preset_passphrase): Allow an arbitrary string for
+	the cache id.
+
 2008-12-08  Werner Koch  <wk at g10code.com>
 
 	* gpg-agent.c (handle_connections): Sync the ticker to the next

Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/g10/ChangeLog	2008-12-09 08:58:02 UTC (rev 4889)
@@ -1,3 +1,15 @@
+2008-12-09  Werner Koch  <wk at g10code.com>
+
+	* gpg.c (open_info_file): Add arg BINARY and adjust callers.
+
+	* gpg.c (main): Call i18n_init before init_common_subsystems.
+	* gpgv.c (main): Ditto.
+
+	* keylist.c (set_attrib_fd): Do not close ATTRIB_FP if it is the
+	log stream. 
+	(set_attrib_fd) [W32]: Set to binary mode.
+	(dump_attribs): Flush the stream after writing.
+
 2008-12-05  Werner Koch  <wk at g10code.com>
 
 	* call-agent.c (percent_plus_escape): Rename to

Modified: trunk/kbx/ChangeLog
===================================================================
--- trunk/kbx/ChangeLog	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/kbx/ChangeLog	2008-12-09 08:58:02 UTC (rev 4889)
@@ -1,3 +1,7 @@
+2008-12-09  Werner Koch  <wk at g10code.com>
+
+	* kbxutil.c (main): Call i18n_init before init_common_subsystems.
+
 2008-11-20  Werner Koch  <wk at g10code.com>
 
 	* keybox-update.c (create_tmp_file) [USE_ONLY_8DOT3]: Use other

Modified: trunk/scd/ChangeLog
===================================================================
--- trunk/scd/ChangeLog	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/scd/ChangeLog	2008-12-09 08:58:02 UTC (rev 4889)
@@ -1,3 +1,7 @@
+2008-12-09  Werner Koch  <wk at g10code.com>
+
+	* scdaemon.c (main): Call i18n_init before init_common_subsystems.
+
 2008-12-08  Werner Koch  <wk at g10code.com>
 
 	* scdaemon.c (handle_connections): Sync ticker to the next full

Modified: trunk/sm/ChangeLog
===================================================================
--- trunk/sm/ChangeLog	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/sm/ChangeLog	2008-12-09 08:58:02 UTC (rev 4889)
@@ -1,3 +1,7 @@
+2008-12-09  Werner Koch  <wk at g10code.com>
+
+	* gpgsm.c (main): Call i18n_init before init_common_subsystems.
+
 2008-12-05  Werner Koch  <wk at g10code.com>
 
 	* certreqgen.c (create_request): Provide a custom prompt for the

Modified: trunk/tools/ChangeLog
===================================================================
--- trunk/tools/ChangeLog	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/tools/ChangeLog	2008-12-09 08:58:02 UTC (rev 4889)
@@ -1,3 +1,11 @@
+2008-12-09  Werner Koch  <wk at g10code.com>
+
+	* gpg-check-pattern.c (main): Call i18n_init before
+	init_common_subsystems.
+	* gpg-connect-agent.c (main): Ditto.
+	* gpgconf.c (main): Ditto.
+	* symcryptrun.c (main): Ditto.
+
 2008-12-08  Werner Koch  <wk at g10code.com>
 
 	* gpgkey2ssh.c (main): Change order of output for RSA. Change name

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/NEWS	2008-12-09 08:58:02 UTC (rev 4889)
@@ -41,7 +41,8 @@
  * [w32] Fixed a race condition bteween gpg and gpgsm in the use of
    temporary file names.
 
- * The gpg-preset-passphrase mechanism works again.
+ * The gpg-preset-passphrase mechanism works again.  An arbitrary
+   string may now be used for a custom cache ID.
 
  * Admin PINs are cached again (bug in 2.0.9).
 

Modified: trunk/agent/command.c
===================================================================
--- trunk/agent/command.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/agent/command.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -1093,7 +1093,7 @@
   return rc;
 }
 
-/* PRESET_PASSPHRASE <hexstring_with_keygrip> <timeout> <hexstring>
+/* PRESET_PASSPHRASE <string_or_keygrip> <timeout> <hexstring>
   
    Set the cached passphrase/PIN for the key identified by the keygrip
    to passwd for the given time, where -1 means infinite and 0 means
@@ -1104,7 +1104,6 @@
 cmd_preset_passphrase (assuan_context_t ctx, char *line)
 {
   int rc;
-  unsigned char grip[20];
   char *grip_clear = NULL;
   char *passphrase = NULL;
   int ttl;
@@ -1113,11 +1112,6 @@
   if (!opt.allow_preset_passphrase)
     return set_error (GPG_ERR_NOT_SUPPORTED, "no --allow-preset-passphrase");
 
-  rc = parse_keygrip (ctx, line, grip);
-  if (rc)
-    return rc;
-
-  /* FIXME: parse_keygrip should return a tail pointer.  */
   grip_clear = line;
   while (*line && (*line != ' ' && *line != '\t'))
     line++;

Modified: trunk/agent/gpg-agent.c
===================================================================
--- trunk/agent/gpg-agent.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/agent/gpg-agent.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -535,9 +535,9 @@
   log_set_prefix ("gpg-agent", JNLIB_LOG_WITH_PREFIX|JNLIB_LOG_WITH_PID); 
 
   /* Make sure that our subsystems are ready.  */
+  i18n_init ();
   init_common_subsystems ();
 
-  i18n_init ();
 
   /* Libgcrypt requires us to register the threading model first.
      Note that this will also do the pth_init. */

Modified: trunk/agent/preset-passphrase.c
===================================================================
--- trunk/agent/preset-passphrase.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/agent/preset-passphrase.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -209,10 +209,9 @@
   log_set_prefix ("gpg-preset-passphrase", 1); 
 
   /* Make sure that our subsystems are ready.  */
+  i18n_init ();
   init_common_subsystems ();
 
-  i18n_init ();
-
   opt_homedir = default_homedir ();
 
   pargs.argc = &argc;

Modified: trunk/agent/protect-tool.c
===================================================================
--- trunk/agent/protect-tool.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/agent/protect-tool.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -1059,10 +1059,9 @@
   log_set_prefix ("gpg-protect-tool", 1); 
 
   /* Make sure that our subsystems are ready.  */
+  i18n_init ();
   init_common_subsystems ();
 
-  i18n_init ();
-
   if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
     {
       log_fatal( _("%s is too old (need %s, have %s)\n"), "libgcrypt",

Modified: trunk/doc/tools.texi
===================================================================
--- trunk/doc/tools.texi	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/doc/tools.texi	2008-12-09 08:58:02 UTC (rev 4889)
@@ -979,7 +979,7 @@
 .B  gpg-preset-passphrase
 .RI [ options ]
 .RI [ command ]
-.I keygrip
+.I cache-id
 @end ifset
 
 @mansect description
@@ -1009,15 +1009,20 @@
 @command{gpg-preset-passphrase} is invoked this way:
 
 @example
-gpg-preset-passphrase [options] [command] @var{keygrip}
+gpg-preset-passphrase [options] [command] @var{cacheid}
 @end example
 
- at var{keygrip} is a 40 character string of hexadecimal characters
-identifying the key for which the passphrase should be set or cleared.
-This keygrip is listed along with the key when running the command:
- at code{gpgsm --dump-secret-keys}. One of the following command options
-must be given:
+ at var{cacheid} is either a 40 character keygrip of hexadecimal
+characters identifying the key for which the passphrase should be set
+or cleared.  The keygrip is listed along with the key when running the
+command: @code{gpgsm --dump-secret-keys}.  Alternatively an arbitrary
+string may be used to identify a passphrase; it is suggested that such
+a string is prefixed with the name of the application (e.g
+ at code{foo:12346}).
 
+ at noindent
+One of the following command options must be given:
+
 @table @gnupgtabopt
 @item --preset
 @opindex preset
@@ -1027,7 +1032,7 @@
 
 @item --forget
 @opindex forget
-Flush the passphrase for the given keygrip from the cache.
+Flush the passphrase for the given cache ID from the cache.
 
 @end table
 

Modified: trunk/g10/cpr.c
===================================================================
--- trunk/g10/cpr.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/g10/cpr.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -229,7 +229,7 @@
 
 
 /* Print the BEGIN_SIGNING status message.  If MD is not NULL it is
-   used retrieve the hash algorithms used for the message. */
+   used to retrieve the hash algorithms used for the message. */
 void
 write_status_begin_signing (gcry_md_hd_t md)
 {

Modified: trunk/g10/gpg.c
===================================================================
--- trunk/g10/gpg.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/g10/gpg.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -1036,9 +1036,9 @@
    used with --status-file etc functions.  Not generally useful but it
    avoids the riscos specific functions and well some Windows people
    might like it too.  Prints an error message and returns -1 on
-   error. On success the file descriptor is returned.  */
+   error.  On success the file descriptor is returned.  */
 static int
-open_info_file (const char *fname, int for_write)
+open_info_file (const char *fname, int for_write, int binary)
 {
 #ifdef __riscos__
   return riscos_fdopenfile (fname, for_write);
@@ -1048,10 +1048,16 @@
      similar to the option file but in that case it is unlikely that
      sensitive information may be retrieved by means of error
      messages.  */
+  (void)fname;
+  (void)for_write;
+  (void)binary;
   return -1;
 #else 
   int fd;
 
+  if (binary)
+    binary = MY_O_BINARY;
+
 /*   if (is_secured_filename (fname)) */
 /*     { */
 /*       fd = -1; */
@@ -1062,10 +1068,10 @@
       do
         {
           if (for_write)
-            fd = open (fname, O_CREAT | O_TRUNC | O_WRONLY,
+            fd = open (fname, O_CREAT | O_TRUNC | O_WRONLY | binary,
                         S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
           else
-            fd = open (fname, O_RDONLY | MY_O_BINARY);
+            fd = open (fname, O_RDONLY | binary);
         }
       while (fd == -1 && errno == EINTR);
 /*     } */
@@ -1910,6 +1916,7 @@
     log_set_prefix ("gpg", 1);
 
     /* Make sure that our subsystems are ready.  */
+    i18n_init();
     init_common_subsystems ();
 
     /* Check that the libraries are suitable.  Do it right here because the
@@ -1929,7 +1936,6 @@
 
     create_dotlock(NULL); /* Register locking cleanup. */
 
-    i18n_init();
 
     opt.command_fd = -1; /* no command fd */
     opt.compress_level = -1; /* defaults to standard compress level */
@@ -2216,16 +2222,16 @@
           case oDebugLevel: debug_level = pargs.r.ret_str; break;
 
 	  case oStatusFD:
-            set_status_fd( translate_sys2libc_fd_int (pargs.r.ret_int, 1) );
+            set_status_fd ( translate_sys2libc_fd_int (pargs.r.ret_int, 1) );
             break;
 	  case oStatusFile:
-            set_status_fd ( open_info_file (pargs.r.ret_str, 1) );
+            set_status_fd ( open_info_file (pargs.r.ret_str, 1, 0) );
             break;
 	  case oAttributeFD:
-            set_attrib_fd(translate_sys2libc_fd_int (pargs.r.ret_int, 1));
+            set_attrib_fd ( translate_sys2libc_fd_int (pargs.r.ret_int, 1) );
             break;
 	  case oAttributeFile:
-            set_attrib_fd ( open_info_file (pargs.r.ret_str, 1) );
+            set_attrib_fd ( open_info_file (pargs.r.ret_str, 1, 1) );
             break;
 	  case oLoggerFD:
             log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1));
@@ -2522,14 +2528,14 @@
             pwfd = translate_sys2libc_fd_int (pargs.r.ret_int, 0);
             break;
 	  case oPasswdFile:
-            pwfd = open_info_file (pargs.r.ret_str, 0);
+            pwfd = open_info_file (pargs.r.ret_str, 0, 1);
             break;
 	  case oPasswdRepeat: opt.passwd_repeat=pargs.r.ret_int; break;
 	  case oCommandFD:
             opt.command_fd = translate_sys2libc_fd_int (pargs.r.ret_int, 0);
             break;
 	  case oCommandFile:
-            opt.command_fd = open_info_file (pargs.r.ret_str, 0);
+            opt.command_fd = open_info_file (pargs.r.ret_str, 0, 1);
             break;
 	  case oCipherAlgo: 
             def_cipher_string = xstrdup(pargs.r.ret_str);

Modified: trunk/g10/gpgv.c
===================================================================
--- trunk/g10/gpgv.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/g10/gpgv.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -147,10 +147,10 @@
   log_set_prefix ("gpgv", 1);
   
   /* Make sure that our subsystems are ready.  */
+  i18n_init();
   init_common_subsystems ();
   
   gnupg_init_signals (0, NULL);
-  i18n_init();
 
   opt.command_fd = -1; /* no command fd */
   opt.pgp2_workarounds = 1;

Modified: trunk/g10/keylist.c
===================================================================
--- trunk/g10/keylist.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/g10/keylist.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -24,6 +24,9 @@
 #include <string.h>
 #include <errno.h>
 #include <assert.h>
+#ifdef HAVE_DOSISH_SYSTEM
+#include <fcntl.h> /* for setmode() */
+#endif
 
 #include "gpg.h"
 #include "options.h"
@@ -50,7 +53,8 @@
   int oth_err;
 };
 
-static FILE *attrib_fp=NULL;
+/* The stream used to write attribute packets to.  */
+static FILE *attrib_fp = NULL;
 
 /****************
  * List the keys
@@ -745,6 +749,7 @@
 	}
 
       fwrite(uid->attribs[i].data,uid->attribs[i].len,1,attrib_fp);
+      fflush (attrib_fp);
     }
 }
 
@@ -1609,29 +1614,35 @@
 
 
 
-void set_attrib_fd(int fd)
+void
+set_attrib_fd (int fd)
 {
   static int last_fd=-1;
 
   if ( fd != -1 && last_fd == fd )
     return;
 
-  if ( attrib_fp && attrib_fp != stdout && attrib_fp != stderr )
+  if ( attrib_fp && attrib_fp != stdout && attrib_fp != stderr 
+       && attrib_fp != log_get_stream () )
     fclose (attrib_fp);
   attrib_fp = NULL;
   if ( fd == -1 ) 
     return;
 
+#ifdef HAVE_DOSISH_SYSTEM
+  setmode ( fileno(fp) , O_BINARY );
+#endif
   if( fd == 1 )
     attrib_fp = stdout;
   else if( fd == 2 )
     attrib_fp = stderr;
   else
-    attrib_fp = fdopen( fd, "wb" );
-  if( !attrib_fp ) {
-    log_fatal("can't open fd %d for attribute output: %s\n",
-	      fd, strerror(errno));
-  }
-
+    attrib_fp = fdopen (fd, "wb");
+  if (!attrib_fp) 
+    {
+      log_fatal("can't open fd %d for attribute output: %s\n",
+                fd, strerror(errno));
+    }
+  
   last_fd = fd;
 }

Modified: trunk/kbx/kbxutil.c
===================================================================
--- trunk/kbx/kbxutil.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/kbx/kbxutil.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -419,10 +419,9 @@
   log_set_prefix ("kbxutil", 1); 
 
   /* Make sure that our subsystems are ready.  */
+  i18n_init ();
   init_common_subsystems ();
 
-  i18n_init ();
-
   /* Check that the libraries are suitable.  Do it here because
      the option parsing may need services of the library.  */
   if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )

Modified: trunk/scd/scdaemon.c
===================================================================
--- trunk/scd/scdaemon.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/scd/scdaemon.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -364,9 +364,9 @@
   log_set_prefix ("scdaemon", 1|4); 
 
   /* Make sure that our subsystems are ready.  */
+  i18n_init ();
   init_common_subsystems ();
 
-  i18n_init ();
 
   /* Libgcrypt requires us to register the threading model first.
      Note that this will also do the pth_init. */

Modified: trunk/sm/gpgsm.c
===================================================================
--- trunk/sm/gpgsm.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/sm/gpgsm.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -869,6 +869,7 @@
   log_set_prefix ("gpgsm", 1);
 
   /* Make sure that our subsystems are ready.  */
+  i18n_init();
   init_common_subsystems ();
 
   /* Check that the libraries are suitable.  Do it here because the
@@ -888,7 +889,6 @@
   gnupg_init_signals (0, emergency_cleanup);
   
   create_dotlock (NULL); /* register locking cleanup */
-  i18n_init();
 
   opt.def_cipher_algoid = "AES";  /*des-EDE3-CBC*/
 

Modified: trunk/tools/gpg-check-pattern.c
===================================================================
--- trunk/tools/gpg-check-pattern.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/tools/gpg-check-pattern.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -168,10 +168,9 @@
   log_set_prefix ("gpg-check-pattern", 1); 
 
   /* Make sure that our subsystems are ready.  */
+  i18n_init ();
   init_common_subsystems ();
 
-  i18n_init ();
-
   /* We need Libgcrypt for hashing.  */
   if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
     {

Modified: trunk/tools/gpg-connect-agent.c
===================================================================
--- trunk/tools/gpg-connect-agent.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/tools/gpg-connect-agent.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -1152,11 +1152,11 @@
   log_set_prefix ("gpg-connect-agent", 1);
 
   /* Make sure that our subsystems are ready.  */
+  i18n_init();
   init_common_subsystems ();
 
   assuan_set_assuan_err_source (0);
 
-  i18n_init();
 
   opt.homedir = default_homedir ();
   opt.connect_flags = 1; /* Use extended connect mode.  */

Modified: trunk/tools/gpgconf.c
===================================================================
--- trunk/tools/gpgconf.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/tools/gpgconf.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -147,10 +147,9 @@
   log_set_prefix ("gpgconf", 1);
 
   /* Make sure that our subsystems are ready.  */
+  i18n_init();
   init_common_subsystems ();
 
-  i18n_init();
-
   /* Parse the command line. */
   pargs.argc  = &argc;
   pargs.argv  = &argv;

Modified: trunk/tools/symcryptrun.c
===================================================================
--- trunk/tools/symcryptrun.c	2008-12-08 19:10:42 UTC (rev 4888)
+++ trunk/tools/symcryptrun.c	2008-12-09 08:58:02 UTC (rev 4889)
@@ -884,10 +884,9 @@
   log_set_prefix ("symcryptrun", 1);
 
   /* Make sure that our subsystems are ready.  */
+  i18n_init();
   init_common_subsystems ();
 
-  i18n_init();
-
   opt.homedir = default_homedir ();
 
   /* Check whether we have a config file given on the commandline */




More information about the Gnupg-commits mailing list