summaryrefslogtreecommitdiffstats
path: root/dirmngr/ldap-misc.h
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2021-06-08 08:46:59 +0200
committerWerner Koch <wk@gnupg.org>2021-06-16 12:58:32 +0200
commit864ea251983977b91a7f6ff5964e497cf4b208dc (patch)
tree1449aece313b92b3d06bf174928cf2dd080f5bdd /dirmngr/ldap-misc.h
parentdirmngr: Remove useless code. (diff)
downloadgnupg2-864ea251983977b91a7f6ff5964e497cf4b208dc.tar.xz
gnupg2-864ea251983977b91a7f6ff5964e497cf4b208dc.zip
dirmngr: Rewrite the LDAP wrapper tool
* dirmngr/ldap-misc.c: New. * dirmngr/ldap-misc.h: New. * dirmngr/ks-engine-ldap.c: Include ldap-misc.h. (ldap_err_to_gpg_err, ldap_to_gpg_err): Move to ldap-misc.c. * dirmngr/ldap-wrapper.c (ldap_wrapper): Print list of args in debug mode. * dirmngr/server.c (lookup_cert_by_pattern): Handle GPG_ERR_NOT_FOUND the saqme as GPG_ERR_NO_DATA. * dirmngr/ldap.c (run_ldap_wrapper): Add args tls_mode and ntds. Remove arg url. Adjust for changes in dirmngr_ldap. (url_fetch_ldap): Remove args host and port. Parse the URL and use these values to call run_ldap_wrapper. (attr_fetch_ldap): Pass tls flags to run_ldap_wrapper. (rfc2254_need_escape, rfc2254_escape): New. (extfilt_need_escape, extfilt_escape): New. (parse_one_pattern): Rename to ... (make_one_filter): this. Change for new dirmngr_ldap calling convention. Make issuer DN searching partly work. (escape4url, make_url): Remove. (start_cert_fetch_ldap): Change for new dirmngr_ldap calling convention. * dirmngr/dirmngr_ldap.c: Major rewrite. * dirmngr/t-ldap-misc.c: New. * dirmngr/t-support.h (DIM, DIMof): New. * dirmngr/Makefile.am (dirmngr_ldap_SOURCES): Add ldap-misc.c (module_tests) [USE_LDAP]: Add t-ldap-misc. (t_ldap_parse_uri_SOURCES): Ditto. (t_ldap_misc_SOURCES): New. -- This rewrite allows to properly handle TLS and avoids some code duplication. Signed-off-by: Werner Koch <wk@gnupg.org> (cherry picked from commit 39815c023f0371dea01f7c51469b19c06ad18718)
Diffstat (limited to 'dirmngr/ldap-misc.h')
-rw-r--r--dirmngr/ldap-misc.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/dirmngr/ldap-misc.h b/dirmngr/ldap-misc.h
new file mode 100644
index 000000000..d555caf49
--- /dev/null
+++ b/dirmngr/ldap-misc.h
@@ -0,0 +1,43 @@
+/* ldap-misc.h - Miscellaneous helpers for LDAP functions
+ * Copyright (C) 2015, 2021 g10 Code GmbH
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#ifndef DIRMNGR_LDAP_MISC_H
+#define DIRMNGR_LDAP_MISC_H
+
+#ifdef _WIN32
+# include <winsock2.h>
+# include <winldap.h>
+#else
+# ifdef NEED_LBER_H
+# include <lber.h>
+# endif
+/* For OpenLDAP, to enable the API that we're using. */
+# define LDAP_DEPRECATED 1
+# include <ldap.h>
+#endif
+
+
+gpg_err_code_t ldap_err_to_gpg_err (int code);
+gpg_err_code_t ldap_to_gpg_err (LDAP *ld);
+gpg_error_t ldap_parse_extfilter (const char *string, int silent,
+ char **r_base, int *r_scope, char **r_filter);
+
+
+#endif /*DIRMNGR_LDAP_MISC_H*/