[git] GnuPG - branch, STABLE-BRANCH-2-2, updated. gnupg-2.2.9-16-g719fc94

by Werner Koch cvs at cvs.gnupg.org
Wed Aug 29 12:31:08 CEST 2018


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, STABLE-BRANCH-2-2 has been updated
       via  719fc941b6eceb75c2326335d9d73011823ff3f9 (commit)
      from  3169b5ae3f21849354b1413644d3e545c0b08c73 (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 719fc941b6eceb75c2326335d9d73011823ff3f9
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Aug 29 11:53:59 2018 +0200

    gpg: Remove unused function get_pubkeys.
    
    * g10/getkey.c (get_pubkeys): Remove.
    (pubkey_free): Remove and use code directly ...
    (pubkeys_free): ... here.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
    (cherry picked from commit ed8fe21e6612401846fc4af8631f0136dc633c67)

diff --git a/g10/getkey.c b/g10/getkey.c
index be81d99..c4afe45 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -394,280 +394,21 @@ getkey_disable_caches ()
 }
 
 
-void
-pubkey_free (pubkey_t key)
-{
-  if (key)
-    {
-      xfree (key->pk);
-      release_kbnode (key->keyblock);
-      xfree (key);
-    }
-}
-
+/* Free a list of pubkey_t objects.  */
 void
 pubkeys_free (pubkey_t keys)
 {
   while (keys)
     {
       pubkey_t next = keys->next;
-      pubkey_free (keys);
+      xfree (keys->pk);
+      release_kbnode (keys->keyblock);
+      xfree (keys);
       keys = next;
     }
 }
 
 
-/* Returns all keys that match the search specification SEARCH_TERMS.
- *
- * This function also checks for and warns about duplicate entries in
- * the keydb, which can occur if the user has configured multiple
- * keyrings or keyboxes or if a keyring or keybox was corrupted.
- *
- * Note: SEARCH_TERMS will not be expanded (i.e., it may not be a
- * group).
- *
- * USE is the operation for which the key is required.  It must be
- * either PUBKEY_USAGE_ENC, PUBKEY_USAGE_SIG, PUBKEY_USAGE_CERT or
- * PUBKEY_USAGE_AUTH.
- *
- * INCLUDE_UNUSABLE indicates whether disabled keys are allowed.
- * (Recipients specified with --encrypt-to and --hidden-encrypt-to may
- * be disabled.  It is possible to edit disabled keys.)
- *
- * SOURCE is the context in which SEARCH_TERMS was specified, e.g.,
- * "--encrypt-to", etc.  If this function is called interactively,
- * then this should be NULL.
- *
- * If WARN_POSSIBLY_AMBIGUOUS is set, then emits a warning if the user
- * does not specify a long key id or a fingerprint.
- *
- * The results are placed in *KEYS.  *KEYS must be NULL!
- *
- * Fixme: Currently, only PUBKEY_USAGE_ENC and PUBKEY_USAGE_SIG are
- * implemented.  */
-gpg_error_t
-get_pubkeys (ctrl_t ctrl,
-             char *search_terms, int use, int include_unusable, char *source,
-             int warn_possibly_ambiguous,
-             pubkey_t *r_keys)
-{
-  /* We show a warning when a key appears multiple times in the DB.
-   * This can happen for two reasons:
-   *
-   *   - The user has configured multiple keyrings or keyboxes.
-   *
-   *   - The keyring or keybox has been corrupted in some way, e.g., a
-   *     bug or a random process changing them.
-   *
-   * For each duplicate, we only want to show the key once.  Hence,
-   * this list.  */
-  static strlist_t key_dups;
-  gpg_error_t err;
-  char *use_str;   /* USE transformed to a string.  */
-  KEYDB_SEARCH_DESC desc;
-  GETKEY_CTX ctx;
-  pubkey_t results = NULL;
-  pubkey_t r;
-  int count;
-  char fingerprint[2 * MAX_FINGERPRINT_LEN + 1];
-
-  if (DBG_LOOKUP)
-    {
-      log_debug ("\n");
-      log_debug ("%s: Checking %s=%s\n",
-                 __func__, source ? source : "user input", search_terms);
-    }
-
-  if (*r_keys)
-    log_bug ("%s: KEYS should be NULL!\n", __func__);
-
-  switch (use)
-    {
-    case PUBKEY_USAGE_ENC: use_str = "encrypt"; break;
-    case PUBKEY_USAGE_SIG: use_str = "sign"; break;
-    case PUBKEY_USAGE_CERT: use_str = "cetify"; break;
-    case PUBKEY_USAGE_AUTH: use_str = "authentication"; break;
-    default: log_bug ("%s: Bad value for USE (%d)\n", __func__, use);
-    }
-
-  if (use == PUBKEY_USAGE_CERT || use == PUBKEY_USAGE_AUTH)
-    log_bug ("%s: use=%s is unimplemented.\n", __func__, use_str);
-
-  err = classify_user_id (search_terms, &desc, 1);
-  if (err)
-    {
-      log_info (_("key \"%s\" not found: %s\n"),
-                search_terms, gpg_strerror (err));
-      if (!opt.quiet && source)
-        log_info (_("(check argument of option '%s')\n"), source);
-      goto leave;
-    }
-
-  if (warn_possibly_ambiguous
-      && ! (desc.mode == KEYDB_SEARCH_MODE_LONG_KID
-            || desc.mode == KEYDB_SEARCH_MODE_FPR16
-            || desc.mode == KEYDB_SEARCH_MODE_FPR20
-            || desc.mode == KEYDB_SEARCH_MODE_FPR))
-    {
-      log_info (_("Warning: '%s' should be a long key ID or a fingerprint\n"),
-                search_terms);
-      if (!opt.quiet && source)
-        log_info (_("(check argument of option '%s')\n"), source);
-    }
-
-  /* Gather all of the results.  */
-  ctx = NULL;
-  count = 0;
-  do
-    {
-      PKT_public_key *pk;
-      KBNODE kb;
-
-      pk = xtrycalloc (1, sizeof *pk);
-      if (!pk)
-        {
-          err = gpg_error_from_syserror ();
-          goto leave;
-        }
-
-      pk->req_usage = use;
-
-      if (! ctx)
-        err = get_pubkey_byname (ctrl, &ctx, pk, search_terms, &kb, NULL,
-                                 include_unusable, 1);
-      else
-        err = getkey_next (ctrl, ctx, pk, &kb);
-
-      if (gpg_err_code (err) == GPG_ERR_NOT_FOUND) /* No more results.   */
-        {
-          xfree (pk);
-          break;
-        }
-      else if (err) /* An error (other than "not found").  */
-        {
-          log_error (_("error looking up: %s\n"), gpg_strerror (err));
-          xfree (pk);
-          break;
-        }
-
-      /* Another result!  */
-      count ++;
-
-      r = xtrycalloc (1, sizeof (*r));
-      if (!r)
-        {
-          err = gpg_error_from_syserror ();
-          xfree (pk);
-          goto leave;
-        }
-      r->pk = pk;
-      r->keyblock = kb;
-      r->next = results;
-      results = r;
-    }
-  while (ctx);
-  getkey_end (ctrl, ctx);
-
-  if (DBG_LOOKUP)
-    {
-      log_debug ("%s resulted in %d matches.\n", search_terms, count);
-      for (r = results; r; r = r->next)
-        log_debug ("  %s\n",
-                   hexfingerprint (r->keyblock->pkt->pkt.public_key,
-                                   fingerprint, sizeof (fingerprint)));
-    }
-
-  if (! results && gpg_err_code (err) == GPG_ERR_NOT_FOUND)
-    { /* No match.  */
-      if (DBG_LOOKUP)
-        log_debug ("%s: '%s' not found.\n", __func__, search_terms);
-
-      log_info (_("key \"%s\" not found\n"), search_terms);
-      if (!opt.quiet && source)
-        log_info (_("(check argument of option '%s')\n"), source);
-
-      goto leave;
-    }
-  else if (gpg_err_code (err) == GPG_ERR_NOT_FOUND)
-    ; /* No more matches.  */
-  else if (err)
-    { /* Some other error.  An error message was already printed out.
-       * Free RESULTS and continue.  */
-      goto leave;
-    }
-
-  /* Check for duplicates.  */
-  if (DBG_LOOKUP)
-    log_debug ("%s: Checking results of %s='%s' for dups\n",
-               __func__, source ? source : "user input", search_terms);
-  count = 0;
-  for (r = results; r; r = r->next)
-    {
-      pubkey_t *prevp;
-      pubkey_t next;
-      pubkey_t r2;
-      int dups = 0;
-
-      prevp = &r->next;
-      next = r->next;
-      while ((r2 = next))
-        {
-          if (cmp_public_keys (r->keyblock->pkt->pkt.public_key,
-                               r2->keyblock->pkt->pkt.public_key) != 0)
-            { /* Not a dup.  */
-              prevp = &r2->next;
-              next = r2->next;
-              continue;
-            }
-
-          dups ++;
-          count ++;
-
-          /* Remove R2 from the list.  */
-          *prevp = r2->next;
-          release_kbnode (r2->keyblock);
-          next = r2->next;
-          xfree (r2);
-        }
-
-      if (dups)
-        {
-          hexfingerprint (r->keyblock->pkt->pkt.public_key,
-                          fingerprint, sizeof fingerprint);
-          if (! strlist_find (key_dups, fingerprint))
-            {
-              char fingerprint_formatted[MAX_FORMATTED_FINGERPRINT_LEN + 1];
-
-              log_info (_("Warning: %s appears in the keyring %d times\n"),
-                        format_hexfingerprint (fingerprint,
-                                               fingerprint_formatted,
-                                               sizeof fingerprint_formatted),
-                        1 + dups);
-              add_to_strlist (&key_dups, fingerprint);
-            }
-        }
-    }
-
-  if (DBG_LOOKUP && count)
-    {
-      log_debug ("After removing %d dups:\n", count);
-      for (r = results, count = 0; r; r = r->next)
-        log_debug ("  %d: %s\n",
-                   count,
-                   hexfingerprint (r->keyblock->pkt->pkt.public_key,
-                                   fingerprint, sizeof fingerprint));
-    }
-
- leave:
-  if (err)
-    pubkeys_free (results);
-  else
-    *r_keys = results;
-
-  return err;
-}
-
-
 static void
 pk_from_block (PKT_public_key *pk, kbnode_t keyblock, kbnode_t found_key)
 {
diff --git a/g10/keydb.h b/g10/keydb.h
index 7cd628d..6fb4e5e 100644
--- a/g10/keydb.h
+++ b/g10/keydb.h
@@ -341,20 +341,9 @@ struct pubkey_s
 };
 typedef struct pubkey_s *pubkey_t;
 
-/* Free a single key.  This does not remove key from any list!  */
-void pubkey_free (pubkey_t key);
-
 /* Free a list of public keys.  */
 void pubkeys_free (pubkey_t keys);
 
-/* Returns all keys that match the search specification SEARCH_TERMS.
-   The returned keys should be freed using pubkeys_free.  */
-gpg_error_t
-get_pubkeys (ctrl_t ctrl,
-             char *search_terms, int use, int include_unusable, char *source,
-             int warn_possibly_ambiguous,
-             pubkey_t *r_keys);
-
 /* Find a public key identified by NAME.  */
 int get_pubkey_byname (ctrl_t ctrl,
                        GETKEY_CTX *retctx, PKT_public_key *pk,

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

Summary of changes:
 g10/getkey.c | 267 +----------------------------------------------------------
 g10/keydb.h  |  11 ---
 2 files changed, 4 insertions(+), 274 deletions(-)


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




More information about the Gnupg-commits mailing list