diff options
author | Werner Koch <[email protected]> | 2019-11-26 12:09:35 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2019-11-26 12:09:35 +0000 |
commit | 264c15c72fe050f5e8d2f1cb2444a459df6fe99f (patch) | |
tree | aa2f381705526fdb8860026137174ba970a24207 /dirmngr/t-ldap-parse-uri.c | |
parent | dirmngr: Make building with a TLS library mandatory (diff) | |
download | gnupg-264c15c72fe050f5e8d2f1cb2444a459df6fe99f.tar.gz gnupg-264c15c72fe050f5e8d2f1cb2444a459df6fe99f.zip |
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 <[email protected]>
Diffstat (limited to 'dirmngr/t-ldap-parse-uri.c')
-rw-r--r-- | dirmngr/t-ldap-parse-uri.c | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/dirmngr/t-ldap-parse-uri.c b/dirmngr/t-ldap-parse-uri.c index 932ca7dcb..984e1412f 100644 --- a/dirmngr/t-ldap-parse-uri.c +++ b/dirmngr/t-ldap-parse-uri.c @@ -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 (); |