cleanup controls logging in LDIF mode (-L[L[L]], ITS#6775)

This commit is contained in:
Pierangelo Masarati 2011-01-04 18:20:04 +00:00
parent d5f65267bd
commit 31199e1847

View File

@ -1953,6 +1953,7 @@ print_prepostread( LDAP *ld, LDAPControl *ctrl, struct berval *what)
while ( ber_scanf( ber, "{m" /*}*/, &bv ) != LBER_ERROR ) {
int i;
BerVarray vals = NULL;
char *str = NULL;
if ( ber_scanf( ber, "[W]", &vals ) == LBER_ERROR ||
vals == NULL )
@ -1960,14 +1961,25 @@ print_prepostread( LDAP *ld, LDAPControl *ctrl, struct berval *what)
/* error? */
return 1;
}
if ( ldif ) {
char *ptr;
str = malloc( bv.bv_len + STRLENOF(": ") + 1 );
ptr = str;
ptr = lutil_strncopy( ptr, bv.bv_val, bv.bv_len );
ptr = lutil_strcopy( ptr, ": " );
}
for ( i = 0; vals[ i ].bv_val != NULL; i++ ) {
tool_write_ldif(
ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
bv.bv_val, vals[ i ].bv_val, vals[ i ].bv_len );
ldif ? str : bv.bv_val, vals[ i ].bv_val, vals[ i ].bv_len );
}
ber_bvarray_free( vals );
if ( str ) free( str );
}
}
@ -2047,7 +2059,8 @@ print_paged_results( LDAP *ld, LDAPControl *ctrl )
}
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"pagedresults", buf, ptr - buf );
ldif ? "pagedresults: " : "pagedresults",
buf, ptr - buf );
}
return 0;
@ -2067,7 +2080,7 @@ print_sss( LDAP *ld, LDAPControl *ctrl )
err, ldap_err2string(err), attr ? " " : "", attr ? attr : "" );
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"sortResult", buf, rc );
ldif ? "sortResult: " : "sortResult", buf, rc );
}
return rc;
@ -2107,7 +2120,7 @@ print_vlv( LDAP *ld, LDAPControl *ctrl )
ber_memfree( bv.bv_val );
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"vlvResult", buf, rc );
ldif ? "vlvResult" : "vlvResult", buf, rc );
}
return rc;
@ -2241,13 +2254,17 @@ print_whatfailed( LDAP *ld, LDAPControl *ctrl )
static int
print_authzid( LDAP *ld, LDAPControl *ctrl )
{
if (ctrl->ldctl_value.bv_len) {
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"authzid", ctrl->ldctl_value.bv_val, ctrl->ldctl_value.bv_len );
if ( ctrl->ldctl_value.bv_len ) {
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
ldif ? "authzid: " : "authzid",
ctrl->ldctl_value.bv_val, ctrl->ldctl_value.bv_len );
} else {
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"authzid", "anonymous", sizeof("anonymous")-1);
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
ldif ? "authzid: " : "authzid",
"anonymous", STRLENOF("anonymous") );
}
return 0;
}
#endif
@ -2281,7 +2298,7 @@ print_ppolicy( LDAP *ld, LDAPControl *ctrl )
}
tool_write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"ppolicy", buf, ptr - buf );
ldif ? "ppolicy: " : "ppolicy", buf, ptr - buf );
}
return rc;