[svn] GnuPG - r4356 - trunk/g10

svn author dshaw cvs at cvs.gnupg.org
Sun Dec 3 05:42:00 CET 2006


Author: dshaw
Date: 2006-12-03 05:41:59 +0100 (Sun, 03 Dec 2006)
New Revision: 4356

Modified:
   trunk/g10/ChangeLog
   trunk/g10/gpg.c
   trunk/g10/options.h
   trunk/g10/passphrase.c
Log:
* options.h, gpg.c (main), passphrase.c (passphrase_to_dek): Add
--passphrase-repeat option to control how many times gpg will
re-prompt for a passphrase to ensure the user has typed it correctly.
Defaults to 1.


Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog	2006-12-03 04:38:53 UTC (rev 4355)
+++ trunk/g10/ChangeLog	2006-12-03 04:41:59 UTC (rev 4356)
@@ -1,3 +1,10 @@
+2006-12-02  David Shaw  <dshaw at jabberwocky.com>
+
+	* options.h, gpg.c (main), passphrase.c (passphrase_to_dek): Add
+	--passphrase-repeat option to control how many times gpg will
+	re-prompt for a passphrase to ensure the user has typed it
+	correctly.  Defaults to 1.
+
 2006-11-27  Werner Koch  <wk at g10code.com>
 
 	* openfile.c (ask_outfile_name): Fixed buffer overflow occurring

Modified: trunk/g10/gpg.c
===================================================================
--- trunk/g10/gpg.c	2006-12-03 04:38:53 UTC (rev 4355)
+++ trunk/g10/gpg.c	2006-12-03 04:41:59 UTC (rev 4356)
@@ -211,6 +211,7 @@
     oPasswd,
     oPasswdFD,
     oPasswdFile,
+    oPasswdRepeat,
     oCommandFD,
     oCommandFile,
     oQuickRandom,
@@ -564,6 +565,7 @@
     { oPasswd, "passphrase",2, "@" },
     { oPasswdFD, "passphrase-fd",1, "@" },
     { oPasswdFile, "passphrase-file",2, "@" },
+    { oPasswdRepeat, "passphrase-repeat", 1, "@"},
     { oCommandFD, "command-fd",1, "@" },
     { oCommandFile, "command-file",2, "@" },
     { oQuickRandom, "debug-quick-random", 0, "@"},
@@ -1858,6 +1860,7 @@
     opt.def_sig_expire="0";
     opt.def_cert_expire="0";
     set_homedir ( default_homedir () );
+    opt.passwd_repeat=1;
 
     /* Check whether we have a config file on the command line.  */
     orig_argc = argc;
@@ -2419,6 +2422,7 @@
 	  case oPasswdFile:
             pwfd = open_info_file (pargs.r.ret_str, 0);
             break;
+	  case oPasswdRepeat: opt.passwd_repeat=pargs.r.ret_int; break;
 	  case oCommandFD:
             opt.command_fd = iobuf_translate_file_handle (pargs.r.ret_int, 0);
             break;

Modified: trunk/g10/options.h
===================================================================
--- trunk/g10/options.h	2006-12-03 04:38:53 UTC (rev 4355)
+++ trunk/g10/options.h	2006-12-03 04:41:59 UTC (rev 4356)
@@ -239,8 +239,8 @@
   } *auto_key_locate;
 
   /* True if multiple concatenated signatures may be verified. */
-  int allow_multisig_verification; 
-
+  int allow_multisig_verification;
+  int passwd_repeat;
 } opt;
 
 /* CTRL is used to keep some global variables we currently can't

Modified: trunk/g10/passphrase.c
===================================================================
--- trunk/g10/passphrase.c	2006-12-03 04:38:53 UTC (rev 4355)
+++ trunk/g10/passphrase.c	2006-12-03 04:41:59 UTC (rev 4356)
@@ -613,17 +613,21 @@
         pw = xstrdup ("");
       if ( *pw && mode == 2 )
         {
-          char *pw2 = passphrase_get ( keyid, 2, NULL, NULL, NULL,
-                                       NULL, canceled );
-          if (!pw2)
-            pw2 = xstrdup ("");
-          if ( strcmp(pw, pw2) )
-            {
-              xfree(pw2);
-              xfree(pw);
-              return NULL;
-            }
-          xfree(pw2);
+	  int i;
+	  for(i=0;i<opt.passwd_repeat;i++)
+	    {
+	      char *pw2 = passphrase_get ( keyid, 2, NULL, NULL, NULL,
+					   NULL, canceled );
+	      if (!pw2)
+		pw2 = xstrdup ("");
+	      if ( strcmp(pw, pw2) )
+		{
+		  xfree(pw2);
+		  xfree(pw);
+		  return NULL;
+		}
+	      xfree(pw2);
+	    }
 	}
     }
     




More information about the Gnupg-commits mailing list