1 /* accesslog.c - log operations for audit/history purposes */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2005-2006 The OpenLDAP Foundation.
6 * Portions copyright 2004-2005 Symas Corporation.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in the file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by Howard Chu for inclusion in
24 #ifdef SLAPD_OVER_ACCESSLOG
28 #include <ac/string.h>
36 #define LOG_OP_ADD 0x001
37 #define LOG_OP_DELETE 0x002
38 #define LOG_OP_MODIFY 0x004
39 #define LOG_OP_MODRDN 0x008
40 #define LOG_OP_COMPARE 0x010
41 #define LOG_OP_SEARCH 0x020
42 #define LOG_OP_BIND 0x040
43 #define LOG_OP_UNBIND 0x080
44 #define LOG_OP_ABANDON 0x100
45 #define LOG_OP_EXTENDED 0x200
46 #define LOG_OP_UNKNOWN 0x400
48 #define LOG_OP_WRITES (LOG_OP_ADD|LOG_OP_DELETE|LOG_OP_MODIFY|LOG_OP_MODRDN)
49 #define LOG_OP_READS (LOG_OP_COMPARE|LOG_OP_SEARCH)
50 #define LOG_OP_SESSION (LOG_OP_BIND|LOG_OP_UNBIND|LOG_OP_ABANDON)
51 #define LOG_OP_ALL (LOG_OP_READS|LOG_OP_WRITES|LOG_OP_SESSION| \
52 LOG_OP_EXTENDED|LOG_OP_UNKNOWN)
54 typedef struct log_info {
61 ldap_pvt_thread_mutex_t li_op_mutex;
62 ldap_pvt_thread_mutex_t li_log_mutex;
65 static ConfigDriver log_cf_gen;
74 static ConfigTable log_cfats[] = {
75 { "logdb", "suffix", 2, 2, 0, ARG_DN|ARG_MAGIC|LOG_DB,
76 log_cf_gen, "( OLcfgOvAt:4.1 NAME 'olcAccessLogDB' "
77 "DESC 'Suffix of database for log content' "
78 "SUP distinguishedName SINGLE-VALUE )", NULL, NULL },
79 { "logops", "op|writes|reads|session|all", 2, 0, 0,
81 log_cf_gen, "( OLcfgOvAt:4.2 NAME 'olcAccessLogOps' "
82 "DESC 'Operation types to log' "
83 "EQUALITY caseIgnoreMatch "
84 "SYNTAX OMsDirectoryString )", NULL, NULL },
85 { "logpurge", "age> <interval", 3, 3, 0, ARG_MAGIC|LOG_PURGE,
86 log_cf_gen, "( OLcfgOvAt:4.3 NAME 'olcAccessLogPurge' "
87 "DESC 'Log cleanup parameters' "
88 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
89 { "logsuccess", NULL, 2, 2, 0, ARG_MAGIC|ARG_ON_OFF|LOG_SUCCESS,
90 log_cf_gen, "( OLcfgOvAt:4.4 NAME 'olcAccessLogSuccess' "
91 "DESC 'Log successful ops only' "
92 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
96 static ConfigOCs log_cfocs[] = {
98 "NAME 'olcAccessLogConfig' "
99 "DESC 'Access log configuration' "
100 "SUP olcOverlayConfig "
101 "MUST olcAccessLogDB "
102 "MAY ( olcAccessLogOps $ olcAccessLogPurge $ olcAccessLogSuccess ) )",
103 Cft_Overlay, log_cfats },
107 static slap_verbmasks logops[] = {
108 { BER_BVC("all"), LOG_OP_ALL },
109 { BER_BVC("writes"), LOG_OP_WRITES },
110 { BER_BVC("session"), LOG_OP_SESSION },
111 { BER_BVC("reads"), LOG_OP_READS },
112 { BER_BVC("add"), LOG_OP_ADD },
113 { BER_BVC("delete"), LOG_OP_DELETE },
114 { BER_BVC("modify"), LOG_OP_MODIFY },
115 { BER_BVC("modrdn"), LOG_OP_MODRDN },
116 { BER_BVC("compare"), LOG_OP_COMPARE },
117 { BER_BVC("search"), LOG_OP_SEARCH },
118 { BER_BVC("bind"), LOG_OP_BIND },
119 { BER_BVC("unbind"), LOG_OP_UNBIND },
120 { BER_BVC("abandon"), LOG_OP_ABANDON },
121 { BER_BVC("extended"), LOG_OP_EXTENDED },
122 { BER_BVC("unknown"), LOG_OP_UNKNOWN },
126 /* Start with "add" in logops */
144 static ObjectClass *log_ocs[LOG_EN__COUNT], *log_container;
146 #define LOG_SCHEMA_ROOT "1.3.6.1.4.1.4203.666.11.5"
148 #define LOG_SCHEMA_AT LOG_SCHEMA_ROOT ".1"
149 #define LOG_SCHEMA_OC LOG_SCHEMA_ROOT ".2"
151 static AttributeDescription *ad_reqDN, *ad_reqStart, *ad_reqEnd, *ad_reqType,
152 *ad_reqSession, *ad_reqResult, *ad_reqAuthzID, *ad_reqControls,
153 *ad_reqRespControls, *ad_reqMethod, *ad_reqAssertion, *ad_reqNewRDN,
154 *ad_reqNewSuperior, *ad_reqDeleteOldRDN, *ad_reqMod,
155 *ad_reqScope, *ad_reqFilter, *ad_reqAttr, *ad_reqEntries,
156 *ad_reqSizeLimit, *ad_reqTimeLimit, *ad_reqAttrsOnly, *ad_reqData,
157 *ad_reqId, *ad_reqMessage, *ad_reqVersion, *ad_reqDerefAliases,
158 *ad_reqReferral, *ad_reqOld;
162 AttributeDescription **ad;
164 { "( " LOG_SCHEMA_AT ".1 NAME 'reqDN' "
165 "DESC 'Target DN of request' "
166 "EQUALITY distinguishedNameMatch "
168 "SINGLE-VALUE )", &ad_reqDN },
169 { "( " LOG_SCHEMA_AT ".2 NAME 'reqStart' "
170 "DESC 'Start time of request' "
171 "EQUALITY generalizedTimeMatch "
172 "ORDERING generalizedTimeOrderingMatch "
173 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
174 "SINGLE-VALUE )", &ad_reqStart },
175 { "( " LOG_SCHEMA_AT ".3 NAME 'reqEnd' "
176 "DESC 'End time of request' "
177 "EQUALITY generalizedTimeMatch "
178 "ORDERING generalizedTimeOrderingMatch "
179 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
180 "SINGLE-VALUE )", &ad_reqEnd },
181 { "( " LOG_SCHEMA_AT ".4 NAME 'reqType' "
182 "DESC 'Type of request' "
183 "EQUALITY caseIgnoreMatch "
184 "SYNTAX OMsDirectoryString "
185 "SINGLE-VALUE )", &ad_reqType },
186 { "( " LOG_SCHEMA_AT ".5 NAME 'reqSession' "
187 "DESC 'Session ID of request' "
188 "EQUALITY caseIgnoreMatch "
189 "SYNTAX OMsDirectoryString "
190 "SINGLE-VALUE )", &ad_reqSession },
191 { "( " LOG_SCHEMA_AT ".6 NAME 'reqAuthzID' "
192 "DESC 'Authorization ID of requestor' "
193 "EQUALITY distinguishedNameMatch "
195 "SINGLE-VALUE )", &ad_reqAuthzID },
196 { "( " LOG_SCHEMA_AT ".7 NAME 'reqResult' "
197 "DESC 'Result code of request' "
198 "EQUALITY integerMatch "
199 "ORDERING integerOrderingMatch "
201 "SINGLE-VALUE )", &ad_reqResult },
202 { "( " LOG_SCHEMA_AT ".8 NAME 'reqMessage' "
203 "DESC 'Error text of request' "
204 "EQUALITY caseIgnoreMatch "
205 "SUBSTR caseIgnoreSubstringsMatch "
206 "SYNTAX OMsDirectoryString "
207 "SINGLE-VALUE )", &ad_reqMessage },
208 { "( " LOG_SCHEMA_AT ".9 NAME 'reqReferral' "
209 "DESC 'Referrals returned for request' "
210 "SUP labeledURI )", &ad_reqReferral },
211 { "( " LOG_SCHEMA_AT ".10 NAME 'reqControls' "
212 "DESC 'Request controls' "
213 "SYNTAX OMsOctetString )", &ad_reqControls },
214 { "( " LOG_SCHEMA_AT ".11 NAME 'reqRespControls' "
215 "DESC 'Response controls of request' "
216 "SYNTAX OMsOctetString )", &ad_reqRespControls },
217 { "( " LOG_SCHEMA_AT ".12 NAME 'reqId' "
218 "DESC 'ID of Request to Abandon' "
219 "EQUALITY integerMatch "
220 "ORDERING integerOrderingMatch "
222 "SINGLE-VALUE )", &ad_reqId },
223 { "( " LOG_SCHEMA_AT ".13 NAME 'reqVersion' "
224 "DESC 'Protocol version of Bind request' "
225 "EQUALITY integerMatch "
226 "ORDERING integerOrderingMatch "
228 "SINGLE-VALUE )", &ad_reqVersion },
229 { "( " LOG_SCHEMA_AT ".14 NAME 'reqMethod' "
230 "DESC 'Bind method of request' "
231 "EQUALITY caseIgnoreMatch "
232 "SYNTAX OMsDirectoryString "
233 "SINGLE-VALUE )", &ad_reqMethod },
234 { "( " LOG_SCHEMA_AT ".15 NAME 'reqAssertion' "
235 "DESC 'Compare Assertion of request' "
236 "SYNTAX OMsDirectoryString "
237 "SINGLE-VALUE )", &ad_reqAssertion },
238 { "( " LOG_SCHEMA_AT ".16 NAME 'reqMod' "
239 "DESC 'Modifications of request' "
240 "EQUALITY octetStringMatch "
241 "SUBSTR octetStringSubstringsMatch "
242 "SYNTAX OMsOctetString )", &ad_reqMod },
243 { "( " LOG_SCHEMA_AT ".17 NAME 'reqOld' "
244 "DESC 'Old values of entry before request completed' "
245 "EQUALITY octetStringMatch "
246 "SUBSTR octetStringSubstringsMatch "
247 "SYNTAX OMsOctetString )", &ad_reqOld },
248 { "( " LOG_SCHEMA_AT ".18 NAME 'reqNewRDN' "
249 "DESC 'New RDN of request' "
250 "EQUALITY distinguishedNameMatch "
252 "SINGLE-VALUE )", &ad_reqNewRDN },
253 { "( " LOG_SCHEMA_AT ".19 NAME 'reqDeleteOldRDN' "
254 "DESC 'Delete old RDN' "
255 "EQUALITY booleanMatch "
257 "SINGLE-VALUE )", &ad_reqDeleteOldRDN },
258 { "( " LOG_SCHEMA_AT ".20 NAME 'reqNewSuperior' "
259 "DESC 'New superior DN of request' "
260 "EQUALITY distinguishedNameMatch "
262 "SINGLE-VALUE )", &ad_reqNewSuperior },
263 { "( " LOG_SCHEMA_AT ".21 NAME 'reqScope' "
264 "DESC 'Scope of request' "
265 "EQUALITY caseIgnoreMatch "
266 "SYNTAX OMsDirectoryString "
267 "SINGLE-VALUE )", &ad_reqScope },
268 { "( " LOG_SCHEMA_AT ".22 NAME 'reqDerefAliases' "
269 "DESC 'Disposition of Aliases in request' "
270 "EQUALITY caseIgnoreMatch "
271 "SYNTAX OMsDirectoryString "
272 "SINGLE-VALUE )", &ad_reqDerefAliases },
273 { "( " LOG_SCHEMA_AT ".23 NAME 'reqAttrsOnly' "
274 "DESC 'Attributes and values of request' "
275 "EQUALITY booleanMatch "
277 "SINGLE-VALUE )", &ad_reqAttrsOnly },
278 { "( " LOG_SCHEMA_AT ".24 NAME 'reqFilter' "
279 "DESC 'Filter of request' "
280 "EQUALITY caseIgnoreMatch "
281 "SUBSTR caseIgnoreSubstringsMatch "
282 "SYNTAX OMsDirectoryString "
283 "SINGLE-VALUE )", &ad_reqFilter },
284 { "( " LOG_SCHEMA_AT ".25 NAME 'reqAttr' "
285 "DESC 'Attributes of request' "
286 "EQUALITY caseIgnoreMatch "
287 "SYNTAX OMsDirectoryString )", &ad_reqAttr },
288 { "( " LOG_SCHEMA_AT ".26 NAME 'reqSizeLimit' "
289 "DESC 'Size limit of request' "
290 "EQUALITY integerMatch "
291 "ORDERING integerOrderingMatch "
293 "SINGLE-VALUE )", &ad_reqSizeLimit },
294 { "( " LOG_SCHEMA_AT ".27 NAME 'reqTimeLimit' "
295 "DESC 'Time limit of request' "
296 "EQUALITY integerMatch "
297 "ORDERING integerOrderingMatch "
299 "SINGLE-VALUE )", &ad_reqTimeLimit },
300 { "( " LOG_SCHEMA_AT ".28 NAME 'reqEntries' "
301 "DESC 'Number of entries returned' "
302 "EQUALITY integerMatch "
303 "ORDERING integerOrderingMatch "
305 "SINGLE-VALUE )", &ad_reqEntries },
306 { "( " LOG_SCHEMA_AT ".29 NAME 'reqData' "
307 "DESC 'Data of extended request' "
308 "EQUALITY octetStringMatch "
309 "SUBSTR octetStringSubstringsMatch "
310 "SYNTAX OMsOctetString "
311 "SINGLE-VALUE )", &ad_reqData },
319 { "( " LOG_SCHEMA_OC ".0 NAME 'auditContainer' "
320 "DESC 'AuditLog container' "
321 "SUP top STRUCTURAL "
322 "MAY ( cn $ reqStart $ reqEnd ) )", &log_container },
323 { "( " LOG_SCHEMA_OC ".1 NAME 'auditObject' "
324 "DESC 'OpenLDAP request auditing' "
325 "SUP top STRUCTURAL "
326 "MUST ( reqStart $ reqType $ reqSession ) "
327 "MAY ( reqDN $ reqAuthzID $ reqControls $ reqRespControls $ reqEnd $ "
328 "reqResult $ reqMessage $ reqReferral ) )",
329 &log_ocs[LOG_EN_UNBIND] },
330 { "( " LOG_SCHEMA_OC ".2 NAME 'auditReadObject' "
331 "DESC 'OpenLDAP read request record' "
332 "SUP auditObject STRUCTURAL )", NULL },
333 { "( " LOG_SCHEMA_OC ".3 NAME 'auditWriteObject' "
334 "DESC 'OpenLDAP write request record' "
335 "SUP auditObject STRUCTURAL )", NULL },
336 { "( " LOG_SCHEMA_OC ".4 NAME 'auditAbandon' "
337 "DESC 'Abandon operation' "
338 "SUP auditObject STRUCTURAL "
339 "MUST reqId )", &log_ocs[LOG_EN_ABANDON] },
340 { "( " LOG_SCHEMA_OC ".5 NAME 'auditAdd' "
341 "DESC 'Add operation' "
342 "SUP auditWriteObject STRUCTURAL "
343 "MUST reqMod )", &log_ocs[LOG_EN_ADD] },
344 { "( " LOG_SCHEMA_OC ".6 NAME 'auditBind' "
345 "DESC 'Bind operation' "
346 "SUP auditObject STRUCTURAL "
347 "MUST ( reqVersion $ reqMethod ) )", &log_ocs[LOG_EN_BIND] },
348 { "( " LOG_SCHEMA_OC ".7 NAME 'auditCompare' "
349 "DESC 'Compare operation' "
350 "SUP auditReadObject STRUCTURAL "
351 "MUST reqAssertion )", &log_ocs[LOG_EN_COMPARE] },
352 { "( " LOG_SCHEMA_OC ".8 NAME 'auditDelete' "
353 "DESC 'Delete operation' "
354 "SUP auditWriteObject STRUCTURAL "
355 "MAY reqOld )", &log_ocs[LOG_EN_DELETE] },
356 { "( " LOG_SCHEMA_OC ".9 NAME 'auditModify' "
357 "DESC 'Modify operation' "
358 "SUP auditWriteObject STRUCTURAL "
359 "MAY reqOld MUST reqMod )", &log_ocs[LOG_EN_MODIFY] },
360 { "( " LOG_SCHEMA_OC ".10 NAME 'auditModRDN' "
361 "DESC 'ModRDN operation' "
362 "SUP auditWriteObject STRUCTURAL "
363 "MUST ( reqNewRDN $ reqDeleteOldRDN ) "
364 "MAY reqNewSuperior )", &log_ocs[LOG_EN_MODRDN] },
365 { "( " LOG_SCHEMA_OC ".11 NAME 'auditSearch' "
366 "DESC 'Search operation' "
367 "SUP auditReadObject STRUCTURAL "
368 "MUST ( reqScope $ reqDerefAliases $ reqAttrsonly ) "
369 "MAY ( reqFilter $ reqAttr $ reqEntries $ reqSizeLimit $ "
370 "reqTimeLimit ) )", &log_ocs[LOG_EN_SEARCH] },
371 { "( " LOG_SCHEMA_OC ".12 NAME 'auditExtended' "
372 "DESC 'Extended operation' "
373 "SUP auditObject STRUCTURAL "
374 "MAY reqData )", &log_ocs[LOG_EN_EXTENDED] },
378 #define RDNEQ "reqStart="
380 /* Our time intervals are of the form [ddd+]hh:mm[:ss]
381 * If a field is present, it must be two digits. (Except for
382 * days, which can be arbitrary width.)
385 log_age_parse(char *agestr)
391 t1 = strtol( agestr, &endptr, 10 );
392 /* Is there a days delimiter? */
393 if ( *endptr == '+' ) {
394 /* 32 bit time only covers about 68 years */
395 if ( t1 < 0 || t1 > 25000 )
399 } else if ( *endptr != ':' ) {
400 /* No valid delimiter found, fail */
407 /* if there's a delimiter, it can only be a colon */
408 if ( agestr[2] && agestr[2] != ':' )
411 /* If we're at the end of the string, and we started with days,
412 * fail because we expected to find minutes too.
414 if ( gotdays && !agestr[2] )
426 /* last field can only be seconds */
427 if ( agestr[2] && ( agestr[2] != ':' || !gotdays ))
437 t1 += atoi( agestr );
443 log_age_unparse( int age, struct berval *agebv )
459 ptr += sprintf( ptr, "%d+", dd );
460 ptr += sprintf( ptr, "%02d:%02d", hh, mm );
462 ptr += sprintf( ptr, ":%02d", ss );
464 agebv->bv_len = ptr - agebv->bv_val;
467 static slap_callback nullsc = { NULL, NULL, NULL, NULL };
469 #define PURGE_INCREMENT 100
471 typedef struct purge_data {
479 log_old_lookup( Operation *op, SlapReply *rs )
481 purge_data *pd = op->o_callback->sc_private;
483 if ( rs->sr_type != REP_SEARCH) return 0;
485 if ( pd->used >= pd->slots ) {
486 pd->slots += PURGE_INCREMENT;
487 pd->dn = ch_realloc( pd->dn, pd->slots * sizeof( struct berval ));
488 pd->ndn = ch_realloc( pd->ndn, pd->slots * sizeof( struct berval ));
490 ber_dupbv( &pd->dn[pd->used], &rs->sr_entry->e_name );
491 ber_dupbv( &pd->ndn[pd->used], &rs->sr_entry->e_nname );
496 /* Periodically search for old entries in the log database and delete them */
498 accesslog_purge( void *ctx, void *arg )
500 struct re_s *rtask = arg;
501 struct log_info *li = rtask->arg;
503 Connection conn = {0};
504 OperationBuffer opbuf;
505 Operation *op = (Operation *) &opbuf;
506 SlapReply rs = {REP_RESULT};
507 slap_callback cb = { NULL, log_old_lookup, NULL, NULL };
509 AttributeAssertion ava = {0};
511 char timebuf[LDAP_LUTIL_GENTIME_BUFSIZE];
512 time_t old = slap_get_time();
514 connection_fake_init( &conn, op, ctx );
516 f.f_choice = LDAP_FILTER_LE;
520 ava.aa_desc = ad_reqStart;
521 ava.aa_value.bv_val = timebuf;
522 ava.aa_value.bv_len = sizeof(timebuf);
525 slap_timestamp( &old, &ava.aa_value );
527 op->o_tag = LDAP_REQ_SEARCH;
528 op->o_bd = li->li_db;
529 op->o_dn = li->li_db->be_rootdn;
530 op->o_ndn = li->li_db->be_rootndn;
531 op->o_req_dn = li->li_db->be_suffix[0];
532 op->o_req_ndn = li->li_db->be_nsuffix[0];
533 op->o_callback = &cb;
534 op->ors_scope = LDAP_SCOPE_ONELEVEL;
535 op->ors_deref = LDAP_DEREF_NEVER;
536 op->ors_tlimit = SLAP_NO_LIMIT;
537 op->ors_slimit = SLAP_NO_LIMIT;
539 filter2bv_x( op, &f, &op->ors_filterstr );
540 op->ors_attrs = slap_anlist_no_attrs;
541 op->ors_attrsonly = 1;
545 op->o_bd->be_search( op, &rs );
546 op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
551 op->o_tag = LDAP_REQ_DELETE;
552 op->o_callback = &nullsc;
554 for (i=0; i<pd.used; i++) {
555 op->o_req_dn = pd.dn[i];
556 op->o_req_ndn = pd.ndn[i];
557 op->o_bd->be_delete( op, &rs );
558 ch_free( pd.ndn[i].bv_val );
559 ch_free( pd.dn[i].bv_val );
565 ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
566 ldap_pvt_runqueue_stoptask( &slapd_rq, rtask );
567 ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
573 log_cf_gen(ConfigArgs *c)
575 slap_overinst *on = (slap_overinst *)c->bi;
576 struct log_info *li = on->on_bi.bi_private;
578 slap_mask_t tmask = 0;
579 char agebuf[2*STRLENOF("ddddd+hh:mm:ss ")];
580 struct berval agebv, cyclebv;
583 case SLAP_CONFIG_EMIT:
586 value_add( &c->rvalue_vals, li->li_db->be_suffix );
587 value_add( &c->rvalue_nvals, li->li_db->be_nsuffix );
590 rc = mask_to_verbs( logops, li->li_ops, &c->rvalue_vals );
593 agebv.bv_val = agebuf;
594 log_age_unparse( li->li_age, &agebv );
595 agebv.bv_val[agebv.bv_len] = ' ';
597 cyclebv.bv_val = agebv.bv_val + agebv.bv_len;
598 log_age_unparse( li->li_cycle, &cyclebv );
599 agebv.bv_len += cyclebv.bv_len;
600 value_add_one( &c->rvalue_vals, &agebv );
603 if ( li->li_success )
604 c->value_int = li->li_success;
610 case LDAP_MOD_DELETE:
613 /* noop. this should always be a valid backend. */
619 rc = verbs_to_mask( 1, &c->line, logops, &tmask );
621 li->li_ops &= ~tmask;
626 struct re_s *re = li->li_task;
628 if ( ldap_pvt_runqueue_isrunning( &slapd_rq, re ))
629 ldap_pvt_runqueue_stoptask( &slapd_rq, re );
630 ldap_pvt_runqueue_remove( &slapd_rq, re );
643 li->li_db = select_backend( &c->value_ndn, 0, 0 );
645 sprintf( c->msg, "<%s> no matching backend found for suffix",
647 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
648 c->log, c->msg, c->value_dn.bv_val );
651 ch_free( c->value_dn.bv_val );
652 ch_free( c->value_ndn.bv_val );
655 rc = verbs_to_mask( c->argc, c->argv, logops, &tmask );
660 li->li_age = log_age_parse( c->argv[1] );
661 if ( li->li_age == -1 ) {
664 li->li_cycle = log_age_parse( c->argv[2] );
665 if ( li->li_cycle == -1 ) {
667 } else if ( slapMode & SLAP_SERVER_MODE ) {
668 struct re_s *re = li->li_task;
670 re->interval.tv_sec = li->li_cycle;
672 li->li_task = ldap_pvt_runqueue_insert( &slapd_rq,
673 li->li_cycle, accesslog_purge, li,
674 "accesslog_purge", li->li_db ?
675 li->li_db->be_suffix[0].bv_val :
676 c->be->be_suffix[0].bv_val );
681 li->li_success = c->value_int;
689 static Entry *accesslog_entry( Operation *op, int logop,
691 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
692 log_info *li = on->on_bi.bi_private;
694 char rdnbuf[STRLENOF(RDNEQ)+LDAP_LUTIL_GENTIME_BUFSIZE+8];
695 char nrdnbuf[STRLENOF(RDNEQ)+LDAP_LUTIL_GENTIME_BUFSIZE+8];
697 struct berval rdn, nrdn, timestamp, ntimestamp, bv;
698 slap_verbmasks *lo = logops+logop+EN_OFFSET;
700 Entry *e = ch_calloc( 1, sizeof(Entry) );
702 strcpy( rdnbuf, RDNEQ );
704 strcpy( nrdnbuf, RDNEQ );
705 nrdn.bv_val = nrdnbuf;
707 timestamp.bv_val = rdnbuf+STRLENOF(RDNEQ);
708 timestamp.bv_len = sizeof(rdnbuf) - STRLENOF(RDNEQ);
709 slap_timestamp( &op->o_time, ×tamp );
710 sprintf( timestamp.bv_val + timestamp.bv_len-1, ".%06dZ", op->o_tincr );
711 timestamp.bv_len += 7;
713 rdn.bv_len = STRLENOF(RDNEQ)+timestamp.bv_len;
714 ad_reqStart->ad_type->sat_equality->smr_normalize(
715 SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, ad_reqStart->ad_type->sat_syntax,
716 ad_reqStart->ad_type->sat_equality, ×tamp, &ntimestamp,
719 strcpy( nrdn.bv_val + STRLENOF(RDNEQ), ntimestamp.bv_val );
720 nrdn.bv_len = STRLENOF(RDNEQ)+ntimestamp.bv_len;
721 build_new_dn( &e->e_name, li->li_db->be_suffix, &rdn, NULL );
722 build_new_dn( &e->e_nname, li->li_db->be_nsuffix, &nrdn, NULL );
724 attr_merge_one( e, slap_schema.si_ad_objectClass,
725 &log_ocs[logop]->soc_cname, NULL );
726 attr_merge_one( e, slap_schema.si_ad_structuralObjectClass,
727 &log_ocs[logop]->soc_cname, NULL );
728 attr_merge_one( e, ad_reqStart, ×tamp, &ntimestamp );
729 op->o_tmpfree( ntimestamp.bv_val, op->o_tmpmemctx );
731 slap_op_time( &op2->o_time, &op2->o_tincr );
733 timestamp.bv_len = sizeof(rdnbuf) - STRLENOF(RDNEQ);
734 slap_timestamp( &op2->o_time, ×tamp );
735 sprintf( timestamp.bv_val + timestamp.bv_len-1, ".%06dZ", op2->o_tincr );
736 timestamp.bv_len += 7;
738 attr_merge_normalize_one( e, ad_reqEnd, ×tamp, op->o_tmpmemctx );
740 /* Exops have OID appended */
741 if ( logop == LOG_EN_EXTENDED ) {
742 bv.bv_len = lo->word.bv_len + op->ore_reqoid.bv_len + 2;
743 bv.bv_val = ch_malloc( bv.bv_len + 1 );
744 AC_MEMCPY( bv.bv_val, lo->word.bv_val, lo->word.bv_len );
745 bv.bv_val[lo->word.bv_len] = '{';
746 AC_MEMCPY( bv.bv_val+lo->word.bv_len+1, op->ore_reqoid.bv_val,
747 op->ore_reqoid.bv_len );
748 bv.bv_val[bv.bv_len-1] = '}';
749 bv.bv_val[bv.bv_len] = '\0';
750 attr_merge_one( e, ad_reqType, &bv, NULL );
752 attr_merge_one( e, ad_reqType, &lo->word, NULL );
755 rdn.bv_len = sprintf( rdn.bv_val, "%lu", op->o_connid );
756 attr_merge_one( e, ad_reqSession, &rdn, NULL );
758 if ( BER_BVISNULL( &op->o_dn ))
759 attr_merge_one( e, ad_reqAuthzID, (struct berval *)&slap_empty_bv,
760 (struct berval *)&slap_empty_bv );
762 attr_merge_one( e, ad_reqAuthzID, &op->o_dn, &op->o_ndn );
764 /* FIXME: need to add reqControls and reqRespControls */
769 static struct berval scopes[] = {
776 static struct berval derefs[] = {
778 BER_BVC("searching"),
783 static struct berval simple = BER_BVC("SIMPLE");
785 static int accesslog_response(Operation *op, SlapReply *rs) {
786 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
787 log_info *li = on->on_bi.bi_private;
788 Attribute *a, *last_attr;
795 char timebuf[LDAP_LUTIL_GENTIME_BUFSIZE+8];
800 SlapReply rs2 = {REP_RESULT};
802 if ( rs->sr_type != REP_RESULT && rs->sr_type != REP_EXTENDED )
803 return SLAP_CB_CONTINUE;
805 switch ( op->o_tag ) {
806 case LDAP_REQ_ADD: logop = LOG_EN_ADD; break;
807 case LDAP_REQ_DELETE: logop = LOG_EN_DELETE; break;
808 case LDAP_REQ_MODIFY: logop = LOG_EN_MODIFY; break;
809 case LDAP_REQ_MODRDN: logop = LOG_EN_MODRDN; break;
810 case LDAP_REQ_COMPARE: logop = LOG_EN_COMPARE; break;
811 case LDAP_REQ_SEARCH: logop = LOG_EN_SEARCH; break;
812 case LDAP_REQ_BIND: logop = LOG_EN_BIND; break;
813 case LDAP_REQ_EXTENDED: logop = LOG_EN_EXTENDED; break;
814 default: /* unknown operation type */
815 logop = LOG_EN_UNKNOWN; break;
816 } /* Unbind and Abandon never reach here */
818 lo = logops+logop+EN_OFFSET;
819 if ( !( li->li_ops & lo->mask ))
820 return SLAP_CB_CONTINUE;
822 if ( lo->mask & LOG_OP_WRITES ) {
823 ldap_pvt_thread_mutex_lock( &li->li_log_mutex );
824 ldap_pvt_thread_mutex_unlock( &li->li_op_mutex );
827 if ( li->li_success && rs->sr_err != LDAP_SUCCESS )
830 e = accesslog_entry( op, logop, &op2 );
832 attr_merge_one( e, ad_reqDN, &op->o_req_dn, &op->o_req_ndn );
835 ber_str2bv( rs->sr_text, 0, 0, &bv );
836 attr_merge_one( e, ad_reqMessage, &bv, NULL );
838 bv.bv_len = sprintf( timebuf, "%d", rs->sr_err );
841 attr_merge_one( e, ad_reqResult, &bv, NULL );
843 last_attr = attr_find( e->e_attrs, ad_reqResult );
847 /* count all the vals */
849 for ( a=op->ora_e->e_attrs; a; a=a->a_next ) {
851 for (b=a->a_vals; !BER_BVISNULL( b ); b++) {
856 vals = ch_malloc( (i+1) * sizeof( struct berval ));
858 for ( a=op->ora_e->e_attrs; a; a=a->a_next ) {
860 for (b=a->a_vals; !BER_BVISNULL( b ); b++,i++) {
861 vals[i].bv_len = a->a_desc->ad_cname.bv_len + b->bv_len +3;
862 vals[i].bv_val = ch_malloc( vals[i].bv_len+1 );
863 ptr = lutil_strcopy( vals[i].bv_val,
864 a->a_desc->ad_cname.bv_val );
868 AC_MEMCPY( ptr, b->bv_val, b->bv_len );
869 vals[i].bv_val[vals[i].bv_len] = '\0';
873 vals[i].bv_val = NULL;
875 a = attr_alloc( ad_reqMod );
878 last_attr->a_next = a;
882 /* needs nothing else */
886 /* count all the mods */
888 for ( m=op->orm_modlist; m; m=m->sml_next ) {
889 if ( m->sml_values ) {
890 for (b=m->sml_values; !BER_BVISNULL( b ); b++) {
893 } else if ( m->sml_op == LDAP_MOD_DELETE ) {
897 vals = ch_malloc( (i+1) * sizeof( struct berval ));
899 for ( m=op->orm_modlist; m; m=m->sml_next ) {
900 if ( m->sml_values ) {
901 for (b=m->sml_values; !BER_BVISNULL( b ); b++,i++) {
903 vals[i].bv_len = m->sml_desc->ad_cname.bv_len + b->bv_len +3;
904 vals[i].bv_val = ch_malloc( vals[i].bv_len+1 );
905 ptr = lutil_strcopy( vals[i].bv_val,
906 m->sml_desc->ad_cname.bv_val );
908 switch( m->sml_op ) {
909 case LDAP_MOD_ADD: c_op = '+'; break;
910 case LDAP_MOD_DELETE: c_op = '-'; break;
911 case LDAP_MOD_REPLACE: c_op = '='; break;
912 case LDAP_MOD_INCREMENT: c_op = '#'; break;
914 /* unknown op. there shouldn't be any of these. we
915 * don't know what to do with it, but we shouldn't just
918 default: c_op = '?'; break;
922 AC_MEMCPY( ptr, b->bv_val, b->bv_len );
923 vals[i].bv_val[vals[i].bv_len] = '\0';
925 } else if ( m->sml_op == LDAP_MOD_DELETE ) {
926 vals[i].bv_len = m->sml_desc->ad_cname.bv_len + 2;
927 vals[i].bv_val = ch_malloc( vals[i].bv_len+1 );
928 ptr = lutil_strcopy( vals[i].bv_val,
929 m->sml_desc->ad_cname.bv_val );
936 vals[i].bv_val = NULL;
938 a = attr_alloc( ad_reqMod );
941 last_attr->a_next = a;
945 attr_merge_one( e, ad_reqNewRDN, &op->orr_newrdn, &op->orr_nnewrdn );
946 attr_merge_one( e, ad_reqDeleteOldRDN, op->orr_deleteoldrdn ?
947 (struct berval *)&slap_true_bv : (struct berval *)&slap_false_bv,
949 if ( op->orr_newSup ) {
950 attr_merge_one( e, ad_reqNewSuperior, op->orr_newSup, op->orr_nnewSup );
955 bv.bv_len = op->orc_ava->aa_desc->ad_cname.bv_len + 1 +
956 op->orc_ava->aa_value.bv_len;
957 bv.bv_val = op->o_tmpalloc( bv.bv_len+1, op->o_tmpmemctx );
958 ptr = lutil_strcopy( bv.bv_val, op->orc_ava->aa_desc->ad_cname.bv_val );
960 AC_MEMCPY( ptr, op->orc_ava->aa_value.bv_val, op->orc_ava->aa_value.bv_len );
961 bv.bv_val[bv.bv_len] = '\0';
962 attr_merge_one( e, ad_reqAssertion, &bv, NULL );
963 op->o_tmpfree( bv.bv_val, op->o_tmpmemctx );
967 attr_merge_one( e, ad_reqScope, &scopes[op->ors_scope], NULL );
968 attr_merge_one( e, ad_reqDerefAliases, &derefs[op->ors_deref], NULL );
969 attr_merge_one( e, ad_reqAttrsOnly, op->ors_attrsonly ?
970 (struct berval *)&slap_true_bv : (struct berval *)&slap_false_bv,
972 if ( !BER_BVISEMPTY( &op->ors_filterstr ))
973 attr_merge_one( e, ad_reqFilter, &op->ors_filterstr, NULL );
974 if ( op->ors_attrs ) {
976 for (i=0; !BER_BVISNULL(&op->ors_attrs[i].an_name );i++)
978 vals = op->o_tmpalloc( (i+1) * sizeof(struct berval),
980 for (i=0; !BER_BVISNULL(&op->ors_attrs[i].an_name );i++)
981 vals[i] = op->ors_attrs[i].an_name;
982 vals[i].bv_val = NULL;
984 attr_merge( e, ad_reqAttr, vals, NULL );
985 op->o_tmpfree( vals, op->o_tmpmemctx );
988 bv.bv_len = sprintf( bv.bv_val, "%d", rs->sr_nentries );
989 attr_merge_one( e, ad_reqEntries, &bv, NULL );
991 bv.bv_len = sprintf( bv.bv_val, "%d", op->ors_tlimit );
992 attr_merge_one( e, ad_reqTimeLimit, &bv, NULL );
994 bv.bv_len = sprintf( bv.bv_val, "%d", op->ors_slimit );
995 attr_merge_one( e, ad_reqSizeLimit, &bv, NULL );
1000 bv.bv_len = sprintf( bv.bv_val, "%d", op->o_protocol );
1001 attr_merge_one( e, ad_reqVersion, &bv, NULL );
1002 if ( op->orb_method == LDAP_AUTH_SIMPLE ) {
1003 attr_merge_one( e, ad_reqMethod, &simple, NULL );
1005 bv.bv_len = STRLENOF("SASL()") + op->orb_tmp_mech.bv_len;
1006 bv.bv_val = op->o_tmpalloc( bv.bv_len + 1, op->o_tmpmemctx );
1007 ptr = lutil_strcopy( bv.bv_val, "SASL(" );
1008 ptr = lutil_strcopy( ptr, op->orb_tmp_mech.bv_val );
1011 attr_merge_one( e, ad_reqMethod, &bv, NULL );
1012 op->o_tmpfree( bv.bv_val, op->o_tmpmemctx );
1017 case LOG_EN_EXTENDED:
1018 if ( op->ore_reqdata ) {
1019 attr_merge_one( e, ad_reqData, op->ore_reqdata, NULL );
1023 case LOG_EN_UNKNOWN:
1024 /* we don't know its parameters, don't add any */
1028 op2.o_hdr = op->o_hdr;
1029 op2.o_tag = LDAP_REQ_ADD;
1030 op2.o_bd = li->li_db;
1031 op2.o_dn = li->li_db->be_rootdn;
1032 op2.o_ndn = li->li_db->be_rootndn;
1033 op2.o_req_dn = e->e_name;
1034 op2.o_req_ndn = e->e_nname;
1036 op2.o_callback = &nullsc;
1038 if (( lo->mask & LOG_OP_WRITES ) && !BER_BVISEMPTY( &op->o_csn )) {
1039 slap_queue_csn( &op2, &op->o_csn );
1042 op2.o_bd->be_add( &op2, &rs2 );
1046 ldap_pvt_thread_mutex_unlock( &li->li_log_mutex );
1047 return SLAP_CB_CONTINUE;
1050 /* Since Bind success is sent by the frontend, it won't normally enter
1051 * the overlay response callback. Add another callback to make sure it
1055 accesslog_bind_resp( Operation *op, SlapReply *rs )
1064 db.bd_info = op->o_callback->sc_private;
1065 rc = accesslog_response( op, rs );
1067 sc = op->o_callback;
1068 op->o_callback = sc->sc_next;
1069 op->o_tmpfree( sc, op->o_tmpmemctx );
1074 accesslog_op_bind( Operation *op, SlapReply *rs )
1078 sc = op->o_tmpcalloc( 1, sizeof(slap_callback), op->o_tmpmemctx );
1079 sc->sc_response = accesslog_bind_resp;
1080 sc->sc_private = op->o_bd->bd_info;
1082 if ( op->o_callback ) {
1083 sc->sc_next = op->o_callback->sc_next;
1084 op->o_callback->sc_next = sc;
1086 op->o_callback = sc;
1088 return SLAP_CB_CONTINUE;
1092 accesslog_op_mod( Operation *op, SlapReply *rs )
1094 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
1095 log_info *li = on->on_bi.bi_private;
1097 if ( li->li_ops & LOG_OP_WRITES ) {
1098 /* FIXME: this needs to be a recursive mutex to allow
1099 * overlays like refint to keep working.
1101 ldap_pvt_thread_mutex_lock( &li->li_op_mutex );
1103 return SLAP_CB_CONTINUE;
1106 /* unbinds are broadcast to all backends; we only log it if this
1107 * backend was used for the original bind.
1110 accesslog_unbind( Operation *op, SlapReply *rs )
1112 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
1113 if ( op->o_conn->c_authz_backend == on->on_info->oi_origdb ) {
1114 log_info *li = on->on_bi.bi_private;
1116 void *cids[SLAP_MAX_CIDS];
1117 SlapReply rs2 = {REP_RESULT};
1120 if ( !( li->li_ops & LOG_OP_UNBIND ))
1121 return SLAP_CB_CONTINUE;
1123 e = accesslog_entry( op, LOG_EN_UNBIND, &op2 );
1124 op2.o_hdr = op->o_hdr;
1125 op2.o_tag = LDAP_REQ_ADD;
1126 op2.o_bd = li->li_db;
1127 op2.o_dn = li->li_db->be_rootdn;
1128 op2.o_ndn = li->li_db->be_rootndn;
1129 op2.o_req_dn = e->e_name;
1130 op2.o_req_ndn = e->e_nname;
1132 op2.o_callback = &nullsc;
1133 op2.o_controls = cids;
1134 memset(cids, 0, sizeof( cids ));
1135 memset(op2.o_ctrlflag, 0, sizeof( op2.o_ctrlflag ));
1137 op2.o_bd->be_add( &op2, &rs2 );
1140 return SLAP_CB_CONTINUE;
1144 accesslog_abandon( Operation *op, SlapReply *rs )
1146 slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
1147 log_info *li = on->on_bi.bi_private;
1149 void *cids[SLAP_MAX_CIDS];
1150 SlapReply rs2 = {REP_RESULT};
1155 if ( !op->o_time || !( li->li_ops & LOG_OP_ABANDON ))
1156 return SLAP_CB_CONTINUE;
1158 e = accesslog_entry( op, LOG_EN_ABANDON, &op2 );
1160 bv.bv_len = sprintf( buf, "%d", op->orn_msgid );
1161 attr_merge_one( e, ad_reqId, &bv, NULL );
1163 op2.o_hdr = op->o_hdr;
1164 op2.o_tag = LDAP_REQ_ADD;
1165 op2.o_bd = li->li_db;
1166 op2.o_dn = li->li_db->be_rootdn;
1167 op2.o_ndn = li->li_db->be_rootndn;
1168 op2.o_req_dn = e->e_name;
1169 op2.o_req_ndn = e->e_nname;
1171 op2.o_callback = &nullsc;
1172 op2.o_controls = cids;
1173 memset(cids, 0, sizeof( cids ));
1174 memset(op2.o_ctrlflag, 0, sizeof( op2.o_ctrlflag ));
1176 op2.o_bd->be_add( &op2, &rs2 );
1179 return SLAP_CB_CONTINUE;
1182 static slap_overinst accesslog;
1189 slap_overinst *on = (slap_overinst *)be->bd_info;
1190 log_info *li = ch_calloc(1, sizeof(log_info));
1192 on->on_bi.bi_private = li;
1193 ldap_pvt_thread_mutex_init( &li->li_op_mutex );
1194 ldap_pvt_thread_mutex_init( &li->li_log_mutex );
1199 accesslog_db_destroy(
1203 slap_overinst *on = (slap_overinst *)be->bd_info;
1204 log_info *li = on->on_bi.bi_private;
1206 ldap_pvt_thread_mutex_destroy( &li->li_log_mutex );
1207 ldap_pvt_thread_mutex_destroy( &li->li_op_mutex );
1209 return LDAP_SUCCESS;
1217 slap_overinst *on = (slap_overinst *)be->bd_info;
1218 log_info *li = on->on_bi.bi_private;
1221 OperationBuffer opbuf;
1222 Operation *op = (Operation *) &opbuf;
1227 if ( slapMode & SLAP_TOOL_MODE )
1230 thrctx = ldap_pvt_thread_pool_context();
1231 connection_fake_init( &conn, op, thrctx );
1232 op->o_bd = li->li_db;
1233 op->o_dn = li->li_db->be_rootdn;
1234 op->o_ndn = li->li_db->be_rootndn;
1236 rc = be_entry_get_rw( op, li->li_db->be_nsuffix, NULL, NULL, 0, &e );
1239 be_entry_release_rw( op, e, 0 );
1241 SlapReply rs = {REP_RESULT};
1242 struct berval rdn, nrdn, attr;
1244 AttributeDescription *ad = NULL;
1245 const char *text = NULL;
1248 e = ch_calloc( 1, sizeof( Entry ));
1249 e->e_name = *li->li_db->be_suffix;
1250 e->e_nname = *li->li_db->be_nsuffix;
1252 attr_merge_one( e, slap_schema.si_ad_objectClass,
1253 &log_container->soc_cname, NULL );
1255 dnRdn( &e->e_name, &rdn );
1256 dnRdn( &e->e_nname, &nrdn );
1257 ptr = ber_bvchr( &rdn, '=' );
1259 assert( ptr != NULL );
1261 attr.bv_val = rdn.bv_val;
1262 attr.bv_len = ptr - rdn.bv_val;
1264 slap_bv2ad( &attr, &ad, &text );
1267 rdn.bv_len -= attr.bv_len + 1;
1268 ptr = ber_bvchr( &nrdn, '=' );
1269 nrdn.bv_len -= ptr - nrdn.bv_val + 1;
1270 nrdn.bv_val = ptr+1;
1271 attr_merge_one( e, ad, &rdn, &nrdn );
1273 /* Get contextCSN from main DB */
1275 op->o_bd->bd_info = on->on_info->oi_orig;
1276 rc = be_entry_get_rw( op, be->be_nsuffix, NULL,
1277 slap_schema.si_ad_contextCSN, 0, &e_ctx );
1282 a = attr_find( e_ctx->e_attrs, slap_schema.si_ad_contextCSN );
1284 attr_merge( e, slap_schema.si_ad_entryCSN, a->a_vals, NULL );
1285 attr_merge( e, a->a_desc, a->a_vals, NULL );
1287 be_entry_release_rw( op, e_ctx, 0 );
1289 op->o_bd->bd_info = (BackendInfo *)on;
1290 op->o_bd = li->li_db;
1293 op->o_req_dn = e->e_name;
1294 op->o_req_ndn = e->e_nname;
1295 op->o_callback = &nullsc;
1296 SLAP_DBFLAGS( op->o_bd ) |= SLAP_DBFLAG_NOLASTMOD;
1297 rc = op->o_bd->be_add( op, &rs );
1298 SLAP_DBFLAGS( op->o_bd ) ^= SLAP_DBFLAG_NOLASTMOD;
1299 attrs_free( e->e_attrs );
1302 ldap_pvt_thread_pool_context_reset( thrctx );
1306 int accesslog_initialize()
1310 accesslog.on_bi.bi_type = "accesslog";
1311 accesslog.on_bi.bi_db_init = accesslog_db_init;
1312 accesslog.on_bi.bi_db_destroy = accesslog_db_destroy;
1313 accesslog.on_bi.bi_db_open = accesslog_db_open;
1315 accesslog.on_bi.bi_op_add = accesslog_op_mod;
1316 accesslog.on_bi.bi_op_bind = accesslog_op_bind;
1317 accesslog.on_bi.bi_op_delete = accesslog_op_mod;
1318 accesslog.on_bi.bi_op_modify = accesslog_op_mod;
1319 accesslog.on_bi.bi_op_modrdn = accesslog_op_mod;
1320 accesslog.on_bi.bi_op_unbind = accesslog_unbind;
1321 accesslog.on_bi.bi_op_abandon = accesslog_abandon;
1322 accesslog.on_response = accesslog_response;
1324 accesslog.on_bi.bi_cf_ocs = log_cfocs;
1326 nullsc.sc_response = slap_null_cb;
1328 rc = config_register_schema( log_cfats, log_cfocs );
1329 if ( rc ) return rc;
1331 /* log schema integration */
1332 for ( i=0; lattrs[i].at; i++ ) {
1333 LDAPAttributeType *lat;
1338 lat = ldap_str2attributetype( lattrs[i].at, &code, &err,
1339 LDAP_SCHEMA_ALLOW_ALL );
1341 Debug( LDAP_DEBUG_ANY, "accesslog_init: "
1342 "ldap_str2attributetype failed on %d: %s, %s\n",
1343 i, ldap_scherr2str(code), err );
1346 code = at_add( lat, 0, &at, &err );
1347 ldap_memfree( lat );
1349 Debug( LDAP_DEBUG_ANY, "log_back_initialize: "
1350 "at_add failed on %d: %s\n",
1351 i, scherr2str(code), 0 );
1354 if ( slap_bv2ad( &at->sat_cname, lattrs[i].ad, &err )) {
1355 Debug( LDAP_DEBUG_ANY, "accesslog_init: "
1356 "slap_bv2ad failed on %d: %s\n",
1361 for ( i=0; locs[i].ot; i++ ) {
1362 LDAPObjectClass *loc;
1367 loc = ldap_str2objectclass( locs[i].ot, &code, &err,
1368 LDAP_SCHEMA_ALLOW_ALL );
1370 Debug( LDAP_DEBUG_ANY, "accesslog_init: "
1371 "ldap_str2objectclass failed on %d: %s, %s\n",
1372 i, ldap_scherr2str(code), err );
1376 code = oc_add( loc, 0, &oc, &err );
1377 ldap_memfree( loc );
1379 Debug( LDAP_DEBUG_ANY, "accesslog_init: "
1380 "oc_add failed on %d: %s\n",
1381 i, scherr2str(code), 0 );
1388 return overlay_register(&accesslog);
1391 #if SLAPD_OVER_ACCESSLOG == SLAPD_MOD_DYNAMIC
1393 init_module( int argc, char *argv[] )
1395 return accesslog_initialize();
1399 #endif /* SLAPD_OVER_ACCESSLOG */