]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ldap: provide version for "legacy" ldap as well
authorDaniel Stenberg <daniel@haxx.se>
Tue, 2 Dec 2025 13:13:55 +0000 (14:13 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 2 Dec 2025 15:27:16 +0000 (16:27 +0100)
It displays in version output as WinLDAP and LDAP/1, compared to
OpenLDAP/[version] for the OpenLDAP backend code.

Closes #19808

lib/curl_ldap.h
lib/ldap.c
lib/openldap.c
lib/version.c

index 8a1d807ed92b0c8fcfd6db62e9c5380a4c7ba13b..9da9b717d52923ec5fdfe4ef55f4ecae66bca976 100644 (file)
@@ -32,5 +32,6 @@ extern const struct Curl_handler Curl_handler_ldap;
 extern const struct Curl_handler Curl_handler_ldaps;
 #endif
 
+void Curl_ldap_version(char *buf, size_t bufsz);
 #endif
 #endif /* HEADER_CURL_LDAP_H */
index 6c6207038571b061a8726a9d5f58994eea9a904e..522bf3ad586036e02b8d22420e279fd2d948970d 100644 (file)
@@ -1037,6 +1037,15 @@ static void ldap_free_urldesc_low(LDAPURLDesc *ludp)
 }
 #endif /* !HAVE_LDAP_URL_PARSE */
 
+void Curl_ldap_version(char *buf, size_t bufsz)
+{
+#ifdef USE_WIN32_LDAP
+  curl_msnprintf(buf, bufsz, "WinLDAP");
+#else
+  curl_msnprintf(buf, bufsz, "LDAP/1");
+#endif
+}
+
 #if defined(__GNUC__) && defined(__APPLE__)
 #pragma GCC diagnostic pop
 #endif
index 107f6da832a54c46e99b2c2057ff13cddc13fed3..bb48edd32f2c112ea74ce312bd21d22283d83406 100644 (file)
@@ -1331,4 +1331,24 @@ ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
 }
 #endif /* USE_SSL */
 
+void Curl_ldap_version(char *buf, size_t bufsz)
+{
+  LDAPAPIInfo api;
+  api.ldapai_info_version = LDAP_API_INFO_VERSION;
+
+  if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &api) == LDAP_OPT_SUCCESS) {
+    unsigned int patch = (unsigned int)(api.ldapai_vendor_version % 100);
+    unsigned int major = (unsigned int)(api.ldapai_vendor_version / 10000);
+    unsigned int minor =
+      (((unsigned int)api.ldapai_vendor_version - major * 10000)
+       - patch) / 100;
+    curl_msnprintf(buf, bufsz, "%s/%u.%u.%u",
+                   api.ldapai_vendor_name, major, minor, patch);
+    ldap_memfree(api.ldapai_vendor_name);
+    ber_memvfree((void **)api.ldapai_extensions);
+  }
+  else
+    curl_msnprintf(buf, bufsz, "OpenLDAP");
+}
+
 #endif /* !CURL_DISABLE_LDAP && USE_OPENLDAP */
index 49c15ffcdec9abd545295f2ee26f3032998a1224..487dc74ffa158e4193ddaacfe6a5a377cd162dc7 100644 (file)
@@ -77,8 +77,8 @@
 #include <gsasl.h>
 #endif
 
-#ifdef USE_OPENLDAP
-#include <ldap.h>
+#ifndef CURL_DISABLE_LDAP
+#include "curl_ldap.h"
 #endif
 
 #ifdef HAVE_BROTLI
@@ -103,28 +103,6 @@ static void zstd_version(char *buf, size_t bufsz)
 }
 #endif
 
-#ifdef USE_OPENLDAP
-static void oldap_version(char *buf, size_t bufsz)
-{
-  LDAPAPIInfo api;
-  api.ldapai_info_version = LDAP_API_INFO_VERSION;
-
-  if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &api) == LDAP_OPT_SUCCESS) {
-    unsigned int patch = (unsigned int)(api.ldapai_vendor_version % 100);
-    unsigned int major = (unsigned int)(api.ldapai_vendor_version / 10000);
-    unsigned int minor =
-      (((unsigned int)api.ldapai_vendor_version - major * 10000)
-       - patch) / 100;
-    curl_msnprintf(buf, bufsz, "%s/%u.%u.%u",
-                   api.ldapai_vendor_name, major, minor, patch);
-    ldap_memfree(api.ldapai_vendor_name);
-    ber_memvfree((void **)api.ldapai_extensions);
-  }
-  else
-    curl_msnprintf(buf, bufsz, "OpenLDAP");
-}
-#endif
-
 #ifdef USE_LIBPSL
 static void psl_version(char *buf, size_t bufsz)
 {
@@ -211,7 +189,7 @@ char *curl_version(void)
 #ifdef HAVE_GSSAPI
   char gss_buf[40];
 #endif
-#ifdef USE_OPENLDAP
+#ifndef CURL_DISABLE_LDAP
   char ldap_buf[30];
 #endif
   int i = 0;
@@ -289,8 +267,8 @@ char *curl_version(void)
 #endif
   src[i++] = gss_buf;
 #endif /* HAVE_GSSAPI */
-#ifdef USE_OPENLDAP
-  oldap_version(ldap_buf, sizeof(ldap_buf));
+#ifndef CURL_DISABLE_LDAP
+  Curl_ldap_version(ldap_buf, sizeof(ldap_buf));
   src[i++] = ldap_buf;
 #endif