[svn] GnuPG - r4858 - trunk/sm

svn author wk cvs at cvs.gnupg.org
Thu Oct 23 11:41:42 CEST 2008


Author: wk
Date: 2008-10-23 11:41:41 +0200 (Thu, 23 Oct 2008)
New Revision: 4858

Modified:
   trunk/sm/ChangeLog
   trunk/sm/export.c
   trunk/sm/import.c
Log:
Try to start the agent before invoking the protect-tool.


Modified: trunk/sm/ChangeLog
===================================================================
--- trunk/sm/ChangeLog	2008-10-21 15:03:51 UTC (rev 4857)
+++ trunk/sm/ChangeLog	2008-10-23 09:41:41 UTC (rev 4858)
@@ -1,3 +1,9 @@
+2008-10-23  Werner Koch  <wk at g10code.com>
+
+	* import.c (popen_protect_tool): Add arg CTRL and assure that the
+	agent is running.  Pass a value for CTRL from all caller.
+	* export.c (popen_protect_tool): Ditto.
+
 2008-10-21  Werner Koch  <wk at g10code.com>
 
 	* call-dirmngr.c (inq_certificate_parm_s): Add field CTRL.

Modified: trunk/sm/export.c
===================================================================
--- trunk/sm/export.c	2008-10-21 15:03:51 UTC (rev 4857)
+++ trunk/sm/export.c	2008-10-23 09:41:41 UTC (rev 4858)
@@ -571,7 +571,7 @@
 
 
 static gpg_error_t
-popen_protect_tool (const char *pgmname,
+popen_protect_tool (ctrl_t ctrl, const char *pgmname,
                     FILE *infile, FILE *outfile, FILE **statusfile, 
                     const char *prompt, const char *keygrip,
                     pid_t *pid)
@@ -579,6 +579,12 @@
   const char *argv[20];
   int i=0;
 
+  /* Make sure that the agent is running so that the protect tool is
+     able to ask for a passphrase.  This has only an effect under W32
+     where the agent is started on demand; sending a NOP does not harm
+     on other platforms. */
+  gpgsm_agent_send_nop (ctrl);
+
   argv[i++] = "--homedir";
   argv[i++] = opt.homedir;
   argv[i++] = "--p12-export";
@@ -645,7 +651,8 @@
       goto cleanup;
     }
 
-  err = popen_protect_tool (pgmname, infp, outfp, &fp, prompt, keygrip, &pid);
+  err = popen_protect_tool (ctrl, 
+                            pgmname, infp, outfp, &fp, prompt, keygrip, &pid);
   if (err)
     {
       pid = -1;

Modified: trunk/sm/import.c
===================================================================
--- trunk/sm/import.c	2008-10-21 15:03:51 UTC (rev 4857)
+++ trunk/sm/import.c	2008-10-23 09:41:41 UTC (rev 4858)
@@ -460,12 +460,18 @@
    output to OUTFILE and the pid of the process in PID.  Returns 0 on
    success or an error code. */
 static gpg_error_t
-popen_protect_tool (const char *pgmname,
+popen_protect_tool (ctrl_t ctrl, const char *pgmname,
                     FILE *infile, FILE *outfile, FILE **statusfile, pid_t *pid)
 {
   const char *argv[20];
   int i=0;
 
+  /* Make sure that the agent is running so that the protect tool is
+     able to ask for a passphrase.  This has only an effect under W32
+     where the agent is started on demand; sending a NOP does not harm
+     on other platforms. */
+  gpgsm_agent_send_nop (ctrl);
+
   argv[i++] = "--homedir";
   argv[i++] = opt.homedir;
   argv[i++] = "--p12-import";
@@ -551,7 +557,7 @@
       goto cleanup;
     }
 
-  err = popen_protect_tool (pgmname, tmpfp, certfp, &fp, &pid);
+  err = popen_protect_tool (ctrl, pgmname, tmpfp, certfp, &fp, &pid);
   if (err)
     {
       pid = -1;




More information about the Gnupg-commits mailing list