mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg,sm: Add STATUS_ERROR keydb_search and keydb_add-resource.
* g10/keydb.c (keydb_add_resource): Make ANY_REGISTERED file-global. Write a STATUS_ERROR. (maybe_create_keyring_or_box): Check for non-accessible but existant file. (keydb_search): Write a STATUS_ERROR if no keyring has been registered but continue to return NOT_FOUND. * sm/keydb.c (keydb_add_resource): Rename ANY_PUBLIC to ANY_REGISTERED and make file-global. Write a STATUS_ERROR. (keydb_search): Write a STATUS_ERROR if no keyring has been registered but continue to return NOT_FOUND. Also add new arg CTRL and change all callers to pass it down. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
c8044c6e33
commit
5d13581f47
17 changed files with 163 additions and 99 deletions
18
g10/keydb.c
18
g10/keydb.c
|
@ -64,6 +64,8 @@ static int used_resources;
|
|||
to the struct resource_item's TOKEN. */
|
||||
static void *primary_keydb;
|
||||
|
||||
/* Whether we have successfully registered any resource. */
|
||||
static int any_registered;
|
||||
|
||||
/* This is a simple cache used to return the last result of a
|
||||
successful fingerprint search. This works only for keybox resources
|
||||
|
@ -277,7 +279,7 @@ maybe_create_keyring_or_box (char *filename, int is_box, int force_create)
|
|||
|
||||
/* A quick test whether the filename already exists. */
|
||||
if (!access (filename, F_OK))
|
||||
return 0;
|
||||
return !access (filename, R_OK)? 0 : gpg_error (GPG_ERR_EACCES);
|
||||
|
||||
/* If we don't want to create a new file at all, there is no need to
|
||||
go any further - bail out right here. */
|
||||
|
@ -616,8 +618,6 @@ keydb_search_desc_dump (struct keydb_search_desc *desc)
|
|||
gpg_error_t
|
||||
keydb_add_resource (const char *url, unsigned int flags)
|
||||
{
|
||||
/* Whether we have successfully registered a resource. */
|
||||
static int any_registered;
|
||||
/* The file named by the URL (i.e., without the prototype). */
|
||||
const char *resname = url;
|
||||
|
||||
|
@ -819,7 +819,11 @@ keydb_add_resource (const char *url, unsigned int flags)
|
|||
|
||||
leave:
|
||||
if (err)
|
||||
log_error (_("keyblock resource '%s': %s\n"), filename, gpg_strerror (err));
|
||||
{
|
||||
log_error (_("keyblock resource '%s': %s\n"),
|
||||
filename, gpg_strerror (err));
|
||||
write_status_error ("add_keyblock_resource", err);
|
||||
}
|
||||
else
|
||||
any_registered = 1;
|
||||
xfree (filename);
|
||||
|
@ -1875,6 +1879,12 @@ keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc,
|
|||
if (!hd)
|
||||
return gpg_error (GPG_ERR_INV_ARG);
|
||||
|
||||
if (!any_registered)
|
||||
{
|
||||
write_status_error ("keydb_search", gpg_error (GPG_ERR_KEYRING_OPEN));
|
||||
return gpg_error (GPG_ERR_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (DBG_CLOCK)
|
||||
log_clock ("keydb_search enter");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue