mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
dirmngr: Rework of the LDAP code, part 1.
* dirmngr/http.h (struct parsed_uri_s): Add flag is_ldap. * dirmngr/http.c (do_parse_uri): Set flag. Do not error out for a missing slashes in an http scheme if NO_SCHEME_CHECK is active. * dirmngr/t-http.c (main): Print new flag. * dirmngr/ks-engine-ldap.c (ks_ldap_help): Use flag instead of checking the scheme. * dirmngr/ldap-parse-uri.c (ldap_uri_p): Re-implement using http_parse_uri. * dirmngr/t-ldap-parse-uri.c (main): Add option --verbose. -- This patch merely remove the separate parser for checking for an LDAP scheme. It is better to let our generic URI parser handle this. Also fixes this bug || url[4] == 'i' || url[4] == 'i') to make the rarely used ldapi scheme case-insensitive. More changes to the LDAP code are planned. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
1009e4e5f7
commit
264c15c72f
6 changed files with 93 additions and 40 deletions
|
@ -20,9 +20,13 @@
|
|||
#include <config.h>
|
||||
|
||||
#include "ldap-parse-uri.h"
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
#define PGM "t-ldap-parse-uri"
|
||||
|
||||
static int verbose;
|
||||
|
||||
|
||||
struct test_ldap_uri_p
|
||||
{
|
||||
const char *uri;
|
||||
|
@ -32,7 +36,11 @@ struct test_ldap_uri_p
|
|||
void
|
||||
check_ldap_uri_p (int test_count, struct test_ldap_uri_p *test)
|
||||
{
|
||||
int result = ldap_uri_p (test->uri);
|
||||
int result;
|
||||
|
||||
if (verbose)
|
||||
fprintf (stderr, PGM ": checking '%s'\n", test->uri);
|
||||
result = ldap_uri_p (test->uri);
|
||||
if (result != test->result)
|
||||
{
|
||||
printf ("'%s' is %san LDAP schema, but ldap_uri_p says opposite.\n",
|
||||
|
@ -106,6 +114,8 @@ check_ldap_parse_uri (int test_count, struct test_ldap_parse_uri *test)
|
|||
gpg_error_t err;
|
||||
parsed_uri_t puri;
|
||||
|
||||
if (verbose)
|
||||
fprintf (stderr, PGM ": parsing '%s'\n", test->uri);
|
||||
err = ldap_parse_uri (&puri, test->uri);
|
||||
if (err)
|
||||
{
|
||||
|
@ -242,12 +252,48 @@ test_ldap_escape_filter (void)
|
|||
test_count ++)
|
||||
check_ldap_escape_filter (test_count, &tests[test_count - 1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
int last_argc = -1;
|
||||
|
||||
if (argc)
|
||||
{ argc--; argv++; }
|
||||
while (argc && last_argc != argc )
|
||||
{
|
||||
last_argc = argc;
|
||||
if (!strcmp (*argv, "--"))
|
||||
{
|
||||
argc--; argv++;
|
||||
break;
|
||||
}
|
||||
else if (!strcmp (*argv, "--help"))
|
||||
{
|
||||
fputs ("usage: " PGM "\n"
|
||||
"Options:\n"
|
||||
" --verbose print timings etc.\n",
|
||||
stdout);
|
||||
exit (0);
|
||||
}
|
||||
else if (!strcmp (*argv, "--verbose"))
|
||||
{
|
||||
verbose++;
|
||||
argc--; argv++;
|
||||
}
|
||||
else if (!strncmp (*argv, "--", 2))
|
||||
{
|
||||
fprintf (stderr, PGM ": unknown option '%s'\n", *argv);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
if (argc)
|
||||
{
|
||||
fprintf (stderr, PGM ": no argumenst are expected\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
test_ldap_uri_p ();
|
||||
test_ldap_parse_uri ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue