[git] GnuPG - branch, master, updated. gnupg-2.1.21-93-g330212e

by Werner Koch cvs at cvs.gnupg.org
Thu Jul 13 18:35:10 CEST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  330212efb927c119bb5135856f8582c0e4e2e6b7 (commit)
       via  fa1155e89ebb4b16ee95549b8ab72672df3a0c54 (commit)
      from  877a321d011deb3e8501aa9cc5e9f9cd0b19dddf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 330212efb927c119bb5135856f8582c0e4e2e6b7
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jul 13 18:22:36 2017 +0200

    gpg: Pass key origin values to import functions.
    
    * g10/import.c (import_keys_stream): Remove this unused function.
    (import_keys_internal): Add arg origin.
    (import_keys): Ditto.
    (import_keys_es_stream): Ditto.
    (import): Ditto.
    (import_one): Ditto.
    (apply_meta_data): New stub.
    (import_secret_one): Pass 0 for ORIGIN.
    * g10/keyserver.c (keyserver_get_chunk): For now pass 0 for ORIGIN.
    (keyserver_fetch): Add arg origin.
    (keyserver_import_cert): Pass KEYORG_DANE for ORIGIN.
    (keyserver_import_wkd): Pass KEYORG_WKD for ORIGIN.
    * g10/gpg.c (main): Pass OPT.KEY_ORIGIN to import_keys and
    keyserver_fetch.
    * g10/card-util.c (fetch_url): Pass KEYORG_URL for ORIGIN.
    --
    
    This is just the framework; applying the meta data will be done in
    another commit.
    
    GnuPG-bug-id: 3252
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/g10/card-util.c b/g10/card-util.c
index 78cd52b..f1795b8 100644
--- a/g10/card-util.c
+++ b/g10/card-util.c
@@ -818,7 +818,7 @@ fetch_url (ctrl_t ctrl)
           strlist_t sl = NULL;
 
           add_to_strlist (&sl, info.pubkey_url);
-          rc = keyserver_fetch (ctrl, sl);
+          rc = keyserver_fetch (ctrl, sl, KEYORG_URL);
           free_strlist (sl);
         }
       else if (info.fpr1valid)
diff --git a/g10/gpg.c b/g10/gpg.c
index 38eeddf..5c60e1d 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -4508,7 +4508,8 @@ main (int argc, char **argv)
       case aFastImport:
         opt.import_options |= IMPORT_FAST; /* fall through */
       case aImport:
-	import_keys (ctrl, argc? argv:NULL, argc, NULL, opt.import_options);
+	import_keys (ctrl, argc? argv:NULL, argc, NULL,
+                     opt.import_options, opt.key_origin);
 	break;
 
 	/* TODO: There are a number of command that use this same
@@ -4596,7 +4597,7 @@ main (int argc, char **argv)
 	sl = NULL;
 	for( ; argc; argc--, argv++ )
 	    append_to_strlist2( &sl, *argv, utf8_strings );
-	rc = keyserver_fetch (ctrl, sl);
+	rc = keyserver_fetch (ctrl, sl, opt.key_origin);
 	if(rc)
           {
             write_status_failure ("fetch-keys", rc);
diff --git a/g10/import.c b/g10/import.c
index 491609d..8010fa5 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -97,7 +97,7 @@ struct import_filter_s import_filter;
 static int import (ctrl_t ctrl,
                    IOBUF inp, const char* fname, struct import_stats_s *stats,
 		   unsigned char **fpr, size_t *fpr_len, unsigned int options,
-		   import_screener_t screener, void *screener_arg);
+		   import_screener_t screener, void *screener_arg, int origin);
 static int read_block (IOBUF a, int with_meta,
                        PACKET **pending_pkt, kbnode_t *ret_root, int *r_v3keys);
 static void revocation_present (ctrl_t ctrl, kbnode_t keyblock);
@@ -106,7 +106,8 @@ static int import_one (ctrl_t ctrl,
                        struct import_stats_s *stats,
                        unsigned char **fpr, size_t *fpr_len,
                        unsigned int options, int from_sk, int silent,
-                       import_screener_t screener, void *screener_arg);
+                       import_screener_t screener, void *screener_arg,
+                       int origin);
 static int import_secret_one (ctrl_t ctrl, kbnode_t keyblock,
                               struct import_stats_s *stats, int batch,
                               unsigned int options, int for_migration,
@@ -430,7 +431,8 @@ import_keys_internal (ctrl_t ctrl, iobuf_t inp, char **fnames, int nnames,
 		      import_stats_t stats_handle,
                       unsigned char **fpr, size_t *fpr_len,
 		      unsigned int options,
-                      import_screener_t screener, void *screener_arg)
+                      import_screener_t screener, void *screener_arg,
+                      int origin)
 {
   int i;
   int rc = 0;
@@ -442,7 +444,7 @@ import_keys_internal (ctrl_t ctrl, iobuf_t inp, char **fnames, int nnames,
   if (inp)
     {
       rc = import (ctrl, inp, "[stream]", stats, fpr, fpr_len, options,
-                   screener, screener_arg);
+                   screener, screener_arg, origin);
     }
   else
     {
@@ -467,7 +469,7 @@ import_keys_internal (ctrl_t ctrl, iobuf_t inp, char **fnames, int nnames,
           else
             {
               rc = import (ctrl, inp2, fname, stats, fpr, fpr_len, options,
-                           screener, screener_arg);
+                           screener, screener_arg, origin);
               iobuf_close (inp2);
               /* Must invalidate that ugly cache to actually close it. */
               iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)fname);
@@ -501,28 +503,20 @@ import_keys_internal (ctrl_t ctrl, iobuf_t inp, char **fnames, int nnames,
 
 void
 import_keys (ctrl_t ctrl, char **fnames, int nnames,
-	     import_stats_t stats_handle, unsigned int options )
+	     import_stats_t stats_handle, unsigned int options, int origin)
 {
   import_keys_internal (ctrl, NULL, fnames, nnames, stats_handle,
-                        NULL, NULL, options, NULL, NULL);
-}
-
-int
-import_keys_stream (ctrl_t ctrl, IOBUF inp, import_stats_t stats_handle,
-		    unsigned char **fpr, size_t *fpr_len, unsigned int options)
-{
-  return import_keys_internal (ctrl, inp, NULL, 0, stats_handle,
-                               fpr, fpr_len, options, NULL, NULL);
+                        NULL, NULL, options, NULL, NULL, origin);
 }
 
 
-/* Variant of import_keys_stream reading from an estream_t.  */
 int
 import_keys_es_stream (ctrl_t ctrl, estream_t fp,
                        import_stats_t stats_handle,
                        unsigned char **fpr, size_t *fpr_len,
                        unsigned int options,
-                       import_screener_t screener, void *screener_arg)
+                       import_screener_t screener, void *screener_arg,
+                       int origin)
 {
   int rc;
   iobuf_t inp;
@@ -537,7 +531,7 @@ import_keys_es_stream (ctrl_t ctrl, estream_t fp,
 
   rc = import_keys_internal (ctrl, inp, NULL, 0, stats_handle,
                              fpr, fpr_len, options,
-                             screener, screener_arg);
+                             screener, screener_arg, origin);
 
   iobuf_close (inp);
   return rc;
@@ -547,7 +541,7 @@ import_keys_es_stream (ctrl_t ctrl, estream_t fp,
 static int
 import (ctrl_t ctrl, IOBUF inp, const char* fname,struct import_stats_s *stats,
 	unsigned char **fpr,size_t *fpr_len, unsigned int options,
-	import_screener_t screener, void *screener_arg)
+	import_screener_t screener, void *screener_arg, int origin)
 {
   PACKET *pending_pkt = NULL;
   kbnode_t keyblock = NULL;  /* Need to initialize because gcc can't
@@ -575,7 +569,7 @@ import (ctrl_t ctrl, IOBUF inp, const char* fname,struct import_stats_s *stats,
       if (keyblock->pkt->pkttype == PKT_PUBLIC_KEY)
         rc = import_one (ctrl, keyblock,
                          stats, fpr, fpr_len, options, 0, 0,
-                         screener, screener_arg);
+                         screener, screener_arg, origin);
       else if (keyblock->pkt->pkttype == PKT_SECRET_KEY)
         rc = import_secret_one (ctrl, keyblock, stats,
                                 opt.batch, options, 0,
@@ -1384,19 +1378,32 @@ apply_drop_sig_filter (ctrl_t ctrl, kbnode_t keyblock, recsel_expr_t selector)
 }
 
 
+/* Apply meta data to KEYBLOCK.  This sets the origin of the key to
+ * ORIGIN.  If MERGE is true KEYBLOCK has been updated and the meta
+ * data is merged and not simply inserted.  */
+static gpg_error_t
+apply_meta_data (kbnode_t keyblock, int merge, int origin)
+{
+
+  return 0;
+}
+
+
 /*
  * Try to import one keyblock. Return an error only in serious cases,
  * but never for an invalid keyblock.  It uses log_error to increase
  * the internal errorcount, so that invalid input can be detected by
  * programs which called gpg.  If SILENT is no messages are printed -
- * even most error messages are suppressed.
+ * even most error messages are suppressed.  ORIGIN is the origin of
+ * the key (0 for unknown).
  */
 static int
 import_one (ctrl_t ctrl,
             kbnode_t keyblock, struct import_stats_s *stats,
 	    unsigned char **fpr, size_t *fpr_len, unsigned int options,
 	    int from_sk, int silent,
-            import_screener_t screener, void *screener_arg)
+            import_screener_t screener, void *screener_arg,
+            int origin)
 {
   PKT_public_key *pk;
   PKT_public_key *pk_orig = NULL;
@@ -1614,6 +1621,17 @@ import_one (ctrl_t ctrl,
       if (opt.verbose > 1 )
         log_info (_("writing to '%s'\n"), keydb_get_resource_name (hd) );
 
+      /* Unless we are in restore mode apply meta data to the
+       * keyblock.  Note that this will never change the first packet
+       * and thus the address of KEYBLOCK won't change.  */
+      if ( !(options & IMPORT_RESTORE) )
+        {
+          rc = apply_meta_data (keyblock, 0, origin);
+          log_error ("apply_meta_data failed: %s\n", gpg_strerror (rc));
+          keydb_release (hd);
+          return GPG_ERR_GENERAL;
+        }
+
       rc = keydb_insert_keyblock (hd, keyblock );
       if (rc)
         log_error (_("error writing keyring '%s': %s\n"),
@@ -2286,7 +2304,7 @@ import_secret_one (ctrl_t ctrl, kbnode_t keyblock,
 	 the secret keys.  FIXME?  */
       import_one (ctrl, pub_keyblock, stats,
 		  NULL, NULL, options, 1, for_migration,
-                  screener, screener_arg);
+                  screener, screener_arg, 0);
 
       /* Fixme: We should check for an invalid keyblock and
 	 cancel the secret key import in this case.  */
diff --git a/g10/keyserver-internal.h b/g10/keyserver-internal.h
index 02452e8..46a1e1d 100644
--- a/g10/keyserver-internal.h
+++ b/g10/keyserver-internal.h
@@ -40,7 +40,7 @@ int keyserver_import_keyid (ctrl_t ctrl, u32 *keyid,
                             struct keyserver_spec *keyserver, int quick);
 gpg_error_t keyserver_refresh (ctrl_t ctrl, strlist_t users);
 gpg_error_t keyserver_search (ctrl_t ctrl, strlist_t tokens);
-int keyserver_fetch (ctrl_t ctrl, strlist_t urilist);
+int keyserver_fetch (ctrl_t ctrl, strlist_t urilist, int origin);
 int keyserver_import_cert (ctrl_t ctrl, const char *name, int dane_mode,
                            unsigned char **fpr,size_t *fpr_len);
 gpg_error_t keyserver_import_pka (ctrl_t ctrl, const char *name,
diff --git a/g10/keyserver.c b/g10/keyserver.c
index c9be1f0..bec30e3 100644
--- a/g10/keyserver.c
+++ b/g10/keyserver.c
@@ -1746,7 +1746,8 @@ keyserver_get_chunk (ctrl_t ctrl, KEYDB_SEARCH_DESC *desc, int ndesc,
                              r_fpr, r_fprlen,
                              (opt.keyserver_options.import_options
                               | IMPORT_NO_SECKEY),
-                             keyserver_retrieval_screener, &screenerarg);
+                             keyserver_retrieval_screener, &screenerarg,
+                             0 /* FIXME? */);
     }
   es_fclose (datastream);
   xfree (source);
@@ -1852,7 +1853,7 @@ keyserver_put (ctrl_t ctrl, strlist_t keyspecs)
    that the fetch operation ignores the configured keyservers and
    instead directly retrieves the keys.  */
 int
-keyserver_fetch (ctrl_t ctrl, strlist_t urilist)
+keyserver_fetch (ctrl_t ctrl, strlist_t urilist, int origin)
 {
   gpg_error_t err;
   strlist_t sl;
@@ -1877,7 +1878,7 @@ keyserver_fetch (ctrl_t ctrl, strlist_t urilist)
           stats_handle = import_new_stats_handle();
           import_keys_es_stream (ctrl, datastream, stats_handle, NULL, NULL,
                                  opt.keyserver_options.import_options,
-                                 NULL, NULL);
+                                 NULL, NULL, origin);
 
           import_print_stats (stats_handle);
           import_release_stats_handle (stats_handle);
@@ -1932,7 +1933,7 @@ keyserver_import_cert (ctrl_t ctrl, const char *name, int dane_mode,
       err = import_keys_es_stream (ctrl, key, NULL, fpr, fpr_len,
                                    (opt.keyserver_options.import_options
                                     | IMPORT_NO_SECKEY),
-                                   NULL, NULL);
+                                   NULL, NULL, KEYORG_DANE);
 
       opt.no_armor=armor_status;
 
@@ -2055,7 +2056,7 @@ keyserver_import_wkd (ctrl_t ctrl, const char *name, int quick,
           if (!err)
             err = import_keys_es_stream (ctrl, key, NULL, fpr, fpr_len,
                                          IMPORT_NO_SECKEY,
-                                         NULL, NULL);
+                                         NULL, NULL, KEYORG_WKD);
 
         }
 
diff --git a/g10/main.h b/g10/main.h
index dad0fe3..e69ed9d 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -352,15 +352,13 @@ void            restore_import_filter (import_filter_t filt);
 gpg_error_t read_key_from_file (ctrl_t ctrl, const char *fname,
                                 kbnode_t *r_keyblock);
 void import_keys (ctrl_t ctrl, char **fnames, int nnames,
-		  import_stats_t stats_hd, unsigned int options);
-int import_keys_stream (ctrl_t ctrl, iobuf_t inp, import_stats_t stats_hd,
-                        unsigned char **fpr,
-			size_t *fpr_len, unsigned int options);
+		  import_stats_t stats_hd, unsigned int options, int origin);
 int import_keys_es_stream (ctrl_t ctrl, estream_t fp,
                            import_stats_t stats_handle,
                            unsigned char **fpr, size_t *fpr_len,
                            unsigned int options,
-                           import_screener_t screener, void *screener_arg);
+                           import_screener_t screener, void *screener_arg,
+                           int origin);
 gpg_error_t import_old_secring (ctrl_t ctrl, const char *fname);
 import_stats_t import_new_stats_handle (void);
 void import_release_stats_handle (import_stats_t hd);

commit fa1155e89ebb4b16ee95549b8ab72672df3a0c54
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jul 13 17:28:32 2017 +0200

    gpg: New option --key-origin.
    
    * g10/keydb.h (KEYORG_): Rename to KEYORG_.
    * g10/packet.h (PKT_user_id): Rename field keysrc to keyorg.  Adjust
    users.
    (PKT_public_key): Ditto.
    (PKT_ring_trust): Ditto.
    * g10/options.h (struct opt): Add field key_origin.
    * g10/getkey.c (parse_key_origin): New.
    * g10/gpg.c (oKeyOrigin): New.
    (opts): Add "keys-origin".
    (main): Set option.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/doc/DETAILS b/doc/DETAILS
index b915f06..cbeead7 100644
--- a/doc/DETAILS
+++ b/doc/DETAILS
@@ -1347,12 +1347,13 @@ CREATE TABLE signatures (
                - 2 :: Key source on a user id (UID)
   - 1 octet :: Key Source; i.e. the origin of the key:
                - 0 :: Unknown source.
-               - 1 :: Direct import from a file.
-               - 2 :: Public keyserver.
-               - 3 :: Preferred keysrver.
+               - 1 :: Public keyserver.
+               - 2 :: Preferred keysrver.
+               - 3 :: OpenPGP DANE.
                - 4 :: Web Key Directory.
-               - 5 :: Web Key Directory via sub-domain.
-               - 6 :: OpenPGP DANE.
+               - 5 :: Import from a trusted URL.
+               - 6 :: Import from a trusted file.
+               - 7 :: Self generated.
   - 4 octets :: Time of last update.  This is a a four-octet scalar
                 with the seconds since Epoch.
   - 1 octet  :: Scalar with the length of the following field.
diff --git a/doc/gpg.texi b/doc/gpg.texi
index bc83eff..64dd502 100644
--- a/doc/gpg.texi
+++ b/doc/gpg.texi
@@ -2254,6 +2254,13 @@ hint to optimize its buffer allocation strategy.  It is also used by
 the @option{--status-fd} line ``PROGRESS'' to provide a value for
 ``total'' if that is not available by other means.
 
+ at item --key-origin @var{string}
+ at opindex key-origin
+gpg can track the origin of a key. Certain origins are implicitly
+known (e.g. keyserver, web key directory) and set.  For a standard
+import the origin of the keys imported can be set with this optionb.
+To list the possible values use "help" for @var{string}.
+
 @item --import-options @code{parameters}
 @opindex import-options
 This is a space or comma delimited string that gives options for
diff --git a/g10/build-packet.c b/g10/build-packet.c
index fa2674b..6d00fc5 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -213,7 +213,7 @@ build_packet_and_meta (iobuf_t out, PACKET *pkt)
       PKT_user_id *uid = pkt->pkt.user_id;
 
       rt.subtype = RING_TRUST_UID;
-      rt.keysrc = uid->keysrc;
+      rt.keyorg = uid->keyorg;
       rt.keyupdate = uid->keyupdate;
       rt.url = uid->updateurl;
       err = do_ring_trust (out, &rt);
@@ -225,7 +225,7 @@ build_packet_and_meta (iobuf_t out, PACKET *pkt)
       PKT_public_key *pk = pkt->pkt.public_key;
 
       rt.subtype = RING_TRUST_KEY;
-      rt.keysrc = pk->keysrc;
+      rt.keyorg = pk->keyorg;
       rt.keyupdate = pk->keyupdate;
       rt.url = pk->updateurl;
       err = do_ring_trust (out, &rt);
@@ -395,7 +395,7 @@ do_ring_trust (iobuf_t out, PKT_ring_trust *rt)
   iobuf_put (out, rt->subtype);
   if (rt->subtype == RING_TRUST_KEY || rt->subtype == RING_TRUST_UID)
     {
-      iobuf_put (out, rt->keysrc);
+      iobuf_put (out, rt->keyorg);
       write_32 (out, rt->keyupdate);
       iobuf_put (out, namelen);
       if (namelen)
diff --git a/g10/call-dirmngr.c b/g10/call-dirmngr.c
index cb6c69c..76fa072 100644
--- a/g10/call-dirmngr.c
+++ b/g10/call-dirmngr.c
@@ -379,6 +379,7 @@ ks_status_cb (void *opaque, const char *line)
 
   if ((s = has_leading_keyword (line, parm->keyword? parm->keyword : "SOURCE")))
     {
+      /* Note that the arg for "S SOURCE" is the URL of a keyserver.  */
       if (!parm->source)
         {
           parm->source = xtrystrdup (s);
diff --git a/g10/getkey.c b/g10/getkey.c
index a3df857..285ea35 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -4294,6 +4294,41 @@ parse_auto_key_locate (char *options)
 }
 
 
+/* Parse the argument for --key-origin.  Return false on error. */
+int
+parse_key_origin (char *string)
+{
+  struct { const char *name; int origin; } list[] = {
+    { "self",    KEYORG_SELF    },
+    { "file",    KEYORG_FILE    },
+    { "url",     KEYORG_URL     },
+    { "wkd",     KEYORG_WKD     },
+    { "dane",    KEYORG_DANE    },
+    { "ks-pref", KEYORG_KS_PREF },
+    { "ks",      KEYORG_KS      },
+    { "unknown", KEYORG_UNKNOWN }
+  };
+  int i;
+
+  if (!ascii_strcasecmp (string, "help"))
+    {
+      log_info (_("valid values for option '%s':\n"), "--key-origin");
+      for (i=0; i < DIM (list); i++)
+        log_info ("  %s\n", list[i].name);
+      g10_exit (1);
+    }
+
+  for (i=0; i < DIM (list); i++)
+    if (!ascii_strcasecmp (string, list[i].name))
+      {
+        opt.key_origin = list[i].origin;
+        return 1;
+      }
+
+  return 0;
+}
+
+
 /* Returns true if a secret key is available for the public key with
    key id KEYID; returns false if not.  This function ignores legacy
    keys.  Note: this is just a fast check and does not tell us whether
diff --git a/g10/gpg.c b/g10/gpg.c
index 3e15373..38eeddf 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -419,6 +419,7 @@ enum cmd_and_opt_values
     oOnlySignTextIDs,
     oDisableSignerUID,
     oSender,
+    oKeyOrigin,
 
     oNoop
   };
@@ -615,6 +616,7 @@ static ARGPARSE_OPTS opts[] = {
 
   ARGPARSE_s_s (oKeyServer, "keyserver", "@"),
   ARGPARSE_s_s (oKeyServerOptions, "keyserver-options", "@"),
+  ARGPARSE_s_s (oKeyOrigin, "key-origin", "@"),
   ARGPARSE_s_s (oImportOptions, "import-options", "@"),
   ARGPARSE_s_s (oImportFilter,  "import-filter", "@"),
   ARGPARSE_s_s (oExportOptions, "export-options", "@"),
@@ -2845,10 +2847,10 @@ main (int argc, char **argv)
 
           case oCompliance:
 	    {
-	      int compliance = gnupg_parse_compliance_option (pargs.r.ret_str,
-							      compliance_options,
-							      DIM (compliance_options),
-							      opt.quiet);
+	      int compliance = gnupg_parse_compliance_option
+                (pargs.r.ret_str,
+                 compliance_options, DIM (compliance_options),
+                 opt.quiet);
 	      if (compliance < 0)
 		g10_exit (1);
 	      set_compliance_option (compliance);
@@ -3462,6 +3464,12 @@ main (int argc, char **argv)
 	    release_akl();
 	    break;
 
+	  case oKeyOrigin:
+	    if(!parse_key_origin (pargs.r.ret_str))
+              log_error (_("invalid argument for option \"%.50s\"\n"),
+                         "--key-origin");
+	    break;
+
 	  case oEnableLargeRSA:
 #if SECMEM_BUFFER_SIZE >= 65536
             opt.flags.large_rsa=1;
diff --git a/g10/keydb.h b/g10/keydb.h
index 4016723..bad3149 100644
--- a/g10/keydb.h
+++ b/g10/keydb.h
@@ -119,13 +119,14 @@ union pref_hint
 /* Constants to describe from where a key was fetched or updated.  */
 enum
   {
-    KEYSRC_UNKNOWN = 0,
-    KEYSRC_FILE    = 1, /* Direct import from a file.  */
-    KEYSRC_KS      = 2, /* Public keyserver.    */
-    KEYSRC_PREF_KS = 3, /* Preferred keysrver.  */
-    KEYSRC_WKD     = 4, /* Web Key Directory.   */
-    KEYSRC_WKD_SD  = 5, /* Web Key Directory but from a sub domain.  */
-    KEYSRC_DANE    = 6  /* OpenPGP DANE.  */
+    KEYORG_UNKNOWN = 0,
+    KEYORG_KS      = 1, /* Public keyserver.    */
+    KEYORG_KS_PREF = 2, /* Preferred keysrver.  */
+    KEYORG_DANE    = 3, /* OpenPGP DANE.        */
+    KEYORG_WKD     = 4, /* Web Key Directory.   */
+    KEYORG_URL     = 5, /* Trusted URL.         */
+    KEYORG_FILE    = 6, /* Trusted file.        */
+    KEYORG_SELF    = 7, /* We generated it.     */
   };
 
 
@@ -396,6 +397,7 @@ char *get_user_id_byfpr_native (ctrl_t ctrl, const byte *fpr);
 
 void release_akl(void);
 int parse_auto_key_locate(char *options);
+int parse_key_origin (char *string);
 
 /*-- keyid.c --*/
 int pubkey_letter( int algo );
diff --git a/g10/options.h b/g10/options.h
index 98417d7..5bb506e 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -263,6 +263,9 @@ struct
     struct akl *next;
   } *auto_key_locate;
 
+  /* The value of --key-origin.  See parse_key_origin().  */
+  int key_origin;
+
   int passphrase_repeat;
   int pinentry_mode;
 
diff --git a/g10/packet.h b/g10/packet.h
index cf2121c..56ac503 100644
--- a/g10/packet.h
+++ b/g10/packet.h
@@ -285,7 +285,7 @@ typedef struct
   u32 created;          /* according to the self-signature */
   u32 keyupdate;        /* From the ring trust packet.  */
   char *updateurl;      /* NULL or the URL of the last update origin.  */
-  byte keysrc;          /* From the ring trust packet.  */
+  byte keyorg;          /* From the ring trust packet.  */
   byte selfsigversion;
   struct
   {
@@ -407,7 +407,7 @@ typedef struct
   u32     trust_timestamp;
   byte    trust_depth;
   byte    trust_value;
-  byte    keysrc;         /* From the ring trust packet.  */
+  byte    keyorg;         /* From the ring trust packet.  */
   u32     keyupdate;      /* From the ring trust packet.  */
   char    *updateurl;     /* NULL or the URL of the last update origin.  */
   const byte *trust_regexp;
@@ -498,7 +498,7 @@ typedef struct {
   unsigned int trustval;
   unsigned int sigcache;
   unsigned char subtype; /* The subtype of this ring trust packet.   */
-  unsigned char keysrc;  /* The origin of the key (KEYSRC_*).        */
+  unsigned char keyorg;  /* The origin of the key (KEYSRC_*).        */
   u32 keyupdate;         /* The wall time the key was last updated.  */
   char *url;             /* NULL or the URL of the source.           */
 } PKT_ring_trust;
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index dbb7af8..0b6ee8b 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -2942,7 +2942,7 @@ parse_ring_trust (parse_packet_ctx_t ctx, unsigned long pktlen)
       int i;
       unsigned int namelen;
 
-      rt.keysrc = iobuf_get_noeof (inp);
+      rt.keyorg = iobuf_get_noeof (inp);
       pktlen--;
       rt.keyupdate = read_32 (inp);
       pktlen -= 4;
@@ -2974,7 +2974,7 @@ parse_ring_trust (parse_packet_ctx_t ctx, unsigned long pktlen)
           es_fprintf (listfp, ":trust packet: %s upd=%lu src=%d%s",
                       (rt.subtype == RING_TRUST_UID? "uid" : "key"),
                       (unsigned long)rt.keyupdate,
-                      rt.keysrc,
+                      rt.keyorg,
                       (rt.url? " url=":""));
           if (rt.url)
             {
@@ -3016,7 +3016,7 @@ parse_ring_trust (parse_packet_ctx_t ctx, unsigned long pktlen)
     {
       PKT_user_id *uid = ctx->last_pkt.pkt.user_id;
 
-      uid->keysrc = rt.keysrc;
+      uid->keyorg = rt.keyorg;
       uid->keyupdate = rt.keyupdate;
       uid->updateurl = rt.url;
       rt.url = NULL;
@@ -3027,7 +3027,7 @@ parse_ring_trust (parse_packet_ctx_t ctx, unsigned long pktlen)
     {
       PKT_public_key *pk = ctx->last_pkt.pkt.public_key;
 
-      pk->keysrc = rt.keysrc;
+      pk->keyorg = rt.keyorg;
       pk->keyupdate = rt.keyupdate;
       pk->updateurl = rt.url;
       rt.url = NULL;

-----------------------------------------------------------------------

Summary of changes:
 doc/DETAILS              | 11 +++++----
 doc/gpg.texi             |  7 ++++++
 g10/build-packet.c       |  6 ++---
 g10/call-dirmngr.c       |  1 +
 g10/card-util.c          |  2 +-
 g10/getkey.c             | 35 ++++++++++++++++++++++++++
 g10/gpg.c                | 21 +++++++++++-----
 g10/import.c             | 64 +++++++++++++++++++++++++++++++-----------------
 g10/keydb.h              | 16 ++++++------
 g10/keyserver-internal.h |  2 +-
 g10/keyserver.c          | 11 +++++----
 g10/main.h               |  8 +++---
 g10/options.h            |  3 +++
 g10/packet.h             |  6 ++---
 g10/parse-packet.c       |  8 +++---
 15 files changed, 138 insertions(+), 63 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list