sm: Remove unused arg SECRET from keydb functions.

* sm/keydb.c (struct resource_item): Remove field 'secret'.
(keydb_add_resource): Remove arg 'secret' and change all callers.
(keydb_new): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-11-10 15:38:14 +01:00
parent ee08677d63
commit c8044c6e33
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
14 changed files with 31 additions and 42 deletions

View File

@ -576,7 +576,7 @@ gpgsm_dirmngr_isvalid (ctrl_t ctrl,
from the dirmngr. Try our own cert store now. */
KEYDB_HANDLE kh;
kh = keydb_new (0);
kh = keydb_new ();
if (!kh)
rc = gpg_error (GPG_ERR_ENOMEM);
if (!rc)

View File

@ -807,7 +807,7 @@ gpgsm_walk_cert_chain (ctrl_t ctrl, ksba_cert_t start, ksba_cert_t *r_next)
int rc = 0;
char *issuer = NULL;
char *subject = NULL;
KEYDB_HANDLE kh = keydb_new (0);
KEYDB_HANDLE kh = keydb_new ();
*r_next = NULL;
if (!kh)
@ -1303,7 +1303,7 @@ do_validate_chain (ctrl_t ctrl, ksba_cert_t cert, ksba_isotime_t checktime_arg,
return 0;
}
kh = keydb_new (0);
kh = keydb_new ();
if (!kh)
{
log_error (_("failed to allocate keyDB handle\n"));
@ -1941,7 +1941,7 @@ gpgsm_basic_cert_check (ctrl_t ctrl, ksba_cert_t cert)
return 0;
}
kh = keydb_new (0);
kh = keydb_new ();
if (!kh)
{
log_error (_("failed to allocate keyDB handle\n"));

View File

@ -319,7 +319,7 @@ gpgsm_add_to_certlist (ctrl_t ctrl, const char *name, int secret,
rc = classify_user_id (name, &desc, 0);
if (!rc)
{
kh = keydb_new (0);
kh = keydb_new ();
if (!kh)
rc = gpg_error (GPG_ERR_ENOMEM);
else
@ -498,7 +498,7 @@ gpgsm_find_cert (const char *name, ksba_sexp_t keyid, ksba_cert_t *r_cert)
rc = classify_user_id (name, &desc, 0);
if (!rc)
{
kh = keydb_new (0);
kh = keydb_new ();
if (!kh)
rc = gpg_error (GPG_ERR_ENOMEM);
else

View File

@ -256,7 +256,7 @@ gpgsm_decrypt (ctrl_t ctrl, int in_fd, estream_t out_fp)
audit_set_type (ctrl->audit, AUDIT_TYPE_DECRYPT);
kh = keydb_new (0);
kh = keydb_new ();
if (!kh)
{
log_error (_("failed to allocate keyDB handle\n"));

View File

@ -54,7 +54,7 @@ delete_one (ctrl_t ctrl, const char *username)
goto leave;
}
kh = keydb_new (0);
kh = keydb_new ();
if (!kh)
{
log_error ("keydb_new failed\n");

View File

@ -336,7 +336,7 @@ gpgsm_encrypt (ctrl_t ctrl, certlist_t recplist, int data_fd, estream_t out_fp)
count++;
audit_log_i (ctrl->audit, AUDIT_GOT_RECIPIENTS, count);
kh = keydb_new (0);
kh = keydb_new ();
if (!kh)
{
log_error (_("failed to allocate keyDB handle\n"));

View File

@ -150,7 +150,7 @@ gpgsm_export (ctrl_t ctrl, strlist_t names, estream_t stream)
goto leave;
}
hd = keydb_new (0);
hd = keydb_new ();
if (!hd)
{
log_error ("keydb_new failed\n");
@ -338,8 +338,7 @@ gpgsm_p12_export (ctrl_t ctrl, const char *name, estream_t stream, int rawmode)
void *data;
size_t datalen;
hd = keydb_new (0);
hd = keydb_new ();
if (!hd)
{
log_error ("keydb_new failed\n");

View File

@ -1616,7 +1616,7 @@ main ( int argc, char **argv)
{
int created;
keydb_add_resource ("pubring.kbx", 0, 0, &created);
keydb_add_resource ("pubring.kbx", 0, &created);
if (created && !no_common_certs_import)
{
/* Import the standard certificates for a new default keybox. */
@ -1634,7 +1634,7 @@ main ( int argc, char **argv)
}
}
for (sl = nrings; sl; sl = sl->next)
keydb_add_resource (sl->d, 0, 0, NULL);
keydb_add_resource (sl->d, 0, NULL);
FREE_STRLIST(nrings);

View File

@ -403,7 +403,7 @@ reimport_one (ctrl_t ctrl, struct stats_s *stats, int in_fd)
ksba_cert_t cert = NULL;
unsigned int flags;
kh = keydb_new (0);
kh = keydb_new ();
if (!kh)
{
err = gpg_error (GPG_ERR_ENOMEM);;

View File

@ -47,7 +47,6 @@ struct resource_item {
KEYBOX_HANDLE kr;
} u;
void *token;
int secret;
dotlock_t lockhandle;
};
@ -250,9 +249,9 @@ maybe_create_keybox (char *filename, int force, int *r_created)
* if the function has created a new keybox.
*/
gpg_error_t
keydb_add_resource (const char *url, int force, int secret, int *auto_created)
keydb_add_resource (const char *url, int force, int *auto_created)
{
static int any_secret, any_public;
static int any_public;
const char *resname = url;
char *filename = NULL;
gpg_error_t err = 0;
@ -293,7 +292,7 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created)
filename = xstrdup (resname);
if (!force)
force = secret? !any_secret : !any_public;
force = !any_public;
/* see whether we can determine the filetype */
if (rt == KEYDB_RESOURCE_TYPE_NONE)
@ -335,7 +334,7 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created)
{
void *token;
err = keybox_register_file (filename, secret, &token);
err = keybox_register_file (filename, 0, &token);
if (gpg_err_code (err) == GPG_ERR_EEXIST)
; /* Already registered - ignore. */
else if (err)
@ -347,7 +346,6 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created)
all_resources[used_resources].type = rt;
all_resources[used_resources].u.kr = NULL; /* Not used here */
all_resources[used_resources].token = token;
all_resources[used_resources].secret = secret;
all_resources[used_resources].lockhandle
= dotlock_create (filename, 0);
@ -357,7 +355,7 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created)
/* Do a compress run if needed and the file is not locked. */
if (!dotlock_take (all_resources[used_resources].lockhandle, 0))
{
KEYBOX_HANDLE kbxhd = keybox_new_x509 (token, secret);
KEYBOX_HANDLE kbxhd = keybox_new_x509 (token, 0);
if (kbxhd)
{
@ -383,8 +381,6 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created)
leave:
if (err)
log_error ("keyblock resource '%s': %s\n", filename, gpg_strerror (err));
else if (secret)
any_secret = 1;
else
any_public = 1;
xfree (filename);
@ -393,7 +389,7 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created)
KEYDB_HANDLE
keydb_new (int secret)
keydb_new (void)
{
KEYDB_HANDLE hd;
int i, j;
@ -405,8 +401,6 @@ keydb_new (int secret)
assert (used_resources <= MAX_KEYDB_RESOURCES);
for (i=j=0; i < used_resources; i++)
{
if (!all_resources[i].secret != !secret)
continue;
switch (all_resources[i].type)
{
case KEYDB_RESOURCE_TYPE_NONE: /* ignore */
@ -414,9 +408,8 @@ keydb_new (int secret)
case KEYDB_RESOURCE_TYPE_KEYBOX:
hd->active[j].type = all_resources[i].type;
hd->active[j].token = all_resources[i].token;
hd->active[j].secret = all_resources[i].secret;
hd->active[j].lockhandle = all_resources[i].lockhandle;
hd->active[j].u.kr = keybox_new_x509 (all_resources[i].token, secret);
hd->active[j].u.kr = keybox_new_x509 (all_resources[i].token, 0);
if (!hd->active[j].u.kr)
{
xfree (hd);
@ -919,8 +912,6 @@ keydb_rebuild_caches (void)
for (i=0; i < used_resources; i++)
{
if (all_resources[i].secret)
continue;
switch (all_resources[i].type)
{
case KEYDB_RESOURCE_TYPE_NONE: /* ignore */
@ -1121,7 +1112,7 @@ keydb_store_cert (ksba_cert_t cert, int ephemeral, int *existed)
return gpg_error (GPG_ERR_GENERAL);
}
kh = keydb_new (0);
kh = keydb_new ();
if (!kh)
{
log_error (_("failed to allocate keyDB handle\n"));
@ -1207,7 +1198,7 @@ keydb_set_cert_flags (ksba_cert_t cert, int ephemeral,
return gpg_error (GPG_ERR_GENERAL);
}
kh = keydb_new (0);
kh = keydb_new ();
if (!kh)
{
log_error (_("failed to allocate keyDB handle\n"));
@ -1278,7 +1269,7 @@ keydb_clear_some_cert_flags (ctrl_t ctrl, strlist_t names)
(void)ctrl;
hd = keydb_new (0);
hd = keydb_new ();
if (!hd)
{
log_error ("keydb_new failed\n");

View File

@ -31,9 +31,8 @@ typedef struct keydb_handle *KEYDB_HANDLE;
/*-- keydb.c --*/
gpg_error_t keydb_add_resource (const char *url, int force, int secret,
int *auto_created);
KEYDB_HANDLE keydb_new (int secret);
gpg_error_t keydb_add_resource (const char *url, int force, int *auto_created);
KEYDB_HANDLE keydb_new (void);
void keydb_release (KEYDB_HANDLE hd);
int keydb_set_ephemeral (KEYDB_HANDLE hd, int yes);
const char *keydb_get_resource_name (KEYDB_HANDLE hd);

View File

@ -1329,7 +1329,7 @@ list_internal_keys (ctrl_t ctrl, strlist_t names, estream_t fp,
int have_secret;
int want_ephemeral = ctrl->with_ephemeral_keys;
hd = keydb_new (0);
hd = keydb_new ();
if (!hd)
{
log_error ("keydb_new failed\n");

View File

@ -141,7 +141,7 @@ gpgsm_get_default_cert (ctrl_t ctrl, ksba_cert_t *r_cert)
int rc;
char *p;
hd = keydb_new (0);
hd = keydb_new ();
if (!hd)
return gpg_error (GPG_ERR_GENERAL);
rc = keydb_search_first (hd);
@ -218,7 +218,7 @@ get_default_signer (ctrl_t ctrl)
return NULL;
}
kh = keydb_new (0);
kh = keydb_new ();
if (!kh)
return NULL;
@ -331,7 +331,7 @@ gpgsm_sign (ctrl_t ctrl, certlist_t signerlist,
audit_set_type (ctrl->audit, AUDIT_TYPE_SIGN);
kh = keydb_new (0);
kh = keydb_new ();
if (!kh)
{
log_error (_("failed to allocate keyDB handle\n"));

View File

@ -108,7 +108,7 @@ gpgsm_verify (ctrl_t ctrl, int in_fd, int data_fd, estream_t out_fp)
audit_set_type (ctrl->audit, AUDIT_TYPE_VERIFY);
kh = keydb_new (0);
kh = keydb_new ();
if (!kh)
{
log_error (_("failed to allocate keyDB handle\n"));