ITS#3854 fix Modify logging, add handlers for unrecognized ops.

This commit is contained in:
Howard Chu 2005-07-12 14:00:01 +00:00
parent fbbfac6771
commit 0b93bfc4f3

View File

@ -43,11 +43,13 @@
#define LOG_OP_UNBIND 0x080
#define LOG_OP_ABANDON 0x100
#define LOG_OP_EXTENDED 0x200
#define LOG_OP_UNKNOWN 0x400
#define LOG_OP_WRITES (LOG_OP_ADD|LOG_OP_DELETE|LOG_OP_MODIFY|LOG_OP_MODRDN)
#define LOG_OP_READS (LOG_OP_COMPARE|LOG_OP_SEARCH)
#define LOG_OP_SESSION (LOG_OP_BIND|LOG_OP_UNBIND|LOG_OP_ABANDON)
#define LOG_OP_ALL (LOG_OP_READS|LOG_OP_WRITES|LOG_OP_SESSION|LOG_OP_EXTENDED)
#define LOG_OP_ALL (LOG_OP_READS|LOG_OP_WRITES|LOG_OP_SESSION| \
LOG_OP_EXTENDED|LOG_OP_UNKNOWN)
typedef struct log_info {
BackendDB *li_db;
@ -109,6 +111,7 @@ static slap_verbmasks logops[] = {
{ BER_BVC("unbind"), LOG_OP_UNBIND },
{ BER_BVC("abandon"), LOG_OP_ABANDON },
{ BER_BVC("extended"), LOG_OP_EXTENDED },
{ BER_BVC("unknown"), LOG_OP_UNKNOWN },
{ BER_BVNULL, 0 }
};
@ -126,6 +129,7 @@ enum {
LOG_EN_UNBIND,
LOG_EN_ABANDON,
LOG_EN_EXTENDED,
LOG_EN_UNKNOWN,
LOG_EN__COUNT
};
@ -723,6 +727,8 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
case LDAP_REQ_SEARCH: logop = LOG_EN_SEARCH; break;
case LDAP_REQ_BIND: logop = LOG_EN_BIND; break;
case LDAP_REQ_EXTENDED: logop = LOG_EN_EXTENDED; break;
default: /* unknown operation type */
logop = LOG_EN_UNKNOWN; break;
} /* Unbind and Abandon never reach here */
lo = logops+logop+EN_OFFSET;
@ -810,16 +816,22 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
if ( m->sml_values ) {
for (b=m->sml_values; !BER_BVISNULL( b ); b++,i++) {
char c_op;
vals[i].bv_len = a->a_desc->ad_cname.bv_len + b->bv_len +3;
vals[i].bv_len = m->sml_desc->ad_cname.bv_len + b->bv_len +3;
vals[i].bv_val = ch_malloc( vals[i].bv_len+1 );
ptr = lutil_strcopy( vals[i].bv_val,
a->a_desc->ad_cname.bv_val );
m->sml_desc->ad_cname.bv_val );
*ptr++ = ':';
switch( m->sml_op ) {
case LDAP_MOD_ADD: c_op = '+'; break;
case LDAP_MOD_DELETE: c_op = '-'; break;
case LDAP_MOD_REPLACE: c_op = '='; break;
case LDAP_MOD_INCREMENT: c_op = '#'; break;
/* unknown op. there shouldn't be any of these. we
* don't know what to do with it, but we shouldn't just
* ignore it.
*/
default: c_op = '?'; break;
}
*ptr++ = c_op;
*ptr++ = ' ';
@ -827,7 +839,7 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
vals[i].bv_val[vals[i].bv_len] = '\0';
}
} else if ( m->sml_op == LDAP_MOD_DELETE ) {
vals[i].bv_len = a->a_desc->ad_cname.bv_len + 2;
vals[i].bv_len = m->sml_desc->ad_cname.bv_len + 2;
vals[i].bv_val = ch_malloc( vals[i].bv_len+1 );
ptr = lutil_strcopy( vals[i].bv_val,
a->a_desc->ad_cname.bv_val );
@ -916,6 +928,10 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
attr_merge_one( e, ad_reqData, op->ore_reqdata, NULL );
}
break;
case LOG_EN_UNKNOWN:
/* we don't know its parameters, don't add any */
break;
}
op2.o_hdr = op->o_hdr;