From: Artur Frysiak Date: Thu, 12 Oct 2000 13:44:24 +0000 (+0000) Subject: add map_ldap to mod_rewrite X-Git-Tag: apache-1_3_12-28~1 X-Git-Url: https://git.pld-linux.org/?a=commitdiff_plain;h=c9cceb4bebca874094172ae1d9c4f24c31c15d15;p=packages%2Fapache1.git add map_ldap to mod_rewrite Changed files: apache-lookup_map_ldap.patch -> 1.1 --- diff --git a/apache-lookup_map_ldap.patch b/apache-lookup_map_ldap.patch new file mode 100644 index 0000000..e4676a5 --- /dev/null +++ b/apache-lookup_map_ldap.patch @@ -0,0 +1,215 @@ +--- apache_1.3.12/src/modules/standard/mod_rewrite.c.wiget Wed Aug 23 17:32:28 2000 ++++ apache_1.3.12/src/modules/standard/mod_rewrite.c Wed Aug 23 18:33:51 2000 +@@ -98,6 +98,9 @@ + #include + #endif + ++#include ++#include ++ + /* + ** +-------------------------------------------------------+ + ** | | +@@ -151,6 +154,14 @@ + echo " (perhaps you need to add -ldbm, -lndbm or -lgdbm to EXTRA_LIBS)" + CFLAGS="$CFLAGS -DNO_DBM_REWRITEMAP" + fi ++ . ./helpers/find-ldap-lib ++ if [ "x$found_ldap" = "x1" ]; then ++ echo " enabling LDAP support for mod_rewrite" ++ else ++ echo " disabling LDAP support for mod_rewrite" ++ echo " (perhaps you need to add -llber -lldap to EXTRA_LIBS)" ++ CFLAGS="$CFLAGS -DNO_LDAP_REWRITEMAP" ++ fi + * ConfigEnd + * MODULE-DEFINITION-END + */ +@@ -480,6 +491,16 @@ + "because no NDBM support is compiled in"); + #endif + } ++ else if (strncmp(a2, "ldap:", 4) == 0) { ++#ifndef NO_LDAP_REWRITEMAP ++ new->type = MAPTYPE_LDAP; ++ new->datafile = a2; ++/* new->checkfile = ap_pstrcat(cmd->pool, a2+5, LDAP_FILE_SUFFIX, NULL); */ ++#else ++ return ap_pstrdup(cmd->pool, "RewriteMap: cannot use LDAP mapfile, " ++ "because no LDAP support is compiled in"); ++#endif ++ } + else if (strncmp(a2, "prg:", 4) == 0) { + new->type = MAPTYPE_PRG; + new->datafile = a2+4; +@@ -2792,6 +2813,48 @@ + return NULL; + #endif + } ++ else if (s->type == MAPTYPE_LDAP) { ++#ifndef NO_LDAP_REWRITEMAP ++/* FIXME */ ++/* if (stat(s->checkfile, &st) == -1) { ++ ap_log_rerror(APLOG_MARK, APLOG_ERR, r, ++ "mod_rewrite: can't access LDAP RewriteMap " ++ "file %s", s->checkfile); ++ rewritelog(r, 1, "can't open LDAP RewriteMap file, " ++ "see error log"); ++ return NULL; ++ } */ ++ rewritelog(r, 1, "MAPTYPE_LDAP: ok "); ++ value = get_cache_string(cachep, s->name, CACHEMODE_TS, ++ st.st_mtime, key); ++ if (value == NULL) { ++ rewritelog(r, 6, ++ "cache lookup FAILED, forcing new map lookup"); ++ if ((value = ++ lookup_map_ldap(r, s->datafile, key)) != NULL) { ++ rewritelog(r, 5, "map lookup OK: map=%s[ldap] key=%s " ++ "-> val=%s", s->name, key, value); ++ set_cache_string(cachep, s->name, CACHEMODE_TS, ++ st.st_mtime, key, value); ++ return value; ++ } ++ else { ++ rewritelog(r, 5, "map lookup FAILED: map=%s[ldap] " ++ "key=%s", s->name, key); ++ set_cache_string(cachep, s->name, CACHEMODE_TS, ++ st.st_mtime, key, ""); ++ return NULL; ++ } ++ } ++ else { ++ rewritelog(r, 5, "cache lookup OK: map=%s[ldap] key=%s " ++ "-> val=%s", s->name, key, value); ++ return value[0] != '\0' ? value : NULL; ++ } ++#else ++ return NULL; ++#endif ++ } + else if (s->type == MAPTYPE_PRG) { + if ((value = + lookup_map_program(r, s->fpin, s->fpout, key)) != NULL) { +@@ -2929,6 +2992,71 @@ + dbm_close(dbmfp); + } + return value; ++} ++#endif ++ ++#ifndef NO_LDAP_REWRITEMAP ++/* FIXME */ ++static char *lookup_map_ldap(request_rec *r, char *url, char *key) ++{ ++#define LDAP_URL_MAX 512 ++ LDAP *ld; ++ LDAPMessage *msg, *entry; ++ char **temp; ++ int res; ++ char *url_p; ++ ++ url_p = (char *)malloc((size_t)LDAP_URL_MAX); ++ snprintf(url_p, LDAP_URL_MAX, url, key); ++ ld=ldap_open("localhost", 389); ++ ++ if (!ld) ++ return NULL; ++ ++ res = ldap_simple_bind_s(ld,NULL,NULL); ++ if (res!=LDAP_SUCCESS) { ++ ldap_unbind(ld); ++ return NULL; ++ } ++ ++/* ++ int ldap_url_search_s( ld, url, attrsonly, res ) ++ LDAP *ld; ++ char *url; ++ int attrsonly; ++ LDAPMessage **res; ++ ++ char *ldap_first_attribute(ld, entry, berptr) ++ LDAP *ld; ++ LDAPMessage *entry; ++ BerElement **berptr; ++ ++*/ ++ ++ res = ldap_url_search_s(ld, url_p, 0, &msg ); ++ free(url_p); ++ if ((res!=LDAP_SUCCESS) || !msg) ++ { ++/* ldap_perror(ld,"lookup_map_ldap"); */ ++ ldap_unbind(ld); ++ return NULL; ++ } ++ entry = ldap_first_entry(ld, msg); ++ if (!entry) { ++ ldap_msgfree(msg); ++ return NULL; ++ } ++ ++ temp = ldap_get_values(ld, entry, "homedirectory"); ++ if (! temp) { ++ return NULL; ++ } ++ ++ /* Assumes that the above ldap_get_values call only returns 1 value */ ++/* strncpy(value, temp[0], (size_t)MAX_PATH); */ ++ ++/* return (char *)value; */ ++ return temp[0]; + } + #endif + +--- apache_1.3.12/src/modules/standard/mod_rewrite.h.wiget Thu Oct 21 22:45:38 1999 ++++ apache_1.3.12/src/modules/standard/mod_rewrite.h Mon Jun 5 21:11:11 2000 +@@ -179,6 +179,11 @@ + #include + #endif + ++#ifndef NO_LDAP_REWRITEMAP ++#include ++#include ++#endif ++ + + /* + ** +@@ -219,6 +224,7 @@ + #define MAPTYPE_PRG 1<<2 + #define MAPTYPE_INT 1<<3 + #define MAPTYPE_RND 1<<4 ++#define MAPTYPE_LDAP 1<<5 + + #define ENGINE_DISABLED 1<<0 + #define ENGINE_ENABLED 1<<1 +@@ -434,6 +440,9 @@ + static char *lookup_map_txtfile(request_rec *r, char *file, char *key); + #ifndef NO_DBM_REWRITEMAP + static char *lookup_map_dbmfile(request_rec *r, char *file, char *key); ++#endif ++#ifndef NO_LDAP_REWRITEMAP ++static char *lookup_map_ldap(request_rec *r, char *url, char *key); + #endif + static char *lookup_map_program(request_rec *r, int fpin, + int fpout, char *key); +--- /dev/null Tue May 5 22:32:27 1998 ++++ apache_1.3.12/src/helpers/find-ldap-lib Wed Aug 23 18:32:53 2000 +@@ -0,0 +1,15 @@ ++if [ "x$found_ldap" = "x" ]; then ++ if ./helpers/TestCompile func ldap_open; then ++ found_ldap=1 ++ else ++ found_ldap=0 ++ LDAP_LIB="" ++ if ./helpers/TestCompile lib "ldap -llber" ldap_open; then ++ LDAP_LIB="-lldap -llber" ++ found_ldap=1 ++ fi ++ if [ "x$found_ldap" = "x1" ]; then ++ echo " + using $LDAP_LIB for LDAP support" ++ fi ++ fi ++fi