mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-28 22:49:59 +01:00
dirmngr: Support new gpgNtds parameter in LDAP keyserver URLs.
* dirmngr/ldap-parse-uri.c (ldap_parse_uri): Support a new gpgNtds extension. * dirmngr/ks-engine-ldap.c (my_ldap_connect): Do ldap_init always with hostname - which is NULL and thus the same if not given. Fix minor error in error code handling. -- Note that "gpgNtds" is per RFC-4512 case insensitive and has not yet been officially regisetered. Thus for correctness the OID can be used: 1.3.6.1.4.1.11591.2.5 LDAP URL extensions 1.3.6.1.4.1.11591.2.5.1 gpgNtds=1 (auth. with current user) Note that the value must be 1; all other values won't enable AD authentication and are resevered for future use.
This commit is contained in:
parent
cdc828f690
commit
55f46b33df
@ -521,18 +521,12 @@ my_ldap_connect (parsed_uri_t uri, LDAP **ldap_connp,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uri->ad_current)
|
ldap_conn = ldap_init (uri->host, uri->port);
|
||||||
ldap_conn = ldap_init (NULL, uri->port);
|
|
||||||
else
|
|
||||||
ldap_conn = ldap_init (uri->host, uri->port);
|
|
||||||
if (!ldap_conn)
|
if (!ldap_conn)
|
||||||
{
|
{
|
||||||
err = gpg_err_code_from_syserror ();
|
err = gpg_err_code_from_syserror ();
|
||||||
if (uri->ad_current)
|
log_error ("error initializing LDAP for (%s://%s:%d)\n",
|
||||||
log_error ("error initializing LDAP for current user\n");
|
uri->scheme, uri->host, uri->port);
|
||||||
else
|
|
||||||
log_error ("error initializing LDAP for (%s://%s:%d)\n",
|
|
||||||
uri->scheme, uri->host, uri->port);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,15 +607,16 @@ my_ldap_connect (parsed_uri_t uri, LDAP **ldap_connp,
|
|||||||
npth_unprotect ();
|
npth_unprotect ();
|
||||||
err = ldap_bind_s (ldap_conn, NULL, NULL, LDAP_AUTH_NEGOTIATE);
|
err = ldap_bind_s (ldap_conn, NULL, NULL, LDAP_AUTH_NEGOTIATE);
|
||||||
npth_protect ();
|
npth_protect ();
|
||||||
#else
|
|
||||||
err = gpg_error (GPG_ERR_NOT_SUPPORTED);
|
|
||||||
#endif
|
|
||||||
if (err != LDAP_SUCCESS)
|
if (err != LDAP_SUCCESS)
|
||||||
{
|
{
|
||||||
log_error ("error binding to LDAP via AD: %s\n",
|
log_error ("error binding to LDAP via AD: %s\n",
|
||||||
ldap_err2string (err));
|
ldap_err2string (err));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
err = gpg_error (GPG_ERR_NOT_SUPPORTED);
|
||||||
|
goto out;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (uri->auth)
|
else if (uri->auth)
|
||||||
{
|
{
|
||||||
|
@ -74,6 +74,7 @@ ldap_parse_uri (parsed_uri_t *purip, const char *uri)
|
|||||||
char *dn = NULL;
|
char *dn = NULL;
|
||||||
char *bindname = NULL;
|
char *bindname = NULL;
|
||||||
char *password = NULL;
|
char *password = NULL;
|
||||||
|
char *gpg_ntds = NULL;
|
||||||
|
|
||||||
char **s;
|
char **s;
|
||||||
|
|
||||||
@ -110,6 +111,15 @@ ldap_parse_uri (parsed_uri_t *purip, const char *uri)
|
|||||||
else
|
else
|
||||||
password = *s + 9;
|
password = *s + 9;
|
||||||
}
|
}
|
||||||
|
else if (!ascii_strncasecmp (*s, "gpgNtds=", 8)
|
||||||
|
|| !strncmp (*s, "1.3.6.1.4.1.11591.2.5.1=", 24))
|
||||||
|
{
|
||||||
|
if (gpg_ntds)
|
||||||
|
log_error ("gpgNtds given multiple times in URL '%s', ignoring.\n",
|
||||||
|
uri);
|
||||||
|
else
|
||||||
|
gpg_ntds = *s + (**s == 'g'? 8 : 24);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
log_error ("Unhandled extension (%s) in URL '%s', ignoring.",
|
log_error ("Unhandled extension (%s) in URL '%s', ignoring.",
|
||||||
*s, uri);
|
*s, uri);
|
||||||
@ -170,10 +180,14 @@ ldap_parse_uri (parsed_uri_t *purip, const char *uri)
|
|||||||
puri->port = lud->lud_port;
|
puri->port = lud->lud_port;
|
||||||
|
|
||||||
/* On Windows detect whether this is ldap:// or ldaps:// to indicate
|
/* On Windows detect whether this is ldap:// or ldaps:// to indicate
|
||||||
* that authentication via AD and the current user is requested. */
|
* that authentication via AD and the current user is requested.
|
||||||
|
* This is shortform of adding "gpgNtDs=1" as extension parameter to
|
||||||
|
* the URL. */
|
||||||
puri->ad_current = 0;
|
puri->ad_current = 0;
|
||||||
|
if (gpg_ntds && atoi (gpg_ntds) == 1)
|
||||||
|
puri->ad_current = 1;
|
||||||
#ifdef HAVE_W32_SYSTEM
|
#ifdef HAVE_W32_SYSTEM
|
||||||
if ((!puri->host || !*puri->host)
|
else if ((!puri->host || !*puri->host)
|
||||||
&& (!puri->path || !*puri->path)
|
&& (!puri->path || !*puri->path)
|
||||||
&& (!puri->auth || !*puri->auth)
|
&& (!puri->auth || !*puri->auth)
|
||||||
&& !password
|
&& !password
|
||||||
|
@ -332,6 +332,8 @@ built-in default of @code{hkps://hkps.pool.sks-keyservers.net}.
|
|||||||
|
|
||||||
Windows users with a keyserver running on their Active Directory
|
Windows users with a keyserver running on their Active Directory
|
||||||
should use @code{ldap:///} for @var{name} to access this directory.
|
should use @code{ldap:///} for @var{name} to access this directory.
|
||||||
|
As an alternative it is also possible to add @code{gpgNtds=1} as
|
||||||
|
extension (i.e. after the fourth question mark).
|
||||||
|
|
||||||
For accessing anonymous LDAP keyservers @var{name} is in general just
|
For accessing anonymous LDAP keyservers @var{name} is in general just
|
||||||
a @code{ldaps://ldap.example.com}. A BaseDN parameter should never be
|
a @code{ldaps://ldap.example.com}. A BaseDN parameter should never be
|
||||||
|
14
doc/gpg.texi
14
doc/gpg.texi
@ -1910,13 +1910,13 @@ Use @var{name} as your keyserver. This is the server that
|
|||||||
will communicate with to receive keys from, send keys to, and search for
|
will communicate with to receive keys from, send keys to, and search for
|
||||||
keys on. The format of the @var{name} is a URI:
|
keys on. The format of the @var{name} is a URI:
|
||||||
`scheme:[//]keyservername[:port]' The scheme is the type of keyserver:
|
`scheme:[//]keyservername[:port]' The scheme is the type of keyserver:
|
||||||
"hkp" for the HTTP (or compatible) keyservers, "ldap" for the LDAP
|
"hkp"/"hkps" for the HTTP (or compatible) keyservers or "ldap"/"ldaps"
|
||||||
keyservers, or "mailto" for the Graff email keyserver. Note that your
|
for the LDAP keyservers. Note that your particular installation of
|
||||||
particular installation of GnuPG may have other keyserver types
|
GnuPG may have other keyserver types available as well. Keyserver
|
||||||
available as well. Keyserver schemes are case-insensitive. After the
|
schemes are case-insensitive. After the keyserver name, optional
|
||||||
keyserver name, optional keyserver configuration options may be
|
keyserver configuration options may be provided. These are the same as
|
||||||
provided. These are the same as the global @option{--keyserver-options}
|
the global @option{--keyserver-options} from below, but apply only to
|
||||||
from below, but apply only to this particular keyserver.
|
this particular keyserver.
|
||||||
|
|
||||||
Most keyservers synchronize with each other, so there is generally no
|
Most keyservers synchronize with each other, so there is generally no
|
||||||
need to send keys to more than one server. The keyserver
|
need to send keys to more than one server. The keyserver
|
||||||
|
Loading…
x
Reference in New Issue
Block a user