version 1.7.2.1, 2006/05/15 17:04:44
|
version 1.7.2.2, 2006/08/17 23:50:32
|
Line 1
|
Line 1
|
/* auditlog.c - log modifications for audit/history purposes */ |
/* auditlog.c - log modifications for audit/history purposes */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/auditlog.c,v 1.8 2006/04/28 21:37:35 hyc Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/auditlog.c,v 1.7.2.1 2006/05/15 17:04:44 kurt Exp $ */ |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
* Copyright 2005-2006 The OpenLDAP Foundation. |
* Copyright 2005-2006 The OpenLDAP Foundation. |
Line 29
|
Line 29
|
#include <ac/ctype.h> |
#include <ac/ctype.h> |
|
|
#include "slap.h" |
#include "slap.h" |
|
#include "config.h" |
#include "ldif.h" |
#include "ldif.h" |
|
|
typedef struct auditlog_data { |
typedef struct auditlog_data { |
Line 36 typedef struct auditlog_data {
|
Line 37 typedef struct auditlog_data {
|
char *ad_logfile; |
char *ad_logfile; |
} auditlog_data; |
} 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) { |
static int fprint_ldif(FILE *f, char *name, char *val, ber_len_t len) { |
char *s; |
char *s; |
if((s = ldif_put(LDIF_PUT_VALUE, name, val, len)) == NULL) |
if((s = ldif_put(LDIF_PUT_VALUE, name, val, len)) == NULL) |
Line 107 static int auditlog_response(Operation *
|
Line 128 static int auditlog_response(Operation *
|
fprintf(f, "# %s %ld %s%s%s\n", |
fprintf(f, "# %s %ld %s%s%s\n", |
what, stamp, suffix, who ? " " : "", who ? who->bv_val : ""); |
what, stamp, suffix, who ? " " : "", who ? who->bv_val : ""); |
|
|
if ( !who || !dn_match( who, &op->o_conn->c_dn )) |
if ( !BER_BVISEMPTY( &op->o_conn->c_dn ) && |
fprintf(f, "# realdn: %s\n", op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : |
(!who || !dn_match( who, &op->o_conn->c_dn ))) |
"<empty>" ); |
fprintf(f, "# realdn: %s\n", op->o_conn->c_dn.bv_val ); |
|
|
fprintf(f, "dn: %s\nchangetype: %s\n", |
fprintf(f, "dn: %s\nchangetype: %s\n", |
op->o_req_dn.bv_val, what); |
op->o_req_dn.bv_val, what); |
Line 167 auditlog_db_init(
|
Line 188 auditlog_db_init(
|
) |
) |
{ |
{ |
slap_overinst *on = (slap_overinst *)be->bd_info; |
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; |
on->on_bi.bi_private = ad; |
ldap_pvt_thread_mutex_init( &ad->ad_mutex ); |
ldap_pvt_thread_mutex_init( &ad->ad_mutex ); |
Line 227 auditlog_config(
|
Line 248 auditlog_config(
|
} |
} |
|
|
int auditlog_initialize() { |
int auditlog_initialize() { |
|
int rc; |
|
|
auditlog.on_bi.bi_type = "auditlog"; |
auditlog.on_bi.bi_type = "auditlog"; |
auditlog.on_bi.bi_db_init = auditlog_db_init; |
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_close = auditlog_db_close; |
auditlog.on_bi.bi_db_destroy = auditlog_db_destroy; |
auditlog.on_bi.bi_db_destroy = auditlog_db_destroy; |
auditlog.on_response = auditlog_response; |
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); |
return overlay_register(&auditlog); |
} |
} |
|
|