]> granicus.if.org Git - apache/commitdiff
Fix load order dependencies in LDAP code by switching to use of APR
authorJoe Orton <jorton@apache.org>
Mon, 27 Jun 2011 09:27:04 +0000 (09:27 +0000)
committerJoe Orton <jorton@apache.org>
Mon, 27 Jun 2011 09:27:04 +0000 (09:27 +0000)
optional functions for the inter-module API:

* modules/ldap/ldap_private.h: New file, containing "real" function
  declarations, copied from...

* include/ap_ldap.h.in, include/ap_ldap_url.h,
  include/ap_ldap_option.h, include/ap_ldap_init.h,
  include/ap_ldap_rebind.h: ... here.  All declarations changed to APR
  optional function declarations.

* modules/ldap/util_ldap.c (util_ldap_register_hooks): Register all
  the new optional functions.

* modules/aaa/mod_authnz_ldap.c (ImportULDAPOptFn): Pick up optional
  function stub for ap_ldap_url_parse.
  (mod_auth_ldap_parse_url): Use it here.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1140069 13f79535-47bb-0310-9956-ffa450edef68

include/ap_ldap.h.in
include/ap_ldap.hw
include/ap_ldap_init.h
include/ap_ldap_option.h
include/ap_ldap_rebind.h
include/ap_ldap_url.h
modules/aaa/mod_authnz_ldap.c
modules/ldap/ldap_private.h [new file with mode: 0644]
modules/ldap/util_ldap.c

index 130c6dd016cc61096cfb926e66f2824b8b50408c..409d4c67a55ef48e6040628686f2d64314207b1d 100644 (file)
  * @{
  */
 
-/* Create a set of LDAP_DECLARE macros with appropriate export 
- * and import tags for the platform
- */
-#if !defined(WIN32)
-#define LDAP_DECLARE(type)            type
-#define LDAP_DECLARE_NONSTD(type)     type
-#define LDAP_DECLARE_DATA
-#elif defined(LDAP_DECLARE_STATIC)
-#define LDAP_DECLARE(type)            type __stdcall
-#define LDAP_DECLARE_NONSTD(type)     type
-#define LDAP_DECLARE_DATA
-#elif defined(LDAP_DECLARE_EXPORT)
-#define LDAP_DECLARE(type)            __declspec(dllexport) type __stdcall
-#define LDAP_DECLARE_NONSTD(type)     __declspec(dllexport) type
-#define LDAP_DECLARE_DATA             __declspec(dllexport)
-#else
-#define LDAP_DECLARE(type)            __declspec(dllimport) type __stdcall
-#define LDAP_DECLARE_NONSTD(type)     __declspec(dllimport) type
-#define LDAP_DECLARE_DATA             __declspec(dllimport)
-#endif
+#include "apr_optional.h"
 
 /* identify the LDAP toolkit used */
 #define AP_HAS_NETSCAPE_LDAPSDK  @ap_has_ldap_netscape@
index 36e21abd860bf836f9ee89d311f564fea9758c41..b64b4f4ae436345d271c606c36e069047c67cf4f 100644 (file)
  * @{
  */
 
-/* Create a set of LDAP_DECLARE macros with appropriate export 
- * and import tags for the platform
- */
-#if !defined(WIN32)
-#define LDAP_DECLARE(type)            type
-#define LDAP_DECLARE_NONSTD(type)     type
-#define LDAP_DECLARE_DATA
-#elif defined(LDAP_DECLARE_STATIC)
-#define LDAP_DECLARE(type)            type __stdcall
-#define LDAP_DECLARE_NONSTD(type)     type
-#define LDAP_DECLARE_DATA
-#elif defined(LDAP_DECLARE_EXPORT)
-#define LDAP_DECLARE(type)            __declspec(dllexport) type __stdcall
-#define LDAP_DECLARE_NONSTD(type)     __declspec(dllexport) type
-#define LDAP_DECLARE_DATA             __declspec(dllexport)
-#else
-#define LDAP_DECLARE(type)            __declspec(dllimport) type __stdcall
-#define LDAP_DECLARE_NONSTD(type)     __declspec(dllimport) type
-#define LDAP_DECLARE_DATA             __declspec(dllimport)
-#endif
+#include "apr_optional.h"
 
 /* this will be defined if LDAP support was compiled into apr-util */
 #define AP_HAS_LDAP               1
index 0fe0bcc6c1c3593649da924a5140c4baaac2411b..440f31835053b5bb0e2a7e0dd2d0d30e9b88a929 100644 (file)
@@ -86,10 +86,12 @@ extern "C" {
  * ap_ldap_set_option() AP_LDAP_OPT_TLS_CERT option for details.
  * @param result_err The returned result
  */
-LDAP_DECLARE(int) ap_ldap_ssl_init(apr_pool_t *pool,
-                                      const char *cert_auth_file,
-                                      int cert_file_type,
-                                      ap_ldap_err_t **result_err);
+APR_DECLARE_OPTIONAL_FN(int, ap_ldap_ssl_init, 
+                        (apr_pool_t *pool,
+                         const char *cert_auth_file,
+                         int cert_file_type,
+                         ap_ldap_err_t **result_err));
+
 
 /**
  * LDAP SSL De-Initialise function
@@ -100,7 +102,7 @@ LDAP_DECLARE(int) ap_ldap_ssl_init(apr_pool_t *pool,
  * @todo currently we do not check whether ap_ldap_ssl_init()
  * has been called first - we probably should.
  */
-LDAP_DECLARE(int) ap_ldap_ssl_deinit(void);
+APR_DECLARE_OPTIONAL_FN(int, ap_ldap_ssl_deinit, (void));
 
 /**
  * LDAP initialise function
@@ -136,12 +138,12 @@ LDAP_DECLARE(int) ap_ldap_ssl_deinit(void);
  * @param secure The security mode to set
  * @param result_err The returned result
  */
-LDAP_DECLARE(int) ap_ldap_init(apr_pool_t *pool,
-                                  LDAP **ldap,
-                                  const char *hostname,
-                                  int portno,
-                                  int secure,
-                                  ap_ldap_err_t **result_err);
+APR_DECLARE_OPTIONAL_FN(int, ap_ldap_init, (apr_pool_t *pool, 
+                                            LDAP **ldap,
+                                            const char *hostname,
+                                            int portno,
+                                            int secure,
+                                            ap_ldap_err_t **result_err));
 
 /**
  * LDAP info function
@@ -151,8 +153,8 @@ LDAP_DECLARE(int) ap_ldap_init(apr_pool_t *pool,
  * @param pool The pool to use
  * @param result_err The returned result
  */
-LDAP_DECLARE(int) ap_ldap_info(apr_pool_t *pool,
-                                  ap_ldap_err_t **result_err);
+APR_DECLARE_OPTIONAL_FN(int, ap_ldap_info, (apr_pool_t *pool,
+                                            ap_ldap_err_t **result_err));
 
 #ifdef __cplusplus
 }
index 6e73e5044fe5fc59b30f63695a77ed2683d8dbd6..b0c30af23e6fa7b1c91187dec9f81a248a0f8815 100644 (file)
@@ -214,11 +214,11 @@ struct ap_ldap_opt_tls_cert_t {
  * @param result_err The ap_ldap_err_t structure contained detailed results
  *        of the operation.
  */
-LDAP_DECLARE(int) ap_ldap_get_option(apr_pool_t *pool,
-                                        LDAP *ldap,
-                                        int option,
-                                        void *outvalue,
-                                        ap_ldap_err_t **result_err);
+APR_DECLARE_OPTIONAL_FN(int, ap_ldap_get_option, (apr_pool_t *pool,
+                                                  LDAP *ldap,
+                                                  int option,
+                                                  void *outvalue,
+                                                  ap_ldap_err_t **result_err));
 
 /**
  * LDAP set option function
@@ -236,11 +236,11 @@ LDAP_DECLARE(int) ap_ldap_get_option(apr_pool_t *pool,
  * @param result_err The ap_ldap_err_t structure contained detailed results
  *        of the operation.
  */
-LDAP_DECLARE(int) ap_ldap_set_option(apr_pool_t *pool,
-                                        LDAP *ldap,
-                                        int option,
-                                        const void *invalue,
-                                        ap_ldap_err_t **result_err);
+APR_DECLARE_OPTIONAL_FN(int, ap_ldap_set_option, (apr_pool_t *pool,
+                                                  LDAP *ldap,
+                                                  int option,
+                                                  const void *invalue,
+                                                  ap_ldap_err_t **result_err));
 
 #ifdef __cplusplus
 }
index 7bc5a5cda963c43880238e775fb2fbde761c59b4..f0090d30e95564f4acd823b2619f56c20c098957 100644 (file)
@@ -48,7 +48,7 @@
  * This function creates the lock for controlling access to the xref list..
  * @param pool Pool to use when creating the xref_lock.
  */
-LDAP_DECLARE(apr_status_t) ap_ldap_rebind_init(apr_pool_t *pool);
+APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_ldap_rebind_init, (apr_pool_t *pool));
 
 
 /**
@@ -72,10 +72,10 @@ LDAP_DECLARE(apr_status_t) ap_ldap_rebind_init(apr_pool_t *pool);
  * @param bindPW The bind Password to be used for any binds while 
  *               chasing referrals on this ldap connection.
  */
-LDAP_DECLARE(apr_status_t) ap_ldap_rebind_add(apr_pool_t *pool,
-                                                 LDAP *ld,
-                                                 const char *bindDN,
-                                                 const char *bindPW);
+APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_ldap_rebind_add, (apr_pool_t *pool,
+                                                           LDAP *ld,
+                                                           const char *bindDN,
+                                                           const char *bindPW));
 
 /**
  * LDAP rebind_remove function
@@ -88,7 +88,7 @@ LDAP_DECLARE(apr_status_t) ap_ldap_rebind_add(apr_pool_t *pool,
  *
  * @param ld The LDAP connectionhandle
  */
-LDAP_DECLARE(apr_status_t) ap_ldap_rebind_remove(LDAP *ld);
+APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_ldap_rebind_remove, (LDAP *ld));
 
 #endif /* AP_HAS_LDAP */
 
index 996b4b5a9aea622fa0160b1eeea619d3c4fdfac3..2c441dd8471b3ecdab1355c762461cccedcee89d 100644 (file)
@@ -31,6 +31,8 @@
 #include "apu.h"
 #include "apr_pools.h"
 
+#include "apr_optional.h"
+
 #if defined(DOXYGEN)
 #include "ap_ldap.h"
 #endif
@@ -71,19 +73,19 @@ typedef struct ap_ldap_url_desc_t {
  * Is this URL an ldap url? ldap://
  * @param url The url to test
  */
-LDAP_DECLARE(int) ap_ldap_is_ldap_url(const char *url);
+APR_DECLARE_OPTIONAL_FN(int, ap_ldap_is_ldap_url, (const char *url));
 
 /**
  * Is this URL an SSL ldap url? ldaps://
  * @param url The url to test
  */
-LDAP_DECLARE(int) ap_ldap_is_ldaps_url(const char *url);
+APR_DECLARE_OPTIONAL_FN(int, ap_ldap_is_ldaps_url, (const char *url));
 
 /**
  * Is this URL an ldap socket url? ldapi://
  * @param url The url to test
  */
-LDAP_DECLARE(int) ap_ldap_is_ldapi_url(const char *url);
+APR_DECLARE_OPTIONAL_FN(int, ap_ldap_is_ldapi_url, (const char *url));
 
 /**
  * Parse an LDAP URL.
@@ -92,10 +94,10 @@ LDAP_DECLARE(int) ap_ldap_is_ldapi_url(const char *url);
  * @param ludpp The structure to return the exploded URL
  * @param result_err The result structure of the operation
  */
-LDAP_DECLARE(int) ap_ldap_url_parse_ext(apr_pool_t *pool,
-                                           const char *url_in,
-                                           ap_ldap_url_desc_t **ludpp,
-                                           ap_ldap_err_t **result_err);
+APR_DECLARE_OPTIONAL_FN(int, ap_ldap_url_parse_ext, (apr_pool_t *pool,
+                                                     const char *url_in,
+                                                     ap_ldap_url_desc_t **ludpp,
+                                                     ap_ldap_err_t **result_err));
 
 /**
  * Parse an LDAP URL.
@@ -104,10 +106,10 @@ LDAP_DECLARE(int) ap_ldap_url_parse_ext(apr_pool_t *pool,
  * @param ludpp The structure to return the exploded URL
  * @param result_err The result structure of the operation
  */
-LDAP_DECLARE(int) ap_ldap_url_parse(apr_pool_t *pool,
-                                       const char *url_in,
-                                       ap_ldap_url_desc_t **ludpp,
-                                       ap_ldap_err_t **result_err);
+APR_DECLARE_OPTIONAL_FN(int, ap_ldap_url_parse, (apr_pool_t *pool,
+                                                 const char *url_in,
+                                                 ap_ldap_url_desc_t **ludpp,
+                                                 ap_ldap_err_t **result_err));
 
 #ifdef __cplusplus
 }
index 95bec065e43aa0de5fb10a11e2473d8738ef626f..426f3f60ad2113973df25784d9316eb1fa2d0c5f 100644 (file)
@@ -111,6 +111,7 @@ static APR_OPTIONAL_FN_TYPE(uldap_cache_check_subgroups) *util_ldap_cache_check_
 static APR_OPTIONAL_FN_TYPE(uldap_cache_checkuserid) *util_ldap_cache_checkuserid;
 static APR_OPTIONAL_FN_TYPE(uldap_cache_getuserdn) *util_ldap_cache_getuserdn;
 static APR_OPTIONAL_FN_TYPE(uldap_ssl_supported) *util_ldap_ssl_supported;
+static APR_OPTIONAL_FN_TYPE(ap_ldap_url_parse) *util_ldap_url_parse;
 
 static apr_hash_t *charset_conversions = NULL;
 static char *to_charset = NULL;           /* UTF-8 identifier derived from the charset.conv file */
@@ -1338,7 +1339,7 @@ static const char *mod_auth_ldap_parse_url(cmd_parms *cmd,
 
     authn_ldap_config_t *sec = config;
 
-    rc = ap_ldap_url_parse(cmd->pool, url, &(urld), &(result));
+    rc = util_ldap_url_parse(cmd->pool, url, &(urld), &(result));
     if (rc != APR_SUCCESS) {
         return result->reason;
     }
@@ -1780,6 +1781,7 @@ static void ImportULDAPOptFn(void)
     util_ldap_cache_getuserdn   = APR_RETRIEVE_OPTIONAL_FN(uldap_cache_getuserdn);
     util_ldap_ssl_supported     = APR_RETRIEVE_OPTIONAL_FN(uldap_ssl_supported);
     util_ldap_cache_check_subgroups = APR_RETRIEVE_OPTIONAL_FN(uldap_cache_check_subgroups);
+    util_ldap_url_parse = APR_RETRIEVE_OPTIONAL_FN(ap_ldap_url_parse);
 }
 
 static void register_hooks(apr_pool_t *p)
diff --git a/modules/ldap/ldap_private.h b/modules/ldap/ldap_private.h
new file mode 100644 (file)
index 0000000..ad6263b
--- /dev/null
@@ -0,0 +1,74 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AP_LDAP_PRIVATE_H
+#define AP_LDAP_PRIVATE_H
+
+#define LDAP_DECLARE(x) x
+
+#include "ap_ldap.h"
+
+/* Private declarations of API functions accessible only internally by
+ * mod_ldap; these are all exported and the corresponding API docs are
+ * in ap_ldap_*.h. */
+
+LDAP_DECLARE(int) ap_ldap_get_option(apr_pool_t *pool,
+                                     LDAP *ldap,
+                                     int option,
+                                     void *outvalue,
+                                     ap_ldap_err_t **result_err);
+
+LDAP_DECLARE(int) ap_ldap_set_option(apr_pool_t *pool,
+                                     LDAP *ldap,
+                                     int option,
+                                     const void *invalue,
+                                     ap_ldap_err_t **result_err);
+
+LDAP_DECLARE(int) ap_ldap_ssl_init(apr_pool_t *pool,
+                                      const char *cert_auth_file,
+                                      int cert_file_type,
+                                      ap_ldap_err_t **result_err);
+LDAP_DECLARE(int) ap_ldap_ssl_deinit(void);
+LDAP_DECLARE(int) ap_ldap_init(apr_pool_t *pool,
+                                  LDAP **ldap,
+                                  const char *hostname,
+                                  int portno,
+                                  int secure,
+                                  ap_ldap_err_t **result_err);
+
+LDAP_DECLARE(int) ap_ldap_info(apr_pool_t *pool,
+                                  ap_ldap_err_t **result_err);
+
+LDAP_DECLARE(int) ap_ldap_is_ldap_url(const char *url);
+LDAP_DECLARE(int) ap_ldap_is_ldaps_url(const char *url);
+LDAP_DECLARE(int) ap_ldap_is_ldapi_url(const char *url);
+LDAP_DECLARE(int) ap_ldap_url_parse_ext(apr_pool_t *pool,
+                                           const char *url_in,
+                                           ap_ldap_url_desc_t **ludpp,
+                                           ap_ldap_err_t **result_err);
+LDAP_DECLARE(int) ap_ldap_url_parse(apr_pool_t *pool,
+                                       const char *url_in,
+                                       ap_ldap_url_desc_t **ludpp,
+                                       ap_ldap_err_t **result_err);
+
+LDAP_DECLARE(apr_status_t) ap_ldap_rebind_init(apr_pool_t *pool);
+LDAP_DECLARE(apr_status_t) ap_ldap_rebind_add(apr_pool_t *pool,
+                                                 LDAP *ld,
+                                                 const char *bindDN,
+                                                 const char *bindPW);
+LDAP_DECLARE(apr_status_t) ap_ldap_rebind_remove(LDAP *ld);
+
+#endif /* AP_LDAP_PRIVATE_H */
index a833342afe3e8d26817422be7b0ff0a6be47a279..6b76a645760b727697d2a3ac99d82c19f5a8be12 100644 (file)
@@ -42,6 +42,8 @@
 #error mod_ldap requires httpd to detect LDAP support
 #endif
 
+#include "ldap_private.h"
+
 #ifdef LDAP_OPT_DEBUG_LEVEL
 #define AP_LDAP_OPT_DEBUG LDAP_OPT_DEBUG_LEVEL
 #else
@@ -2943,6 +2945,21 @@ static void util_ldap_register_hooks(apr_pool_t *p)
     APR_REGISTER_OPTIONAL_FN(uldap_ssl_supported);
     APR_REGISTER_OPTIONAL_FN(uldap_cache_check_subgroups);
 
+    APR_REGISTER_OPTIONAL_FN(ap_ldap_get_option);
+    APR_REGISTER_OPTIONAL_FN(ap_ldap_info);
+    APR_REGISTER_OPTIONAL_FN(ap_ldap_init);
+    APR_REGISTER_OPTIONAL_FN(ap_ldap_is_ldap_url);
+    APR_REGISTER_OPTIONAL_FN(ap_ldap_is_ldapi_url);
+    APR_REGISTER_OPTIONAL_FN(ap_ldap_is_ldaps_url);
+    APR_REGISTER_OPTIONAL_FN(ap_ldap_rebind_add);
+    APR_REGISTER_OPTIONAL_FN(ap_ldap_rebind_init);
+    APR_REGISTER_OPTIONAL_FN(ap_ldap_rebind_remove);
+    APR_REGISTER_OPTIONAL_FN(ap_ldap_set_option);
+    APR_REGISTER_OPTIONAL_FN(ap_ldap_ssl_deinit);
+    APR_REGISTER_OPTIONAL_FN(ap_ldap_ssl_init);
+    APR_REGISTER_OPTIONAL_FN(ap_ldap_url_parse);
+    APR_REGISTER_OPTIONAL_FN(ap_ldap_url_parse_ext);
+
     ap_hook_pre_config(util_ldap_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
     ap_hook_post_config(util_ldap_post_config,NULL,NULL,APR_HOOK_MIDDLE);
     ap_hook_handler(util_ldap_handler, NULL, NULL, APR_HOOK_MIDDLE);