mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-21 14:47:03 +01:00
* keydb.h, keyring.c (keyring_search), trustdb.c (search_skipfnc): Expand
the skipfnc to include a pointer to the user ID that matched. * getkey.c (skip_disabled): Rename to skip_unusable, and add checks for expired or revoked user IDs.
This commit is contained in:
parent
b224756fbe
commit
4ccd51cb50
@ -1,3 +1,12 @@
|
|||||||
|
2003-09-23 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* keydb.h, keyring.c (keyring_search), trustdb.c (search_skipfnc):
|
||||||
|
Expand the skipfnc to include a pointer to the user ID that
|
||||||
|
matched.
|
||||||
|
|
||||||
|
* getkey.c (skip_disabled): Rename to skip_unusable, and add
|
||||||
|
checks for expired or revoked user IDs.
|
||||||
|
|
||||||
2003-09-22 David Shaw <dshaw@jabberwocky.com>
|
2003-09-22 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* g10.c (main): Deprecate --default-comment in favor of
|
* g10.c (main): Deprecate --default-comment in favor of
|
||||||
|
52
g10/getkey.c
52
g10/getkey.c
@ -726,24 +726,44 @@ classify_user_id( const char *name, KEYDB_SEARCH_DESC *desc )
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
skip_disabled(void *dummy,u32 *keyid)
|
skip_unusable(void *dummy,u32 *keyid,PKT_user_id *uid)
|
||||||
{
|
{
|
||||||
int rc,disabled=0;
|
int unusable=0;
|
||||||
PKT_public_key *pk=m_alloc_clear(sizeof(PKT_public_key));
|
KBNODE keyblock;
|
||||||
|
|
||||||
rc = get_pubkey(pk, keyid);
|
keyblock=get_pubkeyblock(keyid);
|
||||||
if(rc)
|
if(!keyblock)
|
||||||
{
|
{
|
||||||
log_error("error checking disabled status of %08lX: %s\n",
|
log_error("error checking usability status of %08lX\n",(ulong)keyid[1]);
|
||||||
(ulong)keyid[1],g10_errstr(rc));
|
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
disabled=pk_is_disabled(pk);
|
/* Is the user ID in question revoked/expired? */
|
||||||
|
if(uid)
|
||||||
|
{
|
||||||
|
KBNODE node;
|
||||||
|
|
||||||
|
for(node=keyblock;node;node=node->next)
|
||||||
|
{
|
||||||
|
if(node->pkt->pkttype==PKT_USER_ID)
|
||||||
|
{
|
||||||
|
if(cmp_user_ids(uid,node->pkt->pkt.user_id)==0
|
||||||
|
&& (node->pkt->pkt.user_id->is_revoked
|
||||||
|
|| node->pkt->pkt.user_id->is_expired))
|
||||||
|
{
|
||||||
|
unusable=1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!unusable)
|
||||||
|
unusable=pk_is_disabled(keyblock->pkt->pkt.public_key);
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
free_public_key(pk);
|
release_kbnode(keyblock);
|
||||||
return disabled;
|
return unusable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
@ -758,7 +778,7 @@ skip_disabled(void *dummy,u32 *keyid)
|
|||||||
static int
|
static int
|
||||||
key_byname( GETKEY_CTX *retctx, STRLIST namelist,
|
key_byname( GETKEY_CTX *retctx, STRLIST namelist,
|
||||||
PKT_public_key *pk, PKT_secret_key *sk,
|
PKT_public_key *pk, PKT_secret_key *sk,
|
||||||
int secmode, int include_disabled,
|
int secmode, int include_unusable,
|
||||||
KBNODE *ret_kb, KEYDB_HANDLE *ret_kdbhd )
|
KBNODE *ret_kb, KEYDB_HANDLE *ret_kdbhd )
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
@ -790,13 +810,13 @@ key_byname( GETKEY_CTX *retctx, STRLIST namelist,
|
|||||||
m_free (ctx);
|
m_free (ctx);
|
||||||
return G10ERR_INV_USER_ID;
|
return G10ERR_INV_USER_ID;
|
||||||
}
|
}
|
||||||
if(!include_disabled
|
if(!include_unusable
|
||||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_SHORT_KID
|
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_SHORT_KID
|
||||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_LONG_KID
|
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_LONG_KID
|
||||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR16
|
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR16
|
||||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR20
|
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR20
|
||||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR)
|
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR)
|
||||||
ctx->items[n].skipfnc=skip_disabled;
|
ctx->items[n].skipfnc=skip_unusable;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->kr_handle = keydb_new (secmode);
|
ctx->kr_handle = keydb_new (secmode);
|
||||||
@ -847,14 +867,14 @@ key_byname( GETKEY_CTX *retctx, STRLIST namelist,
|
|||||||
int
|
int
|
||||||
get_pubkey_byname (PKT_public_key *pk,
|
get_pubkey_byname (PKT_public_key *pk,
|
||||||
const char *name, KBNODE *ret_keyblock,
|
const char *name, KBNODE *ret_keyblock,
|
||||||
KEYDB_HANDLE *ret_kdbhd, int include_disabled )
|
KEYDB_HANDLE *ret_kdbhd, int include_unusable )
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
STRLIST namelist = NULL;
|
STRLIST namelist = NULL;
|
||||||
|
|
||||||
add_to_strlist( &namelist, name );
|
add_to_strlist( &namelist, name );
|
||||||
rc = key_byname( NULL, namelist, pk, NULL, 0,
|
rc = key_byname( NULL, namelist, pk, NULL, 0,
|
||||||
include_disabled, ret_keyblock, ret_kdbhd);
|
include_unusable, ret_keyblock, ret_kdbhd);
|
||||||
free_strlist( namelist );
|
free_strlist( namelist );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ typedef enum {
|
|||||||
|
|
||||||
struct keydb_search_desc {
|
struct keydb_search_desc {
|
||||||
KeydbSearchMode mode;
|
KeydbSearchMode mode;
|
||||||
int (*skipfnc)(void *,u32*);
|
int (*skipfnc)(void *,u32*,PKT_user_id*);
|
||||||
void *skipfncvalue;
|
void *skipfncvalue;
|
||||||
union {
|
union {
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -201,7 +201,7 @@ int get_pubkey_fast ( PKT_public_key *pk, u32 *keyid );
|
|||||||
KBNODE get_pubkeyblock( u32 *keyid );
|
KBNODE get_pubkeyblock( u32 *keyid );
|
||||||
int get_pubkey_byname( PKT_public_key *pk, const char *name,
|
int get_pubkey_byname( PKT_public_key *pk, const char *name,
|
||||||
KBNODE *ret_keyblock, KEYDB_HANDLE *ret_kdbhd,
|
KBNODE *ret_keyblock, KEYDB_HANDLE *ret_kdbhd,
|
||||||
int include_disabled );
|
int include_unusable );
|
||||||
int get_pubkey_bynames( GETKEY_CTX *rx, PKT_public_key *pk,
|
int get_pubkey_bynames( GETKEY_CTX *rx, PKT_public_key *pk,
|
||||||
STRLIST names, KBNODE *ret_keyblock );
|
STRLIST names, KBNODE *ret_keyblock );
|
||||||
int get_pubkey_next( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE *ret_keyblock );
|
int get_pubkey_next( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE *ret_keyblock );
|
||||||
|
@ -1083,7 +1083,7 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
|
|||||||
for (n=any_skip?0:ndesc; n < ndesc; n++)
|
for (n=any_skip?0:ndesc; n < ndesc; n++)
|
||||||
{
|
{
|
||||||
if (desc[n].skipfnc
|
if (desc[n].skipfnc
|
||||||
&& desc[n].skipfnc (desc[n].skipfncvalue, aki))
|
&& desc[n].skipfnc (desc[n].skipfncvalue, aki, uid))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (n == ndesc)
|
if (n == ndesc)
|
||||||
|
@ -1714,7 +1714,7 @@ validate_one_keyblock (KBNODE kb, struct key_item *klist,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
search_skipfnc (void *opaque, u32 *kid)
|
search_skipfnc (void *opaque, u32 *kid, PKT_user_id *dummy)
|
||||||
{
|
{
|
||||||
return test_key_hash_table ((KeyHashTable)opaque, kid);
|
return test_key_hash_table ((KeyHashTable)opaque, kid);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user