[Pkg-gnupg-commit] [gnupg2] 86/292: wks: Add option --fake-submission-addr to gpg-wks-client.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Nov 21 06:31:28 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gnupg2.

commit e514a5b725f0c997cef4362808b2778a3faa9cf8
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Oct 5 11:51:32 2016 +0200

    wks: Add option --fake-submission-addr to gpg-wks-client.
    
    * tools/gpg-wks-client.c (oFakeSubmissionAddr): New.
    (opts): Add option --fake-submission-addr.
    (fake_submission_addr): New variable.
    (parse_arguments): Set it.
    (command_send): Use --fake-submission-addr.
    --
    
    This option is useful for testing.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 tools/gpg-wks-client.c | 49 +++++++++++++++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 16 deletions(-)

diff --git a/tools/gpg-wks-client.c b/tools/gpg-wks-client.c
index f4257ec..4df54cc 100644
--- a/tools/gpg-wks-client.c
+++ b/tools/gpg-wks-client.c
@@ -56,6 +56,7 @@ enum cmd_and_opt_values
 
     oGpgProgram,
     oSend,
+    oFakeSubmissionAddr,
 
     oDummy
   };
@@ -83,6 +84,7 @@ static ARGPARSE_OPTS opts[] = {
   ARGPARSE_s_n (oSend, "send", "send the mail using sendmail"),
   ARGPARSE_s_s (oOutput, "output", "|FILE|write the mail to FILE"),
 
+  ARGPARSE_s_s (oFakeSubmissionAddr, "fake-submission-addr", "@"),
 
   ARGPARSE_end ()
 };
@@ -102,6 +104,11 @@ static struct debug_flags_s debug_flags [] =
   };
 
 
+
+/* Value of the option --fake-submission-addr.  */
+const char *fake_submission_addr;
+
+
 static void wrong_args (const char *text) GPGRT_ATTR_NORETURN;
 static gpg_error_t command_supported (char *userid);
 static gpg_error_t command_send (const char *fingerprint, char *userid);
@@ -180,6 +187,9 @@ parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
         case oOutput:
           opt.output = pargs->r.ret_str;
           break;
+        case oFakeSubmissionAddr:
+          fake_submission_addr = pargs->r.ret_str;
+          break;
 
 	case aSupported:
 	case aCreate:
@@ -551,30 +561,37 @@ command_send (const char *fingerprint, char *userid)
     goto leave;
 
   /* Get the submission address.  */
-  err = wkd_get_submission_address (addrspec, &submission_to);
+  if (fake_submission_addr)
+    {
+      submission_to = xstrdup (fake_submission_addr);
+      err = 0;
+    }
+  else
+    err = wkd_get_submission_address (addrspec, &submission_to);
   if (err)
     goto leave;
   log_info ("submitting request to '%s'\n", submission_to);
 
   /* Get the policy flags.  */
-  {
-    estream_t mbuf;
+  if (!fake_submission_addr)
+    {
+      estream_t mbuf;
 
-    err = wkd_get_policy_flags (addrspec, &mbuf);
-    if (err)
-      {
-        log_error ("error reading policy flags for '%s': %s\n",
-                   submission_to, gpg_strerror (err));
-        goto leave;
-      }
-    if (mbuf)
-      {
-        err = wks_parse_policy (&policy, mbuf, 1);
-        es_fclose (mbuf);
-        if (err)
+      err = wkd_get_policy_flags (addrspec, &mbuf);
+      if (err)
+        {
+          log_error ("error reading policy flags for '%s': %s\n",
+                     submission_to, gpg_strerror (err));
           goto leave;
       }
-  }
+      if (mbuf)
+        {
+          err = wks_parse_policy (&policy, mbuf, 1);
+          es_fclose (mbuf);
+          if (err)
+            goto leave;
+        }
+    }
 
   if (policy.auth_submit)
     log_info ("no confirmation required for '%s'\n", addrspec);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list