mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-30 16:17:02 +01:00
dirmngr: Minor cleanup for better readability.
* dirmngr/ldap.c (start_default_fetch_ldap): Rename to start_cacert_fetch_ldap and remove arg attr. Instead use "cACertificate" directly. * dirmngr/crlfetch.c (ca_cert_fetch): Change the only caller. (start_cert_fetch_ldap): Rename arg for clarity. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
210575d882
commit
b258f8de7e
@ -302,7 +302,7 @@ ca_cert_fetch (ctrl_t ctrl, cert_fetch_context_t *context, const char *dn)
|
||||
return gpg_error (GPG_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
#if USE_LDAP
|
||||
return start_default_fetch_ldap (ctrl, context, dn, "cACertificate");
|
||||
return start_cacert_fetch_ldap (ctrl, context, dn);
|
||||
#else
|
||||
(void)ctrl;
|
||||
(void)context;
|
||||
|
@ -69,9 +69,9 @@ gpg_error_t attr_fetch_ldap (ctrl_t ctrl,
|
||||
ksba_reader_t *reader);
|
||||
|
||||
|
||||
gpg_error_t start_default_fetch_ldap (ctrl_t ctrl,
|
||||
cert_fetch_context_t *context,
|
||||
const char *dn, const char *attr);
|
||||
gpg_error_t start_cacert_fetch_ldap (ctrl_t ctrl,
|
||||
cert_fetch_context_t *context,
|
||||
const char *dn);
|
||||
gpg_error_t start_cert_fetch_ldap( ctrl_t ctrl,
|
||||
cert_fetch_context_t *context,
|
||||
strlist_t patterns,
|
||||
|
@ -468,18 +468,19 @@ make_url (char **url, const char *dn, const char *filter)
|
||||
}
|
||||
|
||||
|
||||
/* Prepare an LDAP query to return the attribute ATTR for the DN. All
|
||||
configured default servers are queried until one responds. This
|
||||
function returns an error code or 0 and a CONTEXT on success. */
|
||||
/* Prepare an LDAP query to return the cACertificate attribute for DN.
|
||||
* All configured default servers are queried until one responds.
|
||||
* This function returns an error code or 0 and stored a newly
|
||||
* allocated contect object at CONTEXT on success. */
|
||||
gpg_error_t
|
||||
start_default_fetch_ldap (ctrl_t ctrl, cert_fetch_context_t *context,
|
||||
const char *dn, const char *attr)
|
||||
start_cacert_fetch_ldap (ctrl_t ctrl, cert_fetch_context_t *r_context,
|
||||
const char *dn)
|
||||
{
|
||||
gpg_error_t err;
|
||||
struct ldapserver_iter iter;
|
||||
|
||||
*context = xtrycalloc (1, sizeof **context);
|
||||
if (!*context)
|
||||
*r_context = xtrycalloc (1, sizeof **r_context);
|
||||
if (!*r_context)
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
/* FIXME; we might want to look at the Base SN to try matching
|
||||
@ -493,30 +494,30 @@ start_default_fetch_ldap (ctrl_t ctrl, cert_fetch_context_t *context,
|
||||
|
||||
err = run_ldap_wrapper (ctrl,
|
||||
0,
|
||||
1,
|
||||
1, /* --multi (record format) */
|
||||
opt.ldap_proxy,
|
||||
server->host, server->port,
|
||||
server->user, server->pass,
|
||||
dn, "objectClass=*", attr, NULL,
|
||||
&(*context)->reader);
|
||||
dn, "objectClass=*", "cACertificate", NULL,
|
||||
&(*r_context)->reader);
|
||||
if (!err)
|
||||
break; /* Probably found a result. */
|
||||
}
|
||||
|
||||
if (err)
|
||||
{
|
||||
xfree (*context);
|
||||
*context = NULL;
|
||||
xfree (*r_context);
|
||||
*r_context = NULL;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/* Prepare an LDAP query to return certificates matching PATTERNS using
|
||||
the SERVER. This function returns an error code or 0 and a CONTEXT
|
||||
on success. */
|
||||
/* Prepare an LDAP query to return certificates matching PATTERNS
|
||||
* using the SERVER. This function returns an error code or 0 and
|
||||
* stores a newly allocated object at R_CONTEXT on success. */
|
||||
gpg_error_t
|
||||
start_cert_fetch_ldap (ctrl_t ctrl, cert_fetch_context_t *context,
|
||||
start_cert_fetch_ldap (ctrl_t ctrl, cert_fetch_context_t *r_context,
|
||||
strlist_t patterns, const ldap_server_t server)
|
||||
{
|
||||
gpg_error_t err;
|
||||
@ -532,7 +533,7 @@ start_cert_fetch_ldap (ctrl_t ctrl, cert_fetch_context_t *context,
|
||||
char portbuf[30], timeoutbuf[30];
|
||||
int use_ldaps = 0;
|
||||
|
||||
*context = NULL;
|
||||
*r_context = NULL;
|
||||
|
||||
if (opt.ldap_proxy && !(proxy = xtrystrdup (opt.ldap_proxy)))
|
||||
{
|
||||
@ -646,19 +647,19 @@ start_cert_fetch_ldap (ctrl_t ctrl, cert_fetch_context_t *context,
|
||||
}
|
||||
argv[argc] = NULL;
|
||||
|
||||
*context = xtrycalloc (1, sizeof **context);
|
||||
if (!*context)
|
||||
*r_context = xtrycalloc (1, sizeof **r_context);
|
||||
if (!*r_context)
|
||||
{
|
||||
err = gpg_error_from_errno (errno);
|
||||
goto leave;
|
||||
}
|
||||
|
||||
err = ldap_wrapper (ctrl, &(*context)->reader, (const char**)argv);
|
||||
err = ldap_wrapper (ctrl, &(*r_context)->reader, (const char**)argv);
|
||||
|
||||
if (err)
|
||||
{
|
||||
xfree (*context);
|
||||
*context = NULL;
|
||||
xfree (*r_context);
|
||||
*r_context = NULL;
|
||||
}
|
||||
|
||||
leave:
|
||||
@ -718,8 +719,7 @@ fetch_next_cert_ldap (cert_fetch_context_t context,
|
||||
n = buf32_to_ulong (hdr+1);
|
||||
if (*hdr == 'V' && okay)
|
||||
{
|
||||
#if 0 /* That code is not yet ready. */
|
||||
|
||||
#if 0 /* That code to extra a cert from a CMS object is not yet ready. */
|
||||
if (is_cms)
|
||||
{
|
||||
/* The certificate needs to be parsed from CMS data. */
|
||||
@ -766,7 +766,7 @@ fetch_next_cert_ldap (cert_fetch_context_t context,
|
||||
any = 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif /* End unfinished code to extract from a CMS object. */
|
||||
{
|
||||
*value = xtrymalloc (n);
|
||||
if (!*value)
|
||||
|
Loading…
x
Reference in New Issue
Block a user