]> git.pld-linux.org Git - packages/apache1.git/blame - apache1-lookup_map_ldap.patch
rel 15; builds
[packages/apache1.git] / apache1-lookup_map_ldap.patch
CommitLineData
c9cceb4b
AF
1--- apache_1.3.12/src/modules/standard/mod_rewrite.c.wiget Wed Aug 23 17:32:28 2000
2+++ apache_1.3.12/src/modules/standard/mod_rewrite.c Wed Aug 23 18:33:51 2000
3@@ -98,6 +98,9 @@
4 #include <sys/uio.h>
5 #endif
6
7+#include <stdlib.h>
8+#include <stdio.h>
9+
10 /*
11 ** +-------------------------------------------------------+
12 ** | |
13@@ -151,6 +154,14 @@
14 echo " (perhaps you need to add -ldbm, -lndbm or -lgdbm to EXTRA_LIBS)"
15 CFLAGS="$CFLAGS -DNO_DBM_REWRITEMAP"
16 fi
17+ . ./helpers/find-ldap-lib
18+ if [ "x$found_ldap" = "x1" ]; then
19+ echo " enabling LDAP support for mod_rewrite"
20+ else
21+ echo " disabling LDAP support for mod_rewrite"
22+ echo " (perhaps you need to add -llber -lldap to EXTRA_LIBS)"
23+ CFLAGS="$CFLAGS -DNO_LDAP_REWRITEMAP"
24+ fi
25 * ConfigEnd
26 * MODULE-DEFINITION-END
27 */
28@@ -480,6 +491,16 @@
29 "because no NDBM support is compiled in");
30 #endif
31 }
32+ else if (strncmp(a2, "ldap:", 4) == 0) {
33+#ifndef NO_LDAP_REWRITEMAP
34+ new->type = MAPTYPE_LDAP;
35+ new->datafile = a2;
36+/* new->checkfile = ap_pstrcat(cmd->pool, a2+5, LDAP_FILE_SUFFIX, NULL); */
37+#else
38+ return ap_pstrdup(cmd->pool, "RewriteMap: cannot use LDAP mapfile, "
39+ "because no LDAP support is compiled in");
40+#endif
41+ }
42 else if (strncmp(a2, "prg:", 4) == 0) {
43 new->type = MAPTYPE_PRG;
44 new->datafile = a2+4;
45@@ -2792,6 +2813,48 @@
46 return NULL;
47 #endif
48 }
49+ else if (s->type == MAPTYPE_LDAP) {
50+#ifndef NO_LDAP_REWRITEMAP
51+/* FIXME */
52+/* if (stat(s->checkfile, &st) == -1) {
53+ ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
54+ "mod_rewrite: can't access LDAP RewriteMap "
55+ "file %s", s->checkfile);
56+ rewritelog(r, 1, "can't open LDAP RewriteMap file, "
57+ "see error log");
58+ return NULL;
59+ } */
60+ rewritelog(r, 1, "MAPTYPE_LDAP: ok ");
61+ value = get_cache_string(cachep, s->name, CACHEMODE_TS,
62+ st.st_mtime, key);
63+ if (value == NULL) {
64+ rewritelog(r, 6,
65+ "cache lookup FAILED, forcing new map lookup");
66+ if ((value =
67+ lookup_map_ldap(r, s->datafile, key)) != NULL) {
68+ rewritelog(r, 5, "map lookup OK: map=%s[ldap] key=%s "
69+ "-> val=%s", s->name, key, value);
70+ set_cache_string(cachep, s->name, CACHEMODE_TS,
71+ st.st_mtime, key, value);
72+ return value;
73+ }
74+ else {
75+ rewritelog(r, 5, "map lookup FAILED: map=%s[ldap] "
76+ "key=%s", s->name, key);
77+ set_cache_string(cachep, s->name, CACHEMODE_TS,
78+ st.st_mtime, key, "");
79+ return NULL;
80+ }
81+ }
82+ else {
83+ rewritelog(r, 5, "cache lookup OK: map=%s[ldap] key=%s "
84+ "-> val=%s", s->name, key, value);
85+ return value[0] != '\0' ? value : NULL;
86+ }
87+#else
88+ return NULL;
89+#endif
90+ }
91 else if (s->type == MAPTYPE_PRG) {
92 if ((value =
93 lookup_map_program(r, s->fpin, s->fpout, key)) != NULL) {
94@@ -2929,6 +2992,71 @@
95 dbm_close(dbmfp);
96 }
97 return value;
98+}
99+#endif
100+
101+#ifndef NO_LDAP_REWRITEMAP
102+/* FIXME */
103+static char *lookup_map_ldap(request_rec *r, char *url, char *key)
104+{
105+#define LDAP_URL_MAX 512
106+ LDAP *ld;
107+ LDAPMessage *msg, *entry;
108+ char **temp;
109+ int res;
110+ char *url_p;
111+
112+ url_p = (char *)malloc((size_t)LDAP_URL_MAX);
113+ snprintf(url_p, LDAP_URL_MAX, url, key);
114+ ld=ldap_open("localhost", 389);
115+
116+ if (!ld)
117+ return NULL;
118+
119+ res = ldap_simple_bind_s(ld,NULL,NULL);
120+ if (res!=LDAP_SUCCESS) {
121+ ldap_unbind(ld);
122+ return NULL;
123+ }
124+
125+/*
126+ int ldap_url_search_s( ld, url, attrsonly, res )
127+ LDAP *ld;
128+ char *url;
129+ int attrsonly;
130+ LDAPMessage **res;
131+
132+ char *ldap_first_attribute(ld, entry, berptr)
133+ LDAP *ld;
134+ LDAPMessage *entry;
135+ BerElement **berptr;
136+
137+*/
138+
139+ res = ldap_url_search_s(ld, url_p, 0, &msg );
140+ free(url_p);
141+ if ((res!=LDAP_SUCCESS) || !msg)
142+ {
143+/* ldap_perror(ld,"lookup_map_ldap"); */
144+ ldap_unbind(ld);
145+ return NULL;
146+ }
147+ entry = ldap_first_entry(ld, msg);
148+ if (!entry) {
149+ ldap_msgfree(msg);
150+ return NULL;
151+ }
152+
153+ temp = ldap_get_values(ld, entry, "homedirectory");
154+ if (! temp) {
155+ return NULL;
156+ }
157+
158+ /* Assumes that the above ldap_get_values call only returns 1 value */
159+/* strncpy(value, temp[0], (size_t)MAX_PATH); */
160+
161+/* return (char *)value; */
162+ return temp[0];
163 }
164 #endif
165
166--- apache_1.3.12/src/modules/standard/mod_rewrite.h.wiget Thu Oct 21 22:45:38 1999
167+++ apache_1.3.12/src/modules/standard/mod_rewrite.h Mon Jun 5 21:11:11 2000
168@@ -179,6 +179,11 @@
169 #include <sys/locking.h>
170 #endif
171
172+#ifndef NO_LDAP_REWRITEMAP
173+#include <lber.h>
174+#include <ldap.h>
175+#endif
176+
177
178 /*
179 **
180@@ -219,6 +224,7 @@
181 #define MAPTYPE_PRG 1<<2
182 #define MAPTYPE_INT 1<<3
183 #define MAPTYPE_RND 1<<4
184+#define MAPTYPE_LDAP 1<<5
185
186 #define ENGINE_DISABLED 1<<0
187 #define ENGINE_ENABLED 1<<1
188@@ -434,6 +440,9 @@
189 static char *lookup_map_txtfile(request_rec *r, char *file, char *key);
190 #ifndef NO_DBM_REWRITEMAP
191 static char *lookup_map_dbmfile(request_rec *r, char *file, char *key);
192+#endif
193+#ifndef NO_LDAP_REWRITEMAP
194+static char *lookup_map_ldap(request_rec *r, char *url, char *key);
195 #endif
196 static char *lookup_map_program(request_rec *r, int fpin,
197 int fpout, char *key);
198--- /dev/null Tue May 5 22:32:27 1998
199+++ apache_1.3.12/src/helpers/find-ldap-lib Wed Aug 23 18:32:53 2000
200@@ -0,0 +1,15 @@
201+if [ "x$found_ldap" = "x" ]; then
202+ if ./helpers/TestCompile func ldap_open; then
203+ found_ldap=1
204+ else
205+ found_ldap=0
206+ LDAP_LIB=""
207+ if ./helpers/TestCompile lib "ldap -llber" ldap_open; then
208+ LDAP_LIB="-lldap -llber"
209+ found_ldap=1
210+ fi
211+ if [ "x$found_ldap" = "x1" ]; then
212+ echo " + using $LDAP_LIB for LDAP support"
213+ fi
214+ fi
215+fi
This page took 0.065339 seconds and 4 git commands to generate.