]> git.sur5r.net Git - openldap/commitdiff
Add flag for only logging successful operations
authorHoward Chu <hyc@openldap.org>
Wed, 14 Sep 2005 09:11:03 +0000 (09:11 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 14 Sep 2005 09:11:03 +0000 (09:11 +0000)
servers/slapd/overlays/accesslog.c

index 0470d0d1bd228676f767d957052d1275599927b0..dd85f18753e40b74963185a3db04b28d33d0b6ef 100644 (file)
@@ -57,6 +57,7 @@ typedef struct log_info {
        int li_age;
        int li_cycle;
        struct re_s *li_task;
+       int li_success;
 } log_info;
 
 static ConfigDriver log_cf_gen;
@@ -64,7 +65,8 @@ static ConfigDriver log_cf_gen;
 enum {
        LOG_DB = 1,
        LOG_OPS,
-       LOG_PURGE
+       LOG_PURGE,
+       LOG_SUCCESS
 };
 
 static ConfigTable log_cfats[] = {
@@ -82,6 +84,10 @@ static ConfigTable log_cfats[] = {
                log_cf_gen, "( OLcfgOvAt:4.3 NAME 'olcAccessLogPurge' "
                        "DESC 'Log cleanup parameters' "
                        "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
+       { "logsuccess", NULL, 2, 2, 0, ARG_MAGIC|ARG_ON_OFF|LOG_SUCCESS,
+               log_cf_gen, "( OLcfgOvAt:4.4 NAME 'olcAccessLogSuccess' "
+                       "DESC 'Log successful ops only' "
+                       "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
        { NULL }
 };
 
@@ -91,7 +97,7 @@ static ConfigOCs log_cfocs[] = {
                "DESC 'Access log configuration' "
                "SUP olcOverlayConfig "
                "MUST olcAccessLogDB "
-               "MAY ( olcAccessLogOps $ olcAccessLogPurge ) )",
+               "MAY ( olcAccessLogOps $ olcAccessLogPurge $ olcAccessLogSuccess ) )",
                        Cft_Overlay, log_cfats },
        { NULL }
 };
@@ -188,7 +194,7 @@ static struct {
                "SYNTAX OMsInteger "
                "SINGLE-VALUE )", &ad_reqResult },
        { "( " LOG_SCHEMA_AT ".7 NAME 'reqAuthzID' "
-               "DESC 'AUthorization ID of requestor' "
+               "DESC 'Authorization ID of requestor' "
                "EQUALITY distinguishedNameMatch "
                "SYNTAX OMsDN "
                "SINGLE-VALUE )", &ad_reqAuthzID },
@@ -556,6 +562,12 @@ log_cf_gen(ConfigArgs *c)
                        agebv.bv_len += cyclebv.bv_len;
                        value_add_one( &c->rvalue_vals, &agebv );
                        break;
+               case LOG_SUCCESS:
+                       if ( li->li_success )
+                               c->value_int = li->li_success;
+                       else
+                               rc = 1;
+                       break;
                }
                break;
        case LDAP_MOD_DELETE:
@@ -583,6 +595,9 @@ log_cf_gen(ConfigArgs *c)
                        li->li_age = 0;
                        li->li_cycle = 0;
                        break;
+               case LOG_SUCCESS:
+                       li->li_success = 0;
+                       break;
                }
                break;
        default:
@@ -625,6 +640,9 @@ log_cf_gen(ConfigArgs *c)
                                }
                        }
                        break;
+               case LOG_SUCCESS:
+                       li->li_success = c->value_int;
+                       break;
                }
                break;
        }
@@ -720,6 +738,9 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
        if ( rs->sr_type != REP_RESULT && rs->sr_type != REP_EXTENDED )
                return SLAP_CB_CONTINUE;
 
+       if ( li->li_success && rs->sr_err != LDAP_SUCCESS )
+               return SLAP_CB_CONTINUE;
+
        switch ( op->o_tag ) {
        case LDAP_REQ_ADD:              logop = LOG_EN_ADD; break;
        case LDAP_REQ_DELETE:   logop = LOG_EN_DELETE; break;