Home GnuPG
Diffusion GnuPG 2b4cddf9086f

dirmngr: Allow for non-URL specified ldap keyservers.

Description

dirmngr: Allow for non-URL specified ldap keyservers.

* dirmngr/server.c (cmd_ldapserver): Strip an optional prefix.
(make_keyserver_item): Handle non-URL ldap specs.
* dirmngr/dirmngr.h (struct ldap_server_s): Add fields starttls,
ldap_over_tls, and ntds.
* dirmngr/ldapserver.c (ldapserver_parse_one): Add for an empty host
string.  Improve error messages for the non-file case.  Support flags.
* dirmngr/ks-action.c (ks_action_help): Handle non-URL ldap specs.
(ks_action_search, ks_action_get, ks_action_put): Ditto.
* dirmngr/ks-engine-ldap.c: Include ldapserver.h.
(ks_ldap_help): Handle non-URL ldap specs.
(my_ldap_connect): Add args r_host and r_use_tls.  Rewrite to support
URLs and non-URL specified keyservers.
(ks_ldap_get): Adjust for changes in my_ldap_connect.
(ks_ldap_search): Ditto.
(ks_ldap_put): Ditto.

The idea here is to unify our use of URLS or colon delimited ldap
keyserver specification. The requirement for percent escaping, for
example the bindname in an URLs, is cumbersome and prone to errors.
This we allow our classic colon delimited format as an alternative.
That format makes it also easy to specify flags to tell dirmngr
whether to use starttls or ldap-over-tls. The code is nearly 100%
compatible to existing specification. There is one ambiguity if the
hostname for CRL/X509 searches is just "ldap"; this can be solved by
prefixing it with "ldap:" (already implemented in gpgsm).

Event Timeline

ikloecker added inline comments.
/dirmngr/ks-engine-ldap.c
316

Shouldn't there be four question marks as in the example URL in dirmngr.8?

/dirmngr/ldapserver.c
114

I think this needs to be changed to

if (*p && !server->user && !*server->user)

because server->user is no longer NULL if there is an empty string at field 3 (and the xtrystrdup (p) of the empty user string in line 108 did not fail).

/dirmngr/ks-engine-ldap.c
547–550

These lines are obsolete. password is set (again) a few lines further down.

/dirmngr/ks-engine-ldap.c
547–550

You are of course right.