summaryrefslogtreecommitdiff
blob: 484328f14b67c48f8cf285069c6f0130db76d363 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
Index: mod-vhost-ldap-1.0.0/mod_vhost_ldap.c
===================================================================
--- mod-vhost-ldap-1.0.0.orig/mod_vhost_ldap.c
+++ mod-vhost-ldap-1.0.0/mod_vhost_ldap.c
@@ -29,12 +29,13 @@
 #include "http_core.h"
 #include "http_log.h"
 #include "http_request.h"
+#include "apr_version.h"
 #include "apr_ldap.h"
 #include "apr_strings.h"
 #include "apr_reslist.h"
 #include "util_ldap.h"
 
-#ifndef APU_HAS_LDAP
+#if !defined(APU_HAS_LDAP) && !defined(APR_HAS_LDAP)
 #error mod_vhost_ldap requires APR-util to have LDAP support built in
 #endif
 
@@ -93,6 +94,27 @@ typedef struct mod_vhost_ldap_request_t 
 char *attributes[] =
   { "apacheServerName", "apacheDocumentRoot", "apacheScriptAlias", "apacheSuexecUid", "apacheSuexecGid", "apacheServerAdmin", 0 };
 
+#if (APR_MAJOR_VERSION >= 1)
+static APR_OPTIONAL_FN_TYPE(uldap_connection_close) *util_ldap_connection_close;
+static APR_OPTIONAL_FN_TYPE(uldap_connection_find) *util_ldap_connection_find;
+static APR_OPTIONAL_FN_TYPE(uldap_cache_comparedn) *util_ldap_cache_comparedn;
+static APR_OPTIONAL_FN_TYPE(uldap_cache_compare) *util_ldap_cache_compare;
+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 void ImportULDAPOptFn(void)
+{
+    util_ldap_connection_close  = APR_RETRIEVE_OPTIONAL_FN(uldap_connection_close);
+    util_ldap_connection_find   = APR_RETRIEVE_OPTIONAL_FN(uldap_connection_find);
+    util_ldap_cache_comparedn   = APR_RETRIEVE_OPTIONAL_FN(uldap_cache_comparedn);
+    util_ldap_cache_compare     = APR_RETRIEVE_OPTIONAL_FN(uldap_cache_compare);
+    util_ldap_cache_checkuserid = APR_RETRIEVE_OPTIONAL_FN(uldap_cache_checkuserid);
+    util_ldap_cache_getuserdn   = APR_RETRIEVE_OPTIONAL_FN(uldap_cache_getuserdn);
+    util_ldap_ssl_supported     = APR_RETRIEVE_OPTIONAL_FN(uldap_ssl_supported);
+}
+#endif 
+
 static int mod_vhost_ldap_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 {
     /* make sure that mod_ldap (util_ldap) is loaded */
@@ -114,6 +136,7 @@ mod_vhost_ldap_create_server_config (apr
 {
     mod_vhost_ldap_config_t *conf =
 	(mod_vhost_ldap_config_t *)apr_pcalloc(p, sizeof (mod_vhost_ldap_config_t));
+    memset(conf, 0, sizeof(mod_vhost_ldap_config_t));
 
     conf->enabled = MVL_UNSET;
     conf->have_ldap_url = 0;
@@ -133,6 +156,7 @@ mod_vhost_ldap_merge_server_config(apr_p
     mod_vhost_ldap_config_t *child  = (mod_vhost_ldap_config_t *) childv;
     mod_vhost_ldap_config_t *conf =
 	(mod_vhost_ldap_config_t *)apr_pcalloc(p, sizeof(mod_vhost_ldap_config_t));
+    memset(conf, 0, sizeof(mod_vhost_ldap_config_t));
 
     if (child->enabled == MVL_UNSET) {
 	conf->enabled = parent->enabled;
@@ -185,6 +209,9 @@ static const char *mod_vhost_ldap_parse_
 {
     int result;
     apr_ldap_url_desc_t *urld;
+#if (APR_MAJOR_VERSION >= 1)
+    apr_ldap_err_t *result_err;
+#endif
 
     mod_vhost_ldap_config_t *conf =
 	(mod_vhost_ldap_config_t *)ap_get_module_config(cmd->server->module_config,
@@ -193,22 +220,29 @@ static const char *mod_vhost_ldap_parse_
     ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0,
 	         cmd->server, "[mod_vhost_ldap.c] url parse: `%s'", 
 	         url);
-
+    
+#if (APR_MAJOR_VERSION >= 1)    /* for apache >= 2.2 */
+    result = apr_ldap_url_parse(cmd->pool, url, &(urld), &(result_err));
+    if (result != LDAP_SUCCESS) {
+        return result_err->reason;
+    }
+#else
     result = apr_ldap_url_parse(url, &(urld));
     if (result != LDAP_SUCCESS) {
         switch (result) {
-        case LDAP_URL_ERR_NOTLDAP:
-            return "LDAP URL does not begin with ldap://";
-        case LDAP_URL_ERR_NODN:
-            return "LDAP URL does not have a DN";
-        case LDAP_URL_ERR_BADSCOPE:
-            return "LDAP URL has an invalid scope";
-        case LDAP_URL_ERR_MEM:
-            return "Out of memory parsing LDAP URL";
-        default:
-            return "Could not parse LDAP URL";
+            case LDAP_URL_ERR_NOTLDAP:
+                return "LDAP URL does not begin with ldap://";
+            case LDAP_URL_ERR_NODN:
+                return "LDAP URL does not have a DN";
+            case LDAP_URL_ERR_BADSCOPE:
+                return "LDAP URL has an invalid scope";
+            case LDAP_URL_ERR_MEM:
+                return "Out of memory parsing LDAP URL";
+            default:
+                return "Could not parse LDAP URL";
         }
     }
+#endif
     conf->url = apr_pstrdup(cmd->pool, url);
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0,
@@ -278,7 +312,9 @@ static const char *mod_vhost_ldap_parse_
     }
 
     conf->have_ldap_url = 1;
+#if (APR_MAJOR_VERSION < 1) /* free only required for older apr */
     apr_ldap_free_urldesc(urld);
+#endif
     return NULL;
 }
 
@@ -406,6 +442,7 @@ static int mod_vhost_ldap_translate_name
 
     reqc =
 	(mod_vhost_ldap_request_t *)apr_pcalloc(r->pool, sizeof(mod_vhost_ldap_request_t));
+    memset(reqc, 0, sizeof(mod_vhost_ldap_request_t)); 
 
     ap_set_module_config(r->request_config, &vhost_ldap_module, reqc);
 
@@ -608,6 +645,9 @@ mod_vhost_ldap_register_hooks (apr_pool_
 #ifdef HAVE_UNIX_SUEXEC
     ap_hook_get_suexec_identity(mod_vhost_ldap_get_suexec_id_doer, NULL, NULL, APR_HOOK_MIDDLE);
 #endif
+#if (APR_MAJOR_VERSION >= 1)
+    ap_hook_optional_fn_retrieve(ImportULDAPOptFn,NULL,NULL,APR_HOOK_MIDDLE);
+#endif
 }
 
 module AP_MODULE_DECLARE_DATA vhost_ldap_module = {
Index: mod-vhost-ldap-1.0.0/ChangeLog
===================================================================
--- mod-vhost-ldap-1.0.0.orig/ChangeLog
+++ mod-vhost-ldap-1.0.0/ChangeLog
@@ -1,3 +1,11 @@
+2006-04-21 Bart Vanbrabant <bart.vanbrabant@zoeloelip.be>
+	* VERSION: 1.0.1 release
+	* mod_vhost_ldap.c: add support for apache-2.2.x
+
+2006-01-30 Ondřej Surý <ondrej@sury.org>
+	* VERSION: 1.0.0 release
+	* Fix small memory leak when used in subrequest (e.g. fastcgi)
+	
 2005-10-03 Ondřej Surý <ondrej@sury.org>
 	* mod_vhost_ldap.c: add support for running from subrequest (ie. mod_fastcgi)
 	* VERSION: 0.2.9 release