Apache HTTPD
framework
httpd-2.4.62
modules
ldap
util_ldap_cache.h
Go to the documentation of this file.
1
/* Licensed to the Apache Software Foundation (ASF) under one or more
2
* contributor license agreements. See the NOTICE file distributed with
3
* this work for additional information regarding copyright ownership.
4
* The ASF licenses this file to You under the Apache License, Version 2.0
5
* (the "License"); you may not use this file except in compliance with
6
* the License. You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#ifndef APU_LDAP_CACHE_H
18
#define APU_LDAP_CACHE_H
19
25
/* this whole thing disappears if LDAP is not enabled */
26
#if APR_HAS_LDAP
27
28
29
/*
30
* LDAP Cache Manager
31
*/
32
33
#include "
util_ldap.h
"
34
35
typedef
struct
util_cache_node_t
{
36
void
*
payload
;
/* Pointer to the payload */
37
apr_time_t
add_time
;
/* Time node was added to cache */
38
struct
util_cache_node_t
*next;
39
}
util_cache_node_t
;
40
41
typedef
struct
util_ald_cache
util_ald_cache_t
;
42
43
struct
util_ald_cache
{
44
unsigned
long
size
;
/* Size of cache array */
45
unsigned
long
maxentries
;
/* Maximum number of cache entries */
46
unsigned
long
numentries
;
/* Current number of cache entries */
47
unsigned
long
fullmark
;
/* Used to keep track of when cache becomes 3/4 full */
48
apr_time_t
marktime
;
/* Time that the cache became 3/4 full */
49
unsigned
long
ttl
;
/* Time to live for items in cache */
50
unsigned
long
(*
hash
)(
void
*);
/* Func to hash the payload */
51
int
(*compare)(
void
*,
void
*);
/* Func to compare two payloads */
52
void
* (*copy)(
util_ald_cache_t
*
cache
,
void
*);
/* Func to alloc mem and copy payload to new mem */
53
void (*free)(
util_ald_cache_t
*
cache
,
void
*);
/* Func to free mem used by the payload */
54
void (*
display
)(
request_rec
*
r
,
util_ald_cache_t
*
cache
,
void
*);
/* Func to display the payload contents */
55
util_cache_node_t
**
nodes
;
56
57
unsigned
long
numpurges
;
/* No. of times the cache has been purged */
58
double
avg_purgetime
;
/* Average time to purge the cache */
59
apr_time_t
last_purge
;
/* Time of the last purge */
60
unsigned
long
npurged
;
/* Number of elements purged in last purge. This is not
61
obvious: it won't be 3/4 the size of the cache if
62
there were a lot of expired entries. */
63
64
unsigned
long
fetches
;
/* Number of fetches */
65
unsigned
long
hits
;
/* Number of cache hits */
66
unsigned
long
inserts
;
/* Number of inserts */
67
unsigned
long
removes
;
/* Number of removes */
68
69
#if APR_HAS_SHARED_MEMORY
70
apr_shm_t
*
shm_addr
;
71
apr_rmm_t
*
rmm_addr
;
72
#endif
73
74
};
75
76
#ifndef WIN32
77
#define ALD_MM_FILE_MODE ( S_IRUSR|S_IWUSR )
78
#else
79
#define ALD_MM_FILE_MODE ( _S_IREAD|_S_IWRITE )
80
#endif
81
82
83
/*
84
* LDAP Cache
85
*/
86
87
/*
88
* Maintain a cache of LDAP URLs that the server handles. Each node in
89
* the cache contains the search cache for that URL, and a compare cache
90
* for the URL. The compare cash is populated when doing require group
91
* compares.
92
*/
93
typedef
struct
util_url_node_t
{
94
const
char
*
url
;
95
util_ald_cache_t
*
search_cache
;
96
util_ald_cache_t
*
compare_cache
;
97
util_ald_cache_t
*
dn_compare_cache
;
98
}
util_url_node_t
;
99
100
/*
101
* When a group is found, subgroups are stored in the group's cache entry.
102
*/
103
typedef
struct
util_compare_subgroup_t
{
104
const
char
**
subgroupDNs
;
105
int
len
;
106
}
util_compare_subgroup_t
;
107
108
/*
109
* We cache every successful search and bind operation, using the username
110
* as the key. Each node in the cache contains the returned DN, plus the
111
* password used to bind.
112
*/
113
typedef
struct
util_search_node_t
{
114
const
char
*
username
;
/* Cache key */
115
const
char
*dn;
/* DN returned from search */
116
const
char
*bindpw;
/* The most recently used bind password;
117
NULL if the bind failed */
118
apr_time_t
lastbind
;
/* Time of last successful bind */
119
const
char
**vals;
/* Values of queried attributes */
120
int
numvals
;
/* Number of queried attributes */
121
}
util_search_node_t
;
122
123
/*
124
* We cache every successful compare operation, using the DN, attrib, and
125
* value as the key.
126
*/
127
typedef
struct
util_compare_node_t
{
128
const
char
*dn;
/* DN, attrib and value combine to be the key */
129
const
char
*
attrib
;
130
const
char
*
value
;
131
apr_time_t
lastcompare
;
132
int
result
;
133
int
sgl_processed
;
/* 0 if no sgl processing yet. 1 if sgl has been processed (even if SGL is NULL). Saves repeat work on leaves. */
134
struct
util_compare_subgroup_t
*
subgroupList
;
135
}
util_compare_node_t
;
136
137
/*
138
* We cache every successful compare dn operation, using the dn in the require
139
* statement and the dn fetched based on the client-provided username.
140
*/
141
typedef
struct
util_dn_compare_node_t
{
142
const
char
*
reqdn
;
/* The DN in the require dn statement */
143
const
char
*dn;
/* The DN found in the search */
144
}
util_dn_compare_node_t
;
145
146
147
/*
148
* Function prototypes for LDAP cache
149
*/
150
151
/* util_ldap_cache.c */
152
unsigned
long
util_ldap_url_node_hash
(
void
*
n
);
153
int
util_ldap_url_node_compare
(
void
*
a
,
void
*
b
);
154
void
*
util_ldap_url_node_copy
(
util_ald_cache_t
*
cache
,
void
*
c
);
155
void
util_ldap_url_node_free
(
util_ald_cache_t
*
cache
,
void
*
n
);
156
void
util_ldap_url_node_display
(
request_rec
*
r
,
util_ald_cache_t
*
cache
,
void
*
n
);
157
158
unsigned
long
util_ldap_search_node_hash
(
void
*
n
);
159
int
util_ldap_search_node_compare
(
void
*
a
,
void
*
b
);
160
void
*
util_ldap_search_node_copy
(
util_ald_cache_t
*
cache
,
void
*
c
);
161
void
util_ldap_search_node_free
(
util_ald_cache_t
*
cache
,
void
*
n
);
162
void
util_ldap_search_node_display
(
request_rec
*
r
,
util_ald_cache_t
*
cache
,
void
*
n
);
163
164
unsigned
long
util_ldap_compare_node_hash
(
void
*
n
);
165
int
util_ldap_compare_node_compare
(
void
*
a
,
void
*
b
);
166
void
*
util_ldap_compare_node_copy
(
util_ald_cache_t
*
cache
,
void
*
c
);
167
void
util_ldap_compare_node_free
(
util_ald_cache_t
*
cache
,
void
*
n
);
168
void
util_ldap_compare_node_display
(
request_rec
*
r
,
util_ald_cache_t
*
cache
,
void
*
n
);
169
170
unsigned
long
util_ldap_dn_compare_node_hash
(
void
*
n
);
171
int
util_ldap_dn_compare_node_compare
(
void
*
a
,
void
*
b
);
172
void
*
util_ldap_dn_compare_node_copy
(
util_ald_cache_t
*
cache
,
void
*
c
);
173
void
util_ldap_dn_compare_node_free
(
util_ald_cache_t
*
cache
,
void
*
n
);
174
void
util_ldap_dn_compare_node_display
(
request_rec
*
r
,
util_ald_cache_t
*
cache
,
void
*
n
);
175
176
177
/* util_ldap_cache_mgr.c */
178
179
/* Cache alloc and free function, dealing or not with shm */
180
void
util_ald_free
(
util_ald_cache_t
*
cache
,
const
void
*ptr);
181
void
*
util_ald_alloc
(
util_ald_cache_t
*
cache
,
unsigned
long
size
);
182
const
char
*
util_ald_strdup
(
util_ald_cache_t
*
cache
,
const
char
*
s
);
183
util_compare_subgroup_t
*
util_ald_sgl_dup
(
util_ald_cache_t
*
cache
,
util_compare_subgroup_t
*
sgl
);
184
void
util_ald_sgl_free
(
util_ald_cache_t
*
cache
,
util_compare_subgroup_t
**
sgl
);
185
186
/* Cache managing function */
187
unsigned
long
util_ald_hash_string
(
int
nstr
, ...);
188
void
util_ald_cache_purge
(
util_ald_cache_t
*
cache
);
189
util_url_node_t
*
util_ald_create_caches
(
util_ldap_state_t
*
s
,
const
char
*
url
);
190
util_ald_cache_t
*
util_ald_create_cache
(
util_ldap_state_t
*
st
,
191
long
cache_size
,
192
long
cache_ttl
,
193
unsigned
long
(*
hashfunc
)(
void
*),
194
int
(*
comparefunc
)(
void
*,
void
*),
195
void
* (*
copyfunc
)(
util_ald_cache_t
*
cache
,
void
*),
196
void
(*
freefunc
)(
util_ald_cache_t
*
cache
,
void
*),
197
void
(*
displayfunc
)(
request_rec
*
r
,
util_ald_cache_t
*
cache
,
void
*));
198
199
void
util_ald_destroy_cache
(
util_ald_cache_t
*
cache
);
200
void
*
util_ald_cache_fetch
(
util_ald_cache_t
*
cache
,
void
*
payload
);
201
void
*
util_ald_cache_insert
(
util_ald_cache_t
*
cache
,
void
*
payload
);
202
void
util_ald_cache_remove
(
util_ald_cache_t
*
cache
,
void
*
payload
);
203
char
*
util_ald_cache_display_stats
(
request_rec
*
r
,
util_ald_cache_t
*
cache
,
char
*
name
,
char
*
id
);
204
205
#endif
/* APR_HAS_LDAP */
206
#endif
/* APU_LDAP_CACHE_H */
n
int n
Definition
ap_regex.h:278
len
const char apr_size_t len
Definition
ap_regex.h:187
hash
#define hash(h, r, b, n)
Definition
apr_random.c:51
r
request_rec * r
Definition
http_config.h:1168
a
apr_bucket apr_bucket_brigade * a
Definition
apr_buckets.h:700
url
const char * url
Definition
apr_escape.h:120
size
apr_size_t size
Definition
apr_allocator.h:115
value
const char * value
Definition
apr_env.h:51
result
apr_array_header_t ** result
Definition
apr_fnmatch.h:144
c
apr_vformatter_buff_t * c
Definition
apr_lib.h:175
ttl
apr_byte_t ttl
Definition
apr_network_io.h:925
b
apr_pool_t * b
Definition
apr_pools.h:529
s
const char * s
Definition
apr_strings.h:95
username
const char * username
Definition
apr_thread_proc.h:571
apr_time_t
apr_int64_t apr_time_t
Definition
apr_time.h:45
name
char * name
Definition
ssl_engine_vars.c:563
apr_rmm_t
Definition
apr_rmm.c:69
apr_shm_t
Definition
apr_arch_shm.h:61
cache
Definition
mod_rewrite.c:374
request_rec
A structure that represents the current request.
Definition
httpd.h:845
util_ldap.h
Apache LDAP library.
int
typedef int(WSAAPI *apr_winapi_fpt_WSAPoll)(IN OUT LPWSAPOLLFD fdArray
Generated by
1.9.8