mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
Re-indentation of keydb.c and error code changes.
Returning -1 as an error code is not very clean given that gpg error has more descriptive error codes. Thus we now return GPG_ERR_NOT_FOUND for all search operations and adjusted all callers.
This commit is contained in:
parent
740629de00
commit
afe5c1a370
@ -1,3 +1,16 @@
|
|||||||
|
2011-04-29 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* keydb.c (keydb_get_keyblock, keydb_add_resource): Use gpg_error.
|
||||||
|
(keydb_get_keyblock): Return VALUE_NOT_FOUND instead of -1.
|
||||||
|
(keydb_update_keyblock, keydb_insert_keyblock)
|
||||||
|
(keydb_delete_keyblock): Ditto.
|
||||||
|
(keydb_locate_writable): Ditto.
|
||||||
|
(keydb_search_reset): Ditto.
|
||||||
|
(keydb_search2): Return GPG_ERR_NOT_FOUND instead of -1. Change
|
||||||
|
all callers.
|
||||||
|
(keydb_search_first, keydb_search_next, keydb_search_kid)
|
||||||
|
(keydb_search_fpr): Ditto.
|
||||||
|
|
||||||
2011-04-28 Werner Koch <wk@g10code.com>
|
2011-04-28 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* ecdh.c (pk_ecdh_encrypt_with_shared_point): Remove memory leak
|
* ecdh.c (pk_ecdh_encrypt_with_shared_point): Remove memory leak
|
||||||
|
@ -1185,7 +1185,7 @@ do_export_stream (ctrl_t ctrl, iobuf_t out, strlist_t users, int secret,
|
|||||||
iobuf_put (out, ')');
|
iobuf_put (out, ')');
|
||||||
iobuf_put (out, '\n');
|
iobuf_put (out, '\n');
|
||||||
}
|
}
|
||||||
if (err == -1)
|
if (gpg_err_code (err) == GPG_ERR_NOT_FOUND)
|
||||||
err = 0;
|
err = 0;
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
|
10
g10/getkey.c
10
g10/getkey.c
@ -431,7 +431,7 @@ get_pubkey_fast (PKT_public_key * pk, u32 * keyid)
|
|||||||
|
|
||||||
hd = keydb_new ();
|
hd = keydb_new ();
|
||||||
rc = keydb_search_kid (hd, keyid);
|
rc = keydb_search_kid (hd, keyid);
|
||||||
if (rc == -1)
|
if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND)
|
||||||
{
|
{
|
||||||
keydb_release (hd);
|
keydb_release (hd);
|
||||||
return G10ERR_NO_PUBKEY;
|
return G10ERR_NO_PUBKEY;
|
||||||
@ -992,7 +992,7 @@ get_pubkey_byfprint_fast (PKT_public_key * pk,
|
|||||||
|
|
||||||
hd = keydb_new ();
|
hd = keydb_new ();
|
||||||
rc = keydb_search_fpr (hd, fprbuf);
|
rc = keydb_search_fpr (hd, fprbuf);
|
||||||
if (rc == -1)
|
if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND)
|
||||||
{
|
{
|
||||||
keydb_release (hd);
|
keydb_release (hd);
|
||||||
return G10ERR_NO_PUBKEY;
|
return G10ERR_NO_PUBKEY;
|
||||||
@ -2488,7 +2488,7 @@ lookup (getkey_ctx_t ctx, kbnode_t *ret_keyblock, int want_secret)
|
|||||||
}
|
}
|
||||||
|
|
||||||
found:
|
found:
|
||||||
if (rc && rc != -1)
|
if (rc && gpg_err_code (rc) != GPG_ERR_NOT_FOUND)
|
||||||
log_error ("keydb_search failed: %s\n", g10_errstr (rc));
|
log_error ("keydb_search failed: %s\n", g10_errstr (rc));
|
||||||
|
|
||||||
if (!rc)
|
if (!rc)
|
||||||
@ -2496,9 +2496,9 @@ found:
|
|||||||
*ret_keyblock = ctx->keyblock; /* Return the keyblock. */
|
*ret_keyblock = ctx->keyblock; /* Return the keyblock. */
|
||||||
ctx->keyblock = NULL;
|
ctx->keyblock = NULL;
|
||||||
}
|
}
|
||||||
else if (rc == -1 && no_suitable_key)
|
else if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND && no_suitable_key)
|
||||||
rc = want_secret? G10ERR_UNU_SECKEY : G10ERR_UNU_PUBKEY;
|
rc = want_secret? G10ERR_UNU_SECKEY : G10ERR_UNU_PUBKEY;
|
||||||
else if (rc == -1)
|
else if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND)
|
||||||
rc = want_secret? G10ERR_NO_SECKEY : G10ERR_NO_PUBKEY;
|
rc = want_secret? G10ERR_NO_SECKEY : G10ERR_NO_PUBKEY;
|
||||||
|
|
||||||
release_kbnode (ctx->keyblock);
|
release_kbnode (ctx->keyblock);
|
||||||
|
645
g10/keydb.c
645
g10/keydb.c
@ -1,6 +1,6 @@
|
|||||||
/* keydb.c - key database dispatcher
|
/* keydb.c - key database dispatcher
|
||||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005,
|
* Copyright (C) 2001, 2002, 2003, 2004, 2005,
|
||||||
* 2008, 2009 Free Software Foundation, Inc.
|
* 2008, 2009, 2011 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GnuPG.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -39,10 +39,11 @@
|
|||||||
|
|
||||||
static int active_handles;
|
static int active_handles;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
KEYDB_RESOURCE_TYPE_NONE = 0,
|
KEYDB_RESOURCE_TYPE_NONE = 0,
|
||||||
KEYDB_RESOURCE_TYPE_KEYRING
|
KEYDB_RESOURCE_TYPE_KEYRING
|
||||||
} KeydbResourceType;
|
} KeydbResourceType;
|
||||||
#define MAX_KEYDB_RESOURCES 40
|
#define MAX_KEYDB_RESOURCES 40
|
||||||
|
|
||||||
struct resource_item
|
struct resource_item
|
||||||
@ -58,11 +59,12 @@ static struct resource_item all_resources[MAX_KEYDB_RESOURCES];
|
|||||||
static int used_resources;
|
static int used_resources;
|
||||||
static void *primary_keyring=NULL;
|
static void *primary_keyring=NULL;
|
||||||
|
|
||||||
struct keydb_handle {
|
struct keydb_handle
|
||||||
|
{
|
||||||
int locked;
|
int locked;
|
||||||
int found;
|
int found;
|
||||||
int current;
|
int current;
|
||||||
int used; /* items in active */
|
int used; /* Number of items in ACTIVE. */
|
||||||
struct resource_item active[MAX_KEYDB_RESOURCES];
|
struct resource_item active[MAX_KEYDB_RESOURCES];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -212,122 +214,132 @@ maybe_create_keyring (char *filename, int force)
|
|||||||
* Flag 4 - This is a default resources.
|
* Flag 4 - This is a default resources.
|
||||||
* Flag 8 - Open as read-only.
|
* Flag 8 - Open as read-only.
|
||||||
*/
|
*/
|
||||||
int
|
gpg_error_t
|
||||||
keydb_add_resource (const char *url, int flags)
|
keydb_add_resource (const char *url, int flags)
|
||||||
{
|
{
|
||||||
static int any_public;
|
static int any_public;
|
||||||
const char *resname = url;
|
const char *resname = url;
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
int force = (flags&1);
|
int force = (flags&1);
|
||||||
int read_only = !!(flags&8);
|
int read_only = !!(flags&8);
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE;
|
KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE;
|
||||||
void *token;
|
void *token;
|
||||||
|
|
||||||
if (read_only)
|
if (read_only)
|
||||||
force = 0;
|
force = 0;
|
||||||
|
|
||||||
/* Do we have an URL?
|
/* Do we have an URL?
|
||||||
* gnupg-ring:filename := this is a plain keyring
|
* gnupg-ring:filename := this is a plain keyring
|
||||||
* filename := See what is is, but create as plain keyring.
|
* filename := See what is is, but create as plain keyring.
|
||||||
*/
|
*/
|
||||||
if (strlen (resname) > 11) {
|
if (strlen (resname) > 11)
|
||||||
if (!strncmp( resname, "gnupg-ring:", 11) ) {
|
{
|
||||||
rt = KEYDB_RESOURCE_TYPE_KEYRING;
|
if (!strncmp( resname, "gnupg-ring:", 11) )
|
||||||
resname += 11;
|
{
|
||||||
|
rt = KEYDB_RESOURCE_TYPE_KEYRING;
|
||||||
|
resname += 11;
|
||||||
}
|
}
|
||||||
#if !defined(HAVE_DRIVE_LETTERS) && !defined(__riscos__)
|
#if !defined(HAVE_DRIVE_LETTERS) && !defined(__riscos__)
|
||||||
else if (strchr (resname, ':')) {
|
else if (strchr (resname, ':'))
|
||||||
log_error ("invalid key resource URL `%s'\n", url );
|
{
|
||||||
rc = G10ERR_GENERAL;
|
log_error ("invalid key resource URL `%s'\n", url );
|
||||||
goto leave;
|
rc = gpg_error (GPG_ERR_GENERAL);
|
||||||
}
|
goto leave;
|
||||||
|
}
|
||||||
#endif /* !HAVE_DRIVE_LETTERS && !__riscos__ */
|
#endif /* !HAVE_DRIVE_LETTERS && !__riscos__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*resname != DIRSEP_C ) { /* do tilde expansion etc */
|
if (*resname != DIRSEP_C )
|
||||||
if (strchr(resname, DIRSEP_C) )
|
{
|
||||||
filename = make_filename (resname, NULL);
|
/* Do tilde expansion etc. */
|
||||||
else
|
if (strchr(resname, DIRSEP_C) )
|
||||||
filename = make_filename (opt.homedir, resname, NULL);
|
filename = make_filename (resname, NULL);
|
||||||
|
else
|
||||||
|
filename = make_filename (opt.homedir, resname, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
filename = xstrdup (resname);
|
filename = xstrdup (resname);
|
||||||
|
|
||||||
if (!force && !read_only)
|
if (!force && !read_only)
|
||||||
force = !any_public;
|
force = !any_public;
|
||||||
|
|
||||||
/* See whether we can determine the filetype. */
|
/* See whether we can determine the filetype. */
|
||||||
if (rt == KEYDB_RESOURCE_TYPE_NONE) {
|
if (rt == KEYDB_RESOURCE_TYPE_NONE)
|
||||||
FILE *fp = fopen( filename, "rb" );
|
{
|
||||||
|
FILE *fp = fopen (filename, "rb");
|
||||||
|
|
||||||
if (fp) {
|
if (fp)
|
||||||
u32 magic;
|
{
|
||||||
|
u32 magic;
|
||||||
|
|
||||||
if (fread( &magic, 4, 1, fp) == 1 ) {
|
if (fread( &magic, 4, 1, fp) == 1 )
|
||||||
if (magic == 0x13579ace || magic == 0xce9a5713)
|
{
|
||||||
; /* GDBM magic - no more support */
|
if (magic == 0x13579ace || magic == 0xce9a5713)
|
||||||
else
|
; /* GDBM magic - not anymore supported. */
|
||||||
rt = KEYDB_RESOURCE_TYPE_KEYRING;
|
else
|
||||||
|
rt = KEYDB_RESOURCE_TYPE_KEYRING;
|
||||||
}
|
}
|
||||||
else /* maybe empty: assume ring */
|
else /* Maybe empty: assume keyring. */
|
||||||
rt = KEYDB_RESOURCE_TYPE_KEYRING;
|
rt = KEYDB_RESOURCE_TYPE_KEYRING;
|
||||||
fclose( fp );
|
|
||||||
|
fclose( fp );
|
||||||
}
|
}
|
||||||
else /* no file yet: create ring */
|
else /* No file yet: create keyring. */
|
||||||
rt = KEYDB_RESOURCE_TYPE_KEYRING;
|
rt = KEYDB_RESOURCE_TYPE_KEYRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (rt) {
|
switch (rt)
|
||||||
case KEYDB_RESOURCE_TYPE_NONE:
|
{
|
||||||
log_error ("unknown type of key resource `%s'\n", url );
|
case KEYDB_RESOURCE_TYPE_NONE:
|
||||||
rc = G10ERR_GENERAL;
|
log_error ("unknown type of key resource `%s'\n", url );
|
||||||
goto leave;
|
rc = gpg_error (GPG_ERR_GENERAL);
|
||||||
|
goto leave;
|
||||||
|
|
||||||
case KEYDB_RESOURCE_TYPE_KEYRING:
|
case KEYDB_RESOURCE_TYPE_KEYRING:
|
||||||
rc = maybe_create_keyring (filename, force);
|
rc = maybe_create_keyring (filename, force);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
if(keyring_register_filename (filename, read_only, &token))
|
if (keyring_register_filename (filename, read_only, &token))
|
||||||
{
|
{
|
||||||
if (used_resources >= MAX_KEYDB_RESOURCES)
|
if (used_resources >= MAX_KEYDB_RESOURCES)
|
||||||
rc = G10ERR_RESOURCE_LIMIT;
|
rc = gpg_error (GPG_ERR_RESOURCE_LIMIT);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(flags&2)
|
if (flags&2)
|
||||||
primary_keyring=token;
|
primary_keyring = token;
|
||||||
all_resources[used_resources].type = rt;
|
all_resources[used_resources].type = rt;
|
||||||
all_resources[used_resources].u.kr = NULL; /* Not used here */
|
all_resources[used_resources].u.kr = NULL; /* Not used here */
|
||||||
all_resources[used_resources].token = token;
|
all_resources[used_resources].token = token;
|
||||||
used_resources++;
|
used_resources++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* This keyring was already registered, so ignore it.
|
/* This keyring was already registered, so ignore it.
|
||||||
However, we can still mark it as primary even if it was
|
However, we can still mark it as primary even if it was
|
||||||
already registered. */
|
already registered. */
|
||||||
if(flags&2)
|
if (flags&2)
|
||||||
primary_keyring=token;
|
primary_keyring = token;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log_error ("resource type of `%s' not supported\n", url);
|
log_error ("resource type of `%s' not supported\n", url);
|
||||||
rc = G10ERR_GENERAL;
|
rc = gpg_error (GPG_ERR_GENERAL);
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fixme: check directory permissions and print a warning */
|
/* fixme: check directory permissions and print a warning */
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
if (rc)
|
if (rc)
|
||||||
log_error (_("keyblock resource `%s': %s\n"), filename, g10_errstr(rc));
|
log_error (_("keyblock resource `%s': %s\n"), filename, gpg_strerror (rc));
|
||||||
else
|
else
|
||||||
any_public = 1;
|
any_public = 1;
|
||||||
xfree (filename);
|
xfree (filename);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -370,25 +382,27 @@ keydb_new (void)
|
|||||||
void
|
void
|
||||||
keydb_release (KEYDB_HANDLE hd)
|
keydb_release (KEYDB_HANDLE hd)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!hd)
|
if (!hd)
|
||||||
return;
|
return;
|
||||||
assert (active_handles > 0);
|
assert (active_handles > 0);
|
||||||
active_handles--;
|
active_handles--;
|
||||||
|
|
||||||
unlock_all (hd);
|
unlock_all (hd);
|
||||||
for (i=0; i < hd->used; i++) {
|
for (i=0; i < hd->used; i++)
|
||||||
switch (hd->active[i].type) {
|
{
|
||||||
case KEYDB_RESOURCE_TYPE_NONE:
|
switch (hd->active[i].type)
|
||||||
break;
|
{
|
||||||
case KEYDB_RESOURCE_TYPE_KEYRING:
|
case KEYDB_RESOURCE_TYPE_NONE:
|
||||||
keyring_release (hd->active[i].u.kr);
|
break;
|
||||||
break;
|
case KEYDB_RESOURCE_TYPE_KEYRING:
|
||||||
|
keyring_release (hd->active[i].u.kr);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree (hd);
|
xfree (hd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -403,29 +417,30 @@ keydb_release (KEYDB_HANDLE hd)
|
|||||||
const char *
|
const char *
|
||||||
keydb_get_resource_name (KEYDB_HANDLE hd)
|
keydb_get_resource_name (KEYDB_HANDLE hd)
|
||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
const char *s = NULL;
|
const char *s = NULL;
|
||||||
|
|
||||||
if (!hd)
|
if (!hd)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ( hd->found >= 0 && hd->found < hd->used)
|
if ( hd->found >= 0 && hd->found < hd->used)
|
||||||
idx = hd->found;
|
idx = hd->found;
|
||||||
else if ( hd->current >= 0 && hd->current < hd->used)
|
else if ( hd->current >= 0 && hd->current < hd->used)
|
||||||
idx = hd->current;
|
idx = hd->current;
|
||||||
else
|
else
|
||||||
idx = 0;
|
idx = 0;
|
||||||
|
|
||||||
switch (hd->active[idx].type) {
|
switch (hd->active[idx].type)
|
||||||
case KEYDB_RESOURCE_TYPE_NONE:
|
{
|
||||||
s = NULL;
|
case KEYDB_RESOURCE_TYPE_NONE:
|
||||||
break;
|
s = NULL;
|
||||||
case KEYDB_RESOURCE_TYPE_KEYRING:
|
break;
|
||||||
s = keyring_get_resource_name (hd->active[idx].u.kr);
|
case KEYDB_RESOURCE_TYPE_KEYRING:
|
||||||
break;
|
s = keyring_get_resource_name (hd->active[idx].u.kr);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return s? s: "";
|
return s? s: "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -433,54 +448,62 @@ keydb_get_resource_name (KEYDB_HANDLE hd)
|
|||||||
static int
|
static int
|
||||||
lock_all (KEYDB_HANDLE hd)
|
lock_all (KEYDB_HANDLE hd)
|
||||||
{
|
{
|
||||||
int i, rc = 0;
|
int i, rc = 0;
|
||||||
|
|
||||||
for (i=0; !rc && i < hd->used; i++) {
|
for (i=0; !rc && i < hd->used; i++)
|
||||||
switch (hd->active[i].type) {
|
{
|
||||||
case KEYDB_RESOURCE_TYPE_NONE:
|
switch (hd->active[i].type)
|
||||||
break;
|
{
|
||||||
case KEYDB_RESOURCE_TYPE_KEYRING:
|
case KEYDB_RESOURCE_TYPE_NONE:
|
||||||
rc = keyring_lock (hd->active[i].u.kr, 1);
|
break;
|
||||||
break;
|
case KEYDB_RESOURCE_TYPE_KEYRING:
|
||||||
|
rc = keyring_lock (hd->active[i].u.kr, 1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc) {
|
if (rc)
|
||||||
/* revert the already set locks */
|
{
|
||||||
for (i--; i >= 0; i--) {
|
/* Revert the already set locks. */
|
||||||
switch (hd->active[i].type) {
|
for (i--; i >= 0; i--)
|
||||||
case KEYDB_RESOURCE_TYPE_NONE:
|
{
|
||||||
break;
|
switch (hd->active[i].type)
|
||||||
case KEYDB_RESOURCE_TYPE_KEYRING:
|
{
|
||||||
keyring_lock (hd->active[i].u.kr, 0);
|
case KEYDB_RESOURCE_TYPE_NONE:
|
||||||
break;
|
break;
|
||||||
|
case KEYDB_RESOURCE_TYPE_KEYRING:
|
||||||
|
keyring_lock (hd->active[i].u.kr, 0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
hd->locked = 1;
|
hd->locked = 1;
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unlock_all (KEYDB_HANDLE hd)
|
unlock_all (KEYDB_HANDLE hd)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!hd->locked)
|
if (!hd->locked)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i=hd->used-1; i >= 0; i--) {
|
for (i=hd->used-1; i >= 0; i--)
|
||||||
switch (hd->active[i].type) {
|
{
|
||||||
case KEYDB_RESOURCE_TYPE_NONE:
|
switch (hd->active[i].type)
|
||||||
break;
|
{
|
||||||
case KEYDB_RESOURCE_TYPE_KEYRING:
|
case KEYDB_RESOURCE_TYPE_NONE:
|
||||||
keyring_lock (hd->active[i].u.kr, 0);
|
break;
|
||||||
break;
|
case KEYDB_RESOURCE_TYPE_KEYRING:
|
||||||
|
keyring_lock (hd->active[i].u.kr, 0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hd->locked = 0;
|
hd->locked = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -490,148 +513,153 @@ unlock_all (KEYDB_HANDLE hd)
|
|||||||
* the public key used to locate the keyblock or flag bit 1 set for
|
* the public key used to locate the keyblock or flag bit 1 set for
|
||||||
* the user ID node.
|
* the user ID node.
|
||||||
*/
|
*/
|
||||||
int
|
gpg_error_t
|
||||||
keydb_get_keyblock (KEYDB_HANDLE hd, KBNODE *ret_kb)
|
keydb_get_keyblock (KEYDB_HANDLE hd, KBNODE *ret_kb)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
gpg_error_t err = 0;
|
||||||
|
|
||||||
if (!hd)
|
if (!hd)
|
||||||
return G10ERR_INV_ARG;
|
return gpg_error (GPG_ERR_INV_ARG);
|
||||||
|
|
||||||
if ( hd->found < 0 || hd->found >= hd->used)
|
if (hd->found < 0 || hd->found >= hd->used)
|
||||||
return -1; /* nothing found */
|
return gpg_error (GPG_ERR_VALUE_NOT_FOUND);
|
||||||
|
|
||||||
switch (hd->active[hd->found].type) {
|
switch (hd->active[hd->found].type)
|
||||||
case KEYDB_RESOURCE_TYPE_NONE:
|
{
|
||||||
rc = G10ERR_GENERAL; /* oops */
|
case KEYDB_RESOURCE_TYPE_NONE:
|
||||||
break;
|
err = gpg_error (GPG_ERR_GENERAL); /* oops */
|
||||||
case KEYDB_RESOURCE_TYPE_KEYRING:
|
break;
|
||||||
rc = keyring_get_keyblock (hd->active[hd->found].u.kr, ret_kb);
|
case KEYDB_RESOURCE_TYPE_KEYRING:
|
||||||
break;
|
err = keyring_get_keyblock (hd->active[hd->found].u.kr, ret_kb);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* update the current keyblock with KB
|
* Update the current keyblock with the keyblock KB
|
||||||
*/
|
*/
|
||||||
int
|
gpg_error_t
|
||||||
keydb_update_keyblock (KEYDB_HANDLE hd, KBNODE kb)
|
keydb_update_keyblock (KEYDB_HANDLE hd, kbnode_t kb)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
gpg_error_t rc;
|
||||||
|
|
||||||
if (!hd)
|
if (!hd)
|
||||||
return G10ERR_INV_ARG;
|
return gpg_error (GPG_ERR_INV_ARG);
|
||||||
|
|
||||||
if ( hd->found < 0 || hd->found >= hd->used)
|
if (hd->found < 0 || hd->found >= hd->used)
|
||||||
return -1; /* nothing found */
|
return gpg_error (GPG_ERR_VALUE_NOT_FOUND);
|
||||||
|
|
||||||
if( opt.dry_run )
|
if (opt.dry_run)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rc = lock_all (hd);
|
rc = lock_all (hd);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
switch (hd->active[hd->found].type) {
|
switch (hd->active[hd->found].type)
|
||||||
case KEYDB_RESOURCE_TYPE_NONE:
|
{
|
||||||
rc = G10ERR_GENERAL; /* oops */
|
case KEYDB_RESOURCE_TYPE_NONE:
|
||||||
break;
|
rc = gpg_error (GPG_ERR_GENERAL); /* oops */
|
||||||
case KEYDB_RESOURCE_TYPE_KEYRING:
|
break;
|
||||||
rc = keyring_update_keyblock (hd->active[hd->found].u.kr, kb);
|
case KEYDB_RESOURCE_TYPE_KEYRING:
|
||||||
break;
|
rc = keyring_update_keyblock (hd->active[hd->found].u.kr, kb);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock_all (hd);
|
unlock_all (hd);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Insert a new KB into one of the resources.
|
* Insert a new KB into one of the resources.
|
||||||
*/
|
*/
|
||||||
int
|
gpg_error_t
|
||||||
keydb_insert_keyblock (KEYDB_HANDLE hd, KBNODE kb)
|
keydb_insert_keyblock (KEYDB_HANDLE hd, kbnode_t kb)
|
||||||
{
|
{
|
||||||
int rc = -1;
|
int rc;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
if (!hd)
|
if (!hd)
|
||||||
return G10ERR_INV_ARG;
|
return gpg_error (GPG_ERR_INV_ARG);
|
||||||
|
|
||||||
if( opt.dry_run )
|
if (opt.dry_run)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ( hd->found >= 0 && hd->found < hd->used)
|
if (hd->found >= 0 && hd->found < hd->used)
|
||||||
idx = hd->found;
|
idx = hd->found;
|
||||||
else if ( hd->current >= 0 && hd->current < hd->used)
|
else if (hd->current >= 0 && hd->current < hd->used)
|
||||||
idx = hd->current;
|
idx = hd->current;
|
||||||
else
|
else
|
||||||
return G10ERR_GENERAL;
|
return gpg_error (GPG_ERR_GENERAL);
|
||||||
|
|
||||||
rc = lock_all (hd);
|
rc = lock_all (hd);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
switch (hd->active[idx].type) {
|
switch (hd->active[idx].type)
|
||||||
case KEYDB_RESOURCE_TYPE_NONE:
|
{
|
||||||
rc = G10ERR_GENERAL; /* oops */
|
case KEYDB_RESOURCE_TYPE_NONE:
|
||||||
break;
|
rc = gpg_error (GPG_ERR_GENERAL); /* oops */
|
||||||
case KEYDB_RESOURCE_TYPE_KEYRING:
|
break;
|
||||||
rc = keyring_insert_keyblock (hd->active[idx].u.kr, kb);
|
case KEYDB_RESOURCE_TYPE_KEYRING:
|
||||||
break;
|
rc = keyring_insert_keyblock (hd->active[idx].u.kr, kb);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock_all (hd);
|
unlock_all (hd);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The current keyblock will be deleted.
|
* Delete the current keyblock.
|
||||||
*/
|
*/
|
||||||
int
|
gpg_error_t
|
||||||
keydb_delete_keyblock (KEYDB_HANDLE hd)
|
keydb_delete_keyblock (KEYDB_HANDLE hd)
|
||||||
{
|
{
|
||||||
int rc = -1;
|
gpg_error_t rc;
|
||||||
|
|
||||||
if (!hd)
|
if (!hd)
|
||||||
return G10ERR_INV_ARG;
|
return gpg_error (GPG_ERR_INV_ARG);
|
||||||
|
|
||||||
if ( hd->found < 0 || hd->found >= hd->used)
|
if (hd->found < 0 || hd->found >= hd->used)
|
||||||
return -1; /* nothing found */
|
return gpg_error (GPG_ERR_VALUE_NOT_FOUND);
|
||||||
|
|
||||||
if( opt.dry_run )
|
if (opt.dry_run)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rc = lock_all (hd);
|
rc = lock_all (hd);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
switch (hd->active[hd->found].type) {
|
switch (hd->active[hd->found].type)
|
||||||
case KEYDB_RESOURCE_TYPE_NONE:
|
{
|
||||||
rc = G10ERR_GENERAL; /* oops */
|
case KEYDB_RESOURCE_TYPE_NONE:
|
||||||
break;
|
rc = gpg_error (GPG_ERR_GENERAL);
|
||||||
case KEYDB_RESOURCE_TYPE_KEYRING:
|
break;
|
||||||
rc = keyring_delete_keyblock (hd->active[hd->found].u.kr);
|
case KEYDB_RESOURCE_TYPE_KEYRING:
|
||||||
break;
|
rc = keyring_delete_keyblock (hd->active[hd->found].u.kr);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock_all (hd);
|
unlock_all (hd);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Locate the default writable key resource, so that the next
|
* Locate the default writable key resource, so that the next
|
||||||
* operation (which is only relevant for inserts) will be done on this
|
* operation (which is only relevant for inserts) will be done on this
|
||||||
* resource.
|
* resource.
|
||||||
*/
|
*/
|
||||||
int
|
gpg_error_t
|
||||||
keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved)
|
keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved)
|
||||||
{
|
{
|
||||||
int rc;
|
gpg_error_t rc;
|
||||||
|
|
||||||
(void)reserved;
|
(void)reserved;
|
||||||
|
|
||||||
@ -643,7 +671,7 @@ keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved)
|
|||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* If we have a primary set, try that one first */
|
/* If we have a primary set, try that one first */
|
||||||
if(primary_keyring)
|
if (primary_keyring)
|
||||||
{
|
{
|
||||||
for ( ; hd->current >= 0 && hd->current < hd->used; hd->current++)
|
for ( ; hd->current >= 0 && hd->current < hd->used; hd->current++)
|
||||||
{
|
{
|
||||||
@ -675,7 +703,7 @@ keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return gpg_error (GPG_ERR_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -709,101 +737,116 @@ keydb_rebuild_caches (int noisy)
|
|||||||
/*
|
/*
|
||||||
* Start the next search on this handle right at the beginning
|
* Start the next search on this handle right at the beginning
|
||||||
*/
|
*/
|
||||||
int
|
gpg_error_t
|
||||||
keydb_search_reset (KEYDB_HANDLE hd)
|
keydb_search_reset (KEYDB_HANDLE hd)
|
||||||
{
|
{
|
||||||
int i, rc = 0;
|
gpg_error_t rc = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (!hd)
|
if (!hd)
|
||||||
return G10ERR_INV_ARG;
|
return gpg_error (GPG_ERR_INV_ARG);
|
||||||
|
|
||||||
hd->current = 0;
|
hd->current = 0;
|
||||||
hd->found = -1;
|
hd->found = -1;
|
||||||
/* and reset all resources */
|
/* Now reset all resources. */
|
||||||
for (i=0; !rc && i < hd->used; i++) {
|
for (i=0; !rc && i < hd->used; i++)
|
||||||
switch (hd->active[i].type) {
|
{
|
||||||
case KEYDB_RESOURCE_TYPE_NONE:
|
switch (hd->active[i].type)
|
||||||
break;
|
{
|
||||||
case KEYDB_RESOURCE_TYPE_KEYRING:
|
case KEYDB_RESOURCE_TYPE_NONE:
|
||||||
rc = keyring_search_reset (hd->active[i].u.kr);
|
break;
|
||||||
break;
|
case KEYDB_RESOURCE_TYPE_KEYRING:
|
||||||
|
rc = keyring_search_reset (hd->active[i].u.kr);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Search through all keydb resources, starting at the current position,
|
* Search through all keydb resources, starting at the current
|
||||||
* for a keyblock which contains one of the keys described in the DESC array.
|
* position, for a keyblock which contains one of the keys described
|
||||||
|
* in the DESC array. Returns GPG_ERR_NOT_FOUND if no matching
|
||||||
|
* keyring was found.
|
||||||
*/
|
*/
|
||||||
int
|
gpg_error_t
|
||||||
keydb_search2 (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc,
|
keydb_search2 (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc,
|
||||||
size_t ndesc, size_t *descindex)
|
size_t ndesc, size_t *descindex)
|
||||||
{
|
{
|
||||||
int rc = -1;
|
gpg_error_t rc;
|
||||||
|
|
||||||
if (!hd)
|
if (!hd)
|
||||||
return G10ERR_INV_ARG;
|
return gpg_error (GPG_ERR_INV_ARG);
|
||||||
|
|
||||||
while (rc == -1 && hd->current >= 0 && hd->current < hd->used) {
|
rc = -1;
|
||||||
switch (hd->active[hd->current].type) {
|
while ((rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF)
|
||||||
case KEYDB_RESOURCE_TYPE_NONE:
|
&& hd->current >= 0 && hd->current < hd->used)
|
||||||
BUG(); /* we should never see it here */
|
{
|
||||||
break;
|
switch (hd->active[hd->current].type)
|
||||||
case KEYDB_RESOURCE_TYPE_KEYRING:
|
{
|
||||||
rc = keyring_search (hd->active[hd->current].u.kr, desc,
|
case KEYDB_RESOURCE_TYPE_NONE:
|
||||||
ndesc, descindex);
|
BUG(); /* we should never see it here */
|
||||||
break;
|
break;
|
||||||
|
case KEYDB_RESOURCE_TYPE_KEYRING:
|
||||||
|
rc = keyring_search (hd->active[hd->current].u.kr, desc,
|
||||||
|
ndesc, descindex);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (rc == -1) /* EOF -> switch to next resource */
|
if (rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF)
|
||||||
hd->current++;
|
{
|
||||||
else if (!rc)
|
/* EOF -> switch to next resource */
|
||||||
hd->found = hd->current;
|
hd->current++;
|
||||||
|
}
|
||||||
|
else if (!rc)
|
||||||
|
hd->found = hd->current;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return ((rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF)
|
||||||
|
? gpg_error (GPG_ERR_NOT_FOUND)
|
||||||
|
: rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
|
gpg_error_t
|
||||||
keydb_search_first (KEYDB_HANDLE hd)
|
keydb_search_first (KEYDB_HANDLE hd)
|
||||||
{
|
{
|
||||||
KEYDB_SEARCH_DESC desc;
|
KEYDB_SEARCH_DESC desc;
|
||||||
|
|
||||||
memset (&desc, 0, sizeof desc);
|
memset (&desc, 0, sizeof desc);
|
||||||
desc.mode = KEYDB_SEARCH_MODE_FIRST;
|
desc.mode = KEYDB_SEARCH_MODE_FIRST;
|
||||||
return keydb_search (hd, &desc, 1);
|
return keydb_search (hd, &desc, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
gpg_error_t
|
||||||
keydb_search_next (KEYDB_HANDLE hd)
|
keydb_search_next (KEYDB_HANDLE hd)
|
||||||
{
|
{
|
||||||
KEYDB_SEARCH_DESC desc;
|
KEYDB_SEARCH_DESC desc;
|
||||||
|
|
||||||
memset (&desc, 0, sizeof desc);
|
memset (&desc, 0, sizeof desc);
|
||||||
desc.mode = KEYDB_SEARCH_MODE_NEXT;
|
desc.mode = KEYDB_SEARCH_MODE_NEXT;
|
||||||
return keydb_search (hd, &desc, 1);
|
return keydb_search (hd, &desc, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
gpg_error_t
|
||||||
keydb_search_kid (KEYDB_HANDLE hd, u32 *kid)
|
keydb_search_kid (KEYDB_HANDLE hd, u32 *kid)
|
||||||
{
|
{
|
||||||
KEYDB_SEARCH_DESC desc;
|
KEYDB_SEARCH_DESC desc;
|
||||||
|
|
||||||
memset (&desc, 0, sizeof desc);
|
memset (&desc, 0, sizeof desc);
|
||||||
desc.mode = KEYDB_SEARCH_MODE_LONG_KID;
|
desc.mode = KEYDB_SEARCH_MODE_LONG_KID;
|
||||||
desc.u.kid[0] = kid[0];
|
desc.u.kid[0] = kid[0];
|
||||||
desc.u.kid[1] = kid[1];
|
desc.u.kid[1] = kid[1];
|
||||||
return keydb_search (hd, &desc, 1);
|
return keydb_search (hd, &desc, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
gpg_error_t
|
||||||
keydb_search_fpr (KEYDB_HANDLE hd, const byte *fpr)
|
keydb_search_fpr (KEYDB_HANDLE hd, const byte *fpr)
|
||||||
{
|
{
|
||||||
KEYDB_SEARCH_DESC desc;
|
KEYDB_SEARCH_DESC desc;
|
||||||
|
|
||||||
memset (&desc, 0, sizeof desc);
|
memset (&desc, 0, sizeof desc);
|
||||||
desc.mode = KEYDB_SEARCH_MODE_FPR;
|
desc.mode = KEYDB_SEARCH_MODE_FPR;
|
||||||
memcpy (desc.u.fpr, fpr, MAX_FINGERPRINT_LEN);
|
memcpy (desc.u.fpr, fpr, MAX_FINGERPRINT_LEN);
|
||||||
return keydb_search (hd, &desc, 1);
|
return keydb_search (hd, &desc, 1);
|
||||||
}
|
}
|
||||||
|
27
g10/keydb.h
27
g10/keydb.h
@ -132,25 +132,24 @@ union pref_hint
|
|||||||
Flag 1 == force
|
Flag 1 == force
|
||||||
Flag 2 == default
|
Flag 2 == default
|
||||||
*/
|
*/
|
||||||
int keydb_add_resource (const char *url, int flags);
|
gpg_error_t keydb_add_resource (const char *url, int flags);
|
||||||
KEYDB_HANDLE keydb_new (void);
|
KEYDB_HANDLE keydb_new (void);
|
||||||
void keydb_release (KEYDB_HANDLE hd);
|
void keydb_release (KEYDB_HANDLE hd);
|
||||||
const char *keydb_get_resource_name (KEYDB_HANDLE hd);
|
const char *keydb_get_resource_name (KEYDB_HANDLE hd);
|
||||||
int keydb_get_keyblock (KEYDB_HANDLE hd, KBNODE *ret_kb);
|
gpg_error_t keydb_get_keyblock (KEYDB_HANDLE hd, KBNODE *ret_kb);
|
||||||
int keydb_update_keyblock (KEYDB_HANDLE hd, KBNODE kb);
|
gpg_error_t keydb_update_keyblock (KEYDB_HANDLE hd, kbnode_t kb);
|
||||||
int keydb_insert_keyblock (KEYDB_HANDLE hd, KBNODE kb);
|
gpg_error_t keydb_insert_keyblock (KEYDB_HANDLE hd, kbnode_t kb);
|
||||||
int keydb_delete_keyblock (KEYDB_HANDLE hd);
|
gpg_error_t keydb_delete_keyblock (KEYDB_HANDLE hd);
|
||||||
int keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved);
|
gpg_error_t keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved);
|
||||||
void keydb_rebuild_caches (int noisy);
|
void keydb_rebuild_caches (int noisy);
|
||||||
int keydb_search_reset (KEYDB_HANDLE hd);
|
gpg_error_t keydb_search_reset (KEYDB_HANDLE hd);
|
||||||
#define keydb_search(a,b,c) keydb_search2((a),(b),(c),NULL)
|
#define keydb_search(a,b,c) keydb_search2((a),(b),(c),NULL)
|
||||||
int keydb_search2 (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc,
|
gpg_error_t keydb_search2 (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc,
|
||||||
size_t ndesc, size_t *descindex);
|
size_t ndesc, size_t *descindex);
|
||||||
int keydb_search_first (KEYDB_HANDLE hd);
|
gpg_error_t keydb_search_first (KEYDB_HANDLE hd);
|
||||||
int keydb_search_next (KEYDB_HANDLE hd);
|
gpg_error_t keydb_search_next (KEYDB_HANDLE hd);
|
||||||
int keydb_search_kid (KEYDB_HANDLE hd, u32 *kid);
|
gpg_error_t keydb_search_kid (KEYDB_HANDLE hd, u32 *kid);
|
||||||
int keydb_search_fpr (KEYDB_HANDLE hd, const byte *fpr);
|
gpg_error_t keydb_search_fpr (KEYDB_HANDLE hd, const byte *fpr);
|
||||||
|
|
||||||
|
|
||||||
/*-- pkclist.c --*/
|
/*-- pkclist.c --*/
|
||||||
void show_revocation_reason( PKT_public_key *pk, int mode );
|
void show_revocation_reason( PKT_public_key *pk, int mode );
|
||||||
|
@ -434,12 +434,12 @@ list_all (int secret)
|
|||||||
|
|
||||||
hd = keydb_new ();
|
hd = keydb_new ();
|
||||||
if (!hd)
|
if (!hd)
|
||||||
rc = G10ERR_GENERAL;
|
rc = gpg_error (GPG_ERR_GENERAL);
|
||||||
else
|
else
|
||||||
rc = keydb_search_first (hd);
|
rc = keydb_search_first (hd);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
if (rc != -1)
|
if (gpg_err_code (rc) != GPG_ERR_NOT_FOUND)
|
||||||
log_error ("keydb_search_first failed: %s\n", g10_errstr (rc));
|
log_error ("keydb_search_first failed: %s\n", g10_errstr (rc));
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
@ -479,7 +479,7 @@ list_all (int secret)
|
|||||||
keyblock = NULL;
|
keyblock = NULL;
|
||||||
}
|
}
|
||||||
while (!(rc = keydb_search_next (hd)));
|
while (!(rc = keydb_search_next (hd)));
|
||||||
if (rc && rc != -1)
|
if (rc && gpg_err_code (rc) != GPG_ERR_NOT_FOUND)
|
||||||
log_error ("keydb_search_next failed: %s\n", g10_errstr (rc));
|
log_error ("keydb_search_next failed: %s\n", g10_errstr (rc));
|
||||||
|
|
||||||
if (opt.check_sigs && !opt.with_colons)
|
if (opt.check_sigs && !opt.with_colons)
|
||||||
|
@ -1236,8 +1236,8 @@ keyidlist(strlist_t users,KEYDB_SEARCH_DESC **klist,int *count,int fakev3)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rc==-1)
|
if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND)
|
||||||
rc=0;
|
rc = 0;
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
if(rc)
|
if(rc)
|
||||||
|
@ -2107,7 +2107,7 @@ validate_key_list (KEYDB_HANDLE hd, KeyHashTable full_trust,
|
|||||||
desc.skipfnc = search_skipfnc;
|
desc.skipfnc = search_skipfnc;
|
||||||
desc.skipfncvalue = full_trust;
|
desc.skipfncvalue = full_trust;
|
||||||
rc = keydb_search (hd, &desc, 1);
|
rc = keydb_search (hd, &desc, 1);
|
||||||
if (rc == -1)
|
if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND)
|
||||||
{
|
{
|
||||||
keys[nkeys].keyblock = NULL;
|
keys[nkeys].keyblock = NULL;
|
||||||
return keys;
|
return keys;
|
||||||
@ -2181,7 +2181,7 @@ validate_key_list (KEYDB_HANDLE hd, KeyHashTable full_trust,
|
|||||||
keyblock = NULL;
|
keyblock = NULL;
|
||||||
}
|
}
|
||||||
while ( !(rc = keydb_search (hd, &desc, 1)) );
|
while ( !(rc = keydb_search (hd, &desc, 1)) );
|
||||||
if (rc && rc != -1)
|
if (rc && gpg_err_code (rc) != GPG_ERR_NOT_FOUND)
|
||||||
{
|
{
|
||||||
log_error ("keydb_search_next failed: %s\n", g10_errstr(rc));
|
log_error ("keydb_search_next failed: %s\n", g10_errstr(rc));
|
||||||
xfree (keys);
|
xfree (keys);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user