e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher/* Licensed to the Apache Software Foundation (ASF) under one or more
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * contributor license agreements. See the NOTICE file distributed with
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * this work for additional information regarding copyright ownership.
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * The ASF licenses this file to You under the Apache License, Version 2.0
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * (the "License"); you may not use this file except in compliance with
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * the License. You may obtain a copy of the License at
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher *
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * http://www.apache.org/licenses/LICENSE-2.0
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher *
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * Unless required by applicable law or agreed to in writing, software
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * distributed under the License is distributed on an "AS IS" BASIS,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * See the License for the specific language governing permissions and
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * limitations under the License.
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher */
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher/*
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * util_ldap_cache.c: LDAP cache things
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher *
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * Original code from auth_ldap module for Apache v1.3:
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * Copyright 1998, 1999 Enbridge Pipelines Inc.
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher * Copyright 1999-2001 Dave Carrigan
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher */
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher#include "httpd.h"
e0404de84c31d2387bb244d018a5cac8d01f8b19Simo Sorce#include "util_ldap.h"
e0404de84c31d2387bb244d018a5cac8d01f8b19Simo Sorce#include "util_ldap_cache.h"
e0404de84c31d2387bb244d018a5cac8d01f8b19Simo Sorce#include <apr_strings.h>
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher#if APR_HAS_LDAP
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher/* ------------------------------------------------------------------ */
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagherunsigned long util_ldap_url_node_hash(void *n)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_url_node_t *node = n;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return util_ald_hash_string(1, node->url);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagherint util_ldap_url_node_compare(void *a, void *b)
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_url_node_t *na = a;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_url_node_t *nb = b;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return (strcmp(na->url, nb->url) == 0);
e2ac9be4f293b96f3c8992f1171e44bc1da5cfcaMichal Zidek}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallaghervoid *util_ldap_url_node_copy(util_ald_cache_t *cache, void *c)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_url_node_t *n = c;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_url_node_t *node = util_ald_alloc(cache, sizeof *node);
e0404de84c31d2387bb244d018a5cac8d01f8b19Simo Sorce
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (node) {
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov if (!(node->url = util_ald_strdup(cache, n->url))) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_free(cache, node);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return NULL;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher node->search_cache = n->search_cache;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher node->compare_cache = n->compare_cache;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher node->dn_compare_cache = n->dn_compare_cache;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return node;
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher else {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return NULL;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallaghervoid util_ldap_url_node_free(util_ald_cache_t *cache, void *n)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_url_node_t *node = n;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_free(cache, node->url);
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov util_ald_destroy_cache(node->search_cache);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_destroy_cache(node->compare_cache);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_destroy_cache(node->dn_compare_cache);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_free(cache, node);
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
d115f40c7a3999e3cbe705a2ff9cf0fd493f80fbMichal Zidekvoid util_ldap_url_node_display(request_rec *r, util_ald_cache_t *cache, void *n)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov util_url_node_t *node = n;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher char date_str[APR_CTIME_LEN];
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher const char *type_str;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_cache_t *cache_node;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher int x;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher for (x=0;x<3;x++) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher switch (x) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher case 0:
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher cache_node = node->search_cache;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher type_str = "Searches";
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher break;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher case 1:
e0404de84c31d2387bb244d018a5cac8d01f8b19Simo Sorce cache_node = node->compare_cache;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher type_str = "Compares";
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher break;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher case 2:
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher default:
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher cache_node = node->dn_compare_cache;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher type_str = "DN Compares";
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher break;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (cache_node->marktime) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher apr_ctime(date_str, cache_node->marktime);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher else
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher date_str[0] = 0;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher ap_rprintf(r,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "<tr valign='top'>"
e0404de84c31d2387bb244d018a5cac8d01f8b19Simo Sorce "<td nowrap>%s (%s)</td>"
21d485184df986e1a123f70c689517386e51a5ceMichal Zidek "<td nowrap>%ld</td>"
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "<td nowrap>%ld</td>"
21d485184df986e1a123f70c689517386e51a5ceMichal Zidek "<td nowrap>%ld</td>"
21d485184df986e1a123f70c689517386e51a5ceMichal Zidek "<td nowrap>%ld</td>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "<td nowrap>%s</td>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "</tr>",
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher node->url,
e0404de84c31d2387bb244d018a5cac8d01f8b19Simo Sorce type_str,
e0404de84c31d2387bb244d018a5cac8d01f8b19Simo Sorce cache_node->size,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher cache_node->maxentries,
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov cache_node->numentries,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov cache_node->fullmark,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher date_str);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e0404de84c31d2387bb244d018a5cac8d01f8b19Simo Sorce/* ------------------------------------------------------------------ */
e0404de84c31d2387bb244d018a5cac8d01f8b19Simo Sorce
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher/* Cache functions for search nodes */
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashovunsigned long util_ldap_search_node_hash(void *n)
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_search_node_t *node = n;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return util_ald_hash_string(1, node->username);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e0404de84c31d2387bb244d018a5cac8d01f8b19Simo Sorceint util_ldap_search_node_compare(void *a, void *b)
21d485184df986e1a123f70c689517386e51a5ceMichal Zidek{
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov util_search_node_t *na = a;
21d485184df986e1a123f70c689517386e51a5ceMichal Zidek util_search_node_t *nb = b;
21d485184df986e1a123f70c689517386e51a5ceMichal Zidek
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return (strcmp(na->username, nb->username) == 0);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallaghervoid *util_ldap_search_node_copy(util_ald_cache_t *cache, void *c)
e0404de84c31d2387bb244d018a5cac8d01f8b19Simo Sorce{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_search_node_t *node = c;
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov util_search_node_t *newnode = util_ald_alloc(cache, sizeof *newnode);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher /* safety check */
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (newnode) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov /* copy vals */
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (node->vals) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher int k = node->numvals;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher int i = 0;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (!(newnode->vals = util_ald_alloc(cache, sizeof(char *) * (k+1)))) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ldap_search_node_free(cache, newnode);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return NULL;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher newnode->numvals = node->numvals;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher for (;k;k--) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (node->vals[i]) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (!(newnode->vals[i] = util_ald_strdup(cache, node->vals[i]))) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ldap_search_node_free(cache, newnode);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return NULL;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov else
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher newnode->vals[i] = NULL;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher i++;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher else {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher newnode->vals = NULL;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
3d8a87081a6cd197acbd355b5a39111669ec2aa6Jakub Hrozek if (!(newnode->username = util_ald_strdup(cache, node->username)) ||
3d8a87081a6cd197acbd355b5a39111669ec2aa6Jakub Hrozek !(newnode->dn = util_ald_strdup(cache, node->dn)) ) {
3d8a87081a6cd197acbd355b5a39111669ec2aa6Jakub Hrozek util_ldap_search_node_free(cache, newnode);
3d8a87081a6cd197acbd355b5a39111669ec2aa6Jakub Hrozek return NULL;
3d8a87081a6cd197acbd355b5a39111669ec2aa6Jakub Hrozek }
3d8a87081a6cd197acbd355b5a39111669ec2aa6Jakub Hrozek if(node->bindpw) {
3d8a87081a6cd197acbd355b5a39111669ec2aa6Jakub Hrozek if(!(newnode->bindpw = util_ald_strdup(cache, node->bindpw))) {
3d8a87081a6cd197acbd355b5a39111669ec2aa6Jakub Hrozek util_ldap_search_node_free(cache, newnode);
3d8a87081a6cd197acbd355b5a39111669ec2aa6Jakub Hrozek return NULL;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher } else {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher newnode->bindpw = NULL;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher newnode->lastbind = node->lastbind;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return (void *)newnode;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallaghervoid util_ldap_search_node_free(util_ald_cache_t *cache, void *n)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher int i = 0;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_search_node_t *node = n;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher int k = node->numvals;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (node->vals) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher for (;k;k--,i++) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (node->vals[i]) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_free(cache, node->vals[i]);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_free(cache, node->vals);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_free(cache, node->username);
9f37bb2012faa136ef7c1f9fe93689ce2be85637Ondrej Kos util_ald_free(cache, node->dn);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_free(cache, node->bindpw);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_free(cache, node);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallaghervoid util_ldap_search_node_display(request_rec *r, util_ald_cache_t *cache, void *n)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_search_node_t *node = n;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher char date_str[APR_CTIME_LEN];
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher apr_ctime(date_str, node->lastbind);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher ap_rprintf(r,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "<tr valign='top'>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "<td nowrap>%s</td>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "<td nowrap>%s</td>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "<td nowrap>%s</td>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "</tr>",
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher node->username,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher node->dn,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher date_str);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov/* ------------------------------------------------------------------ */
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagherunsigned long util_ldap_compare_node_hash(void *n)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_compare_node_t *node = n;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return util_ald_hash_string(3, node->dn, node->attrib, node->value);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagherint util_ldap_compare_node_compare(void *a, void *b)
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_compare_node_t *na = a;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_compare_node_t *nb = b;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return (strcmp(na->dn, nb->dn) == 0 &&
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher strcmp(na->attrib, nb->attrib) == 0 &&
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher strcmp(na->value, nb->value) == 0);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallaghervoid *util_ldap_compare_node_copy(util_ald_cache_t *cache, void *c)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_compare_node_t *n = c;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_compare_node_t *node = util_ald_alloc(cache, sizeof *node);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (node) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (!(node->dn = util_ald_strdup(cache, n->dn)) ||
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher !(node->attrib = util_ald_strdup(cache, n->attrib)) ||
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher !(node->value = util_ald_strdup(cache, n->value)) ||
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher ((n->subgroupList) && !(node->subgroupList = util_ald_sgl_dup(cache, n->subgroupList)))) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ldap_compare_node_free(cache, node);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return NULL;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher node->lastcompare = n->lastcompare;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher node->result = n->result;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher node->sgl_processed = n->sgl_processed;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return node;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher else {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return NULL;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallaghervoid util_ldap_compare_node_free(util_ald_cache_t *cache, void *n)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_compare_node_t *node = n;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_sgl_free(cache, &(node->subgroupList));
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_free(cache, node->dn);
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov util_ald_free(cache, node->attrib);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_free(cache, node->value);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_free(cache, node);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallaghervoid util_ldap_compare_node_display(request_rec *r, util_ald_cache_t *cache, void *n)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_compare_node_t *node = n;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher char date_str[APR_CTIME_LEN];
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher char *cmp_result;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher char *sub_groups_val;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher char *sub_groups_checked;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher apr_ctime(date_str, node->lastcompare);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (node->result == LDAP_COMPARE_TRUE) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher cmp_result = "LDAP_COMPARE_TRUE";
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov }
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov else if (node->result == LDAP_COMPARE_FALSE) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher cmp_result = "LDAP_COMPARE_FALSE";
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher else {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher cmp_result = apr_itoa(r->pool, node->result);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if(node->subgroupList) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher sub_groups_val = "Yes";
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher else {
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov sub_groups_val = "No";
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if(node->sgl_processed) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher sub_groups_checked = "Yes";
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina else {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher sub_groups_checked = "No";
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher ap_rprintf(r,
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov "<tr valign='top'>"
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "<td nowrap>%s</td>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "<td nowrap>%s</td>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "<td nowrap>%s</td>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "<td nowrap>%s</td>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "<td nowrap>%s</td>"
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina "<td nowrap>%s</td>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "<td nowrap>%s</td>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "</tr>",
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher node->dn,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher node->attrib,
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov node->value,
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov date_str,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov cmp_result,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher sub_groups_val,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher sub_groups_checked);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
6fb75e297bf7fc83e3db1f5ae8560624656ef319Jan Zeleny/* ------------------------------------------------------------------ */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagherunsigned long util_ldap_dn_compare_node_hash(void *n)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
6fb75e297bf7fc83e3db1f5ae8560624656ef319Jan Zeleny util_dn_compare_node_t *node = n;
6fb75e297bf7fc83e3db1f5ae8560624656ef319Jan Zeleny return util_ald_hash_string(1, node->reqdn);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashovint util_ldap_dn_compare_node_compare(void *a, void *b)
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov{
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov util_dn_compare_node_t *na = a;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_dn_compare_node_t *nb = b;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return (strcmp(na->reqdn, nb->reqdn) == 0);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallaghervoid *util_ldap_dn_compare_node_copy(util_ald_cache_t *cache, void *c)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_dn_compare_node_t *n = c;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_dn_compare_node_t *node = util_ald_alloc(cache, sizeof *node);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (node) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (!(node->reqdn = util_ald_strdup(cache, n->reqdn)) ||
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher !(node->dn = util_ald_strdup(cache, n->dn))) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ldap_dn_compare_node_free(cache, node);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return NULL;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return node;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher else {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return NULL;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallaghervoid util_ldap_dn_compare_node_free(util_ald_cache_t *cache, void *n)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_dn_compare_node_t *node = n;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_free(cache, node->reqdn);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_free(cache, node->dn);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ald_free(cache, node);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashovvoid util_ldap_dn_compare_node_display(request_rec *r, util_ald_cache_t *cache, void *n)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_dn_compare_node_t *node = n;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov ap_rprintf(r,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "<tr valign='top'>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "<td nowrap>%s</td>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "<td nowrap>%s</td>"
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher "</tr>",
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher node->reqdn,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher node->dn);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher/* ------------------------------------------------------------------ */
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagherstatic apr_status_t util_ldap_cache_module_kill(void *data)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ldap_state_t *st = data;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
2ce00e0d3896bb42db169d1e79553a81ca837a22Simo Sorce util_ald_destroy_cache(st->util_ldap_cache);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher#if APR_HAS_SHARED_MEMORY
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (st->cache_rmm != NULL) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher apr_rmm_destroy (st->cache_rmm);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher st->cache_rmm = NULL;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (st->cache_shm != NULL) {
f5e22261a2ff95f2a61f4f199fffb8de79668110Stephen Gallagher apr_status_t result = apr_shm_destroy(st->cache_shm);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher st->cache_shm = NULL;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return result;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher#endif
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return APR_SUCCESS;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher}
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagherapr_status_t util_ldap_cache_init(apr_pool_t *pool, util_ldap_state_t *st)
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher{
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher#if APR_HAS_SHARED_MEMORY
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher apr_status_t result;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher apr_size_t size;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (st->cache_bytes > 0) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (st->cache_file) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher /* Remove any existing shm segment with this name. */
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher apr_shm_remove(st->cache_file, st->pool);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher size = APR_ALIGN_DEFAULT(st->cache_bytes);
94a66f84bd3c28fcabffeb84c682dccf89d89c2bSumit Bose
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher result = apr_shm_create(&st->cache_shm, size, st->cache_file, st->pool);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher if (result != APR_SUCCESS) {
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return result;
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher }
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
1ea2e8bd370e0dc2f2c3fa09232cf67082ef748dStephen Gallagher /* Determine the usable size of the shm segment. */
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher size = apr_shm_size_get(st->cache_shm);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher /* This will create a rmm "handler" to get into the shared memory area */
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher result = apr_rmm_init(&st->cache_rmm, NULL,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher apr_shm_baseaddr_get(st->cache_shm), size,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher st->pool);
94a66f84bd3c28fcabffeb84c682dccf89d89c2bSumit Bose if (result != APR_SUCCESS) {
94a66f84bd3c28fcabffeb84c682dccf89d89c2bSumit Bose return result;
94a66f84bd3c28fcabffeb84c682dccf89d89c2bSumit Bose }
db18dda869bc6c52a41797b2066cf121cf10f49cPavel Reichl }
94a66f84bd3c28fcabffeb84c682dccf89d89c2bSumit Bose
db18dda869bc6c52a41797b2066cf121cf10f49cPavel Reichl#endif
94a66f84bd3c28fcabffeb84c682dccf89d89c2bSumit Bose
94a66f84bd3c28fcabffeb84c682dccf89d89c2bSumit Bose apr_pool_cleanup_register(st->pool, st , util_ldap_cache_module_kill, apr_pool_cleanup_null);
94a66f84bd3c28fcabffeb84c682dccf89d89c2bSumit Bose
c41ae115bfa808d04e729dcbd759d8aae8387ce7Jakub Hrozek st->util_ldap_cache =
c41ae115bfa808d04e729dcbd759d8aae8387ce7Jakub Hrozek util_ald_create_cache(st,
94a66f84bd3c28fcabffeb84c682dccf89d89c2bSumit Bose st->search_cache_size,
c41ae115bfa808d04e729dcbd759d8aae8387ce7Jakub Hrozek util_ldap_url_node_hash,
c41ae115bfa808d04e729dcbd759d8aae8387ce7Jakub Hrozek util_ldap_url_node_compare,
94a66f84bd3c28fcabffeb84c682dccf89d89c2bSumit Bose util_ldap_url_node_copy,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ldap_url_node_free,
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher util_ldap_url_node_display);
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher return APR_SUCCESS;
c41ae115bfa808d04e729dcbd759d8aae8387ce7Jakub Hrozek}
c41ae115bfa808d04e729dcbd759d8aae8387ce7Jakub Hrozek
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher#endif /* APR_HAS_LDAP */
e134a6af42102c8d865e82bf89e0b8c5a40fb5faStephen Gallagher