]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/auditlog.c
More logging for ITS#4423
[openldap] / servers / slapd / overlays / auditlog.c
index 441df6c68fd062f69fd30e1324523b4d50aa6878..cc67c2b950b55dd2afedddc64cda5eaac52ec5ac 100644 (file)
@@ -36,7 +36,7 @@ typedef struct auditlog_data {
        char *ad_logfile;
 } auditlog_data;
 
-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;
        if((s = ldif_put(LDIF_PUT_VALUE, name, val, len)) == NULL)
                return(-1);
@@ -45,20 +45,20 @@ int fprint_ldif(FILE *f, char *name, char *val, ber_len_t len) {
        return(0);
 }
 
-int auditlog_response(Operation *op, SlapReply *rs) {
+static int auditlog_response(Operation *op, SlapReply *rs) {
        slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
        auditlog_data *ad = on->on_bi.bi_private;
        FILE *f;
        Attribute *a;
        Modifications *m;
        struct berval *b;
-       char *what, *subop, *suffix, *who = NULL;
+       char *what, *suffix, *who = NULL;
        long stamp = slap_get_time();
        int i;
 
        if ( rs->sr_err != LDAP_SUCCESS ) return SLAP_CB_CONTINUE;
 
-       if ( !op->o_bd || !ad->ad_logfile ) return SLAP_CB_CONTINUE;
+       if ( !ad->ad_logfile ) return SLAP_CB_CONTINUE;
 
 /*
 ** add or modify: use modifiersName if present
@@ -78,7 +78,9 @@ int auditlog_response(Operation *op, SlapReply *rs) {
                case LDAP_REQ_MODIFY:
                        what = "modify";
                        for(m = op->orm_modlist; m; m = m->sml_next)
-                               if( m->sml_desc == slap_schema.si_ad_modifiersName ) {
+                               if( m->sml_desc == slap_schema.si_ad_modifiersName &&
+                                       ( m->sml_op == LDAP_MOD_ADD ||
+                                       m->sml_op == LDAP_MOD_REPLACE )) {
                                        who = m->sml_values[0].bv_val;
                                        break;
                                }
@@ -109,7 +111,7 @@ int auditlog_response(Operation *op, SlapReply *rs) {
        switch(op->o_tag) {
          case LDAP_REQ_ADD:
                for(a = op->ora_e->e_attrs; a; a = a->a_next)
-                   if(b = a->a_vals)
+                 if((b = a->a_vals) != NULL)
                        for(i = 0; b[i].bv_val; i++)
                                fprint_ldif(f, a->a_desc->ad_cname.bv_val, b[i].bv_val, b[i].bv_len);
                break;
@@ -126,7 +128,8 @@ int auditlog_response(Operation *op, SlapReply *rs) {
                                        continue;
                        }
                        fprintf(f, "%s: %s\n", what, m->sml_desc->ad_cname.bv_val);
-                       if(b = m->sml_values) for(i = 0; b[i].bv_val; i++)
+                       if((b = m->sml_values) != NULL)
+                         for(i = 0; b[i].bv_val; i++)
                                fprint_ldif(f, m->sml_desc->ad_cname.bv_val, b[i].bv_val, b[i].bv_len);
                        fprintf(f, "-\n");
                }
@@ -175,6 +178,7 @@ auditlog_db_close(
 
        free( ad->ad_logfile );
        ad->ad_logfile = NULL;
+       return 0;
 }
 
 static int
@@ -187,6 +191,7 @@ auditlog_db_destroy(
 
        ldap_pvt_thread_mutex_destroy( &ad->ad_mutex );
        free( ad );
+       return 0;
 }
 
 static int