[Pkg-gnupg-commit] [gnupg2] 06/118: wks: Add command --supported to gpg-wks-client.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu Sep 15 18:24:57 UTC 2016


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

dkg pushed a commit to branch encoding-and-speling
in repository gnupg2.

commit 460568d341851ac79dd100e00e4eafcac1318148
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Aug 24 15:48:21 2016 +0200

    wks: Add command --supported to gpg-wks-client.
    
    * tools/gpg-wks-client.c (aSupported): New.
    (opts): Add --supported.
    (parse_arguments): Ditto.
    (main): Call command_supported.
    (command_supported): New.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 tools/gpg-wks-client.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/tools/gpg-wks-client.c b/tools/gpg-wks-client.c
index 2c9cc4f..34b26ea 100644
--- a/tools/gpg-wks-client.c
+++ b/tools/gpg-wks-client.c
@@ -49,6 +49,7 @@ enum cmd_and_opt_values
 
     oDebug      = 500,
 
+    aSupported,
     aCreate,
     aReceive,
     aRead,
@@ -64,6 +65,8 @@ enum cmd_and_opt_values
 static ARGPARSE_OPTS opts[] = {
   ARGPARSE_group (300, ("@Commands:\n ")),
 
+  ARGPARSE_c (aSupported, "supported",
+              ("check whether provider supports WKS")),
   ARGPARSE_c (aCreate,   "create",
               ("create a publication request")),
   ARGPARSE_c (aReceive,   "receive",
@@ -98,6 +101,7 @@ static struct debug_flags_s debug_flags [] =
 
 
 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);
 static gpg_error_t process_confirmation_request (estream_t msg);
 static gpg_error_t command_receive_cb (void *opaque,
@@ -174,6 +178,7 @@ parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
           opt.output = pargs->r.ret_str;
           break;
 
+	case aSupported:
 	case aCreate:
 	case aReceive:
 	case aRead:
@@ -237,6 +242,14 @@ main (int argc, char **argv)
   /* Run the selected command.  */
   switch (cmd)
     {
+    case aSupported:
+      if (argc != 1)
+        wrong_args ("--supported USER-ID");
+      err = command_supported (argv[0]);
+      if (err && gpg_err_code (err) != GPG_ERR_FALSE)
+        log_error ("checking support failed: %s\n", gpg_strerror (err));
+      break;
+
     case aCreate:
       if (argc != 2)
         wrong_args ("--create FINGERPRINT USER-ID");
@@ -381,6 +394,48 @@ get_key (estream_t *r_key, const char *fingerprint, const char *addrspec)
 
 
 

+/* Check whether the  provider supports the WKS protocol.  */
+static gpg_error_t
+command_supported (char *userid)
+{
+  gpg_error_t err;
+  char *addrspec = NULL;
+  char *submission_to = NULL;
+
+  addrspec = mailbox_from_userid (userid);
+  if (!addrspec)
+    {
+      log_error (_("\"%s\" is not a proper mail address\n"), userid);
+      err = gpg_error (GPG_ERR_INV_USER_ID);
+      goto leave;
+    }
+
+  /* Get the submission address.  */
+  err = wkd_get_submission_address (addrspec, &submission_to);
+  if (err)
+    {
+      if (gpg_err_code (err) == GPG_ERR_NO_DATA
+          || gpg_err_code (err) == GPG_ERR_UNKNOWN_HOST)
+        {
+          if (opt.verbose)
+            log_info ("provider for '%s' does NOT support WKS (%s)\n",
+                      addrspec, gpg_strerror (err));
+          err = gpg_error (GPG_ERR_FALSE);
+          log_inc_errorcount ();
+        }
+      goto leave;
+    }
+  if (opt.verbose)
+    log_info ("provider for '%s' supports WKS\n", addrspec);
+
+ leave:
+  xfree (submission_to);
+  xfree (addrspec);
+  return err;
+}
+
+
+

 /* Locate the key by fingerprint and userid and send a publication
  * request.  */
 static gpg_error_t

-- 
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