X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Foverlays%2Fauditlog.c;h=55aabd40af8909c858b6c49349154c1e946a0d83;hb=2317211a8f7b1a50862bd16c29d208b62fbb387b;hp=f603c1429eec0c65c71d3606307a8456ed15a8b4;hpb=6e8f1b9b257990fa47729b61f6cbc86ddabe856f;p=openldap diff --git a/servers/slapd/overlays/auditlog.c b/servers/slapd/overlays/auditlog.c index f603c1429e..55aabd40af 100644 --- a/servers/slapd/overlays/auditlog.c +++ b/servers/slapd/overlays/auditlog.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 2005-2006 The OpenLDAP Foundation. + * Copyright 2005-2008 The OpenLDAP Foundation. * Portions copyright 2004-2005 Symas Corporation. * All rights reserved. * @@ -29,6 +29,7 @@ #include #include "slap.h" +#include "config.h" #include "ldif.h" typedef struct auditlog_data { @@ -36,6 +37,26 @@ typedef struct auditlog_data { char *ad_logfile; } auditlog_data; +static ConfigTable auditlogcfg[] = { + { "auditlog", "filename", 2, 2, 0, + ARG_STRING|ARG_OFFSET, + (void *)offsetof(auditlog_data, ad_logfile), + "( OLcfgOvAt:15.1 NAME 'olcAuditlogFile' " + "DESC 'Filename for auditlogging' " + "SYNTAX OMsDirectoryString )", NULL, NULL }, + { NULL, NULL, 0, 0, 0, ARG_IGNORED } +}; + +static ConfigOCs auditlogocs[] = { + { "( OLcfgOvOc:15.1 " + "NAME 'olcAuditlogConfig' " + "DESC 'Auditlog configuration' " + "SUP olcOverlayConfig " + "MAY ( olcAuditlogFile ) )", + Cft_Overlay, auditlogcfg }, + { NULL, 0, NULL } +}; + static int fprint_ldif(FILE *f, char *name, char *val, ber_len_t len) { char *s; if((s = ldif_put(LDIF_PUT_VALUE, name, val, len)) == NULL) @@ -107,9 +128,9 @@ static int auditlog_response(Operation *op, SlapReply *rs) { fprintf(f, "# %s %ld %s%s%s\n", what, stamp, suffix, who ? " " : "", who ? who->bv_val : ""); - if ( !who || !dn_match( who, &op->o_conn->c_dn )) - fprintf(f, "# realdn: %s\n", op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : - "" ); + if ( !BER_BVISEMPTY( &op->o_conn->c_dn ) && + (!who || !dn_match( who, &op->o_conn->c_dn ))) + fprintf(f, "# realdn: %s\n", op->o_conn->c_dn.bv_val ); fprintf(f, "dn: %s\nchangetype: %s\n", op->o_req_dn.bv_val, what); @@ -163,11 +184,12 @@ static slap_overinst auditlog; static int auditlog_db_init( - BackendDB *be + BackendDB *be, + ConfigReply *cr ) { slap_overinst *on = (slap_overinst *)be->bd_info; - auditlog_data *ad = ch_malloc(sizeof(auditlog_data)); + auditlog_data *ad = ch_calloc(1, sizeof(auditlog_data)); on->on_bi.bi_private = ad; ldap_pvt_thread_mutex_init( &ad->ad_mutex ); @@ -176,7 +198,8 @@ auditlog_db_init( static int auditlog_db_close( - BackendDB *be + BackendDB *be, + ConfigReply *cr ) { slap_overinst *on = (slap_overinst *)be->bd_info; @@ -189,7 +212,8 @@ auditlog_db_close( static int auditlog_db_destroy( - BackendDB *be + BackendDB *be, + ConfigReply *cr ) { slap_overinst *on = (slap_overinst *)be->bd_info; @@ -200,41 +224,19 @@ auditlog_db_destroy( return 0; } -static int -auditlog_config( - BackendDB *be, - const char *fname, - int lineno, - int argc, - char **argv -) -{ - slap_overinst *on = (slap_overinst *) be->bd_info; - auditlog_data *ad = on->on_bi.bi_private; - - /* history log file */ - if ( strcasecmp( argv[0], "auditlog" ) == 0 ) { - if ( argc < 2 ) { - Debug( LDAP_DEBUG_ANY, - "%s: line %d: missing filename in \"auditlog \" line\n", - fname, lineno, 0 ); - return( 1 ); - } - ad->ad_logfile = ch_strdup( argv[1] ); - return 0; - } - return SLAP_CONF_UNKNOWN; -} - int auditlog_initialize() { + int rc; auditlog.on_bi.bi_type = "auditlog"; auditlog.on_bi.bi_db_init = auditlog_db_init; - auditlog.on_bi.bi_db_config = auditlog_config; auditlog.on_bi.bi_db_close = auditlog_db_close; auditlog.on_bi.bi_db_destroy = auditlog_db_destroy; auditlog.on_response = auditlog_response; + auditlog.on_bi.bi_cf_ocs = auditlogocs; + rc = config_register_schema( auditlogcfg, auditlogocs ); + if ( rc ) return rc; + return overlay_register(&auditlog); }