[Freeipa-devel] [PATCH 0142] Improve LDAP error logging

Petr Spacek pspacek at redhat.com
Thu May 9 11:37:45 UTC 2013


On 7.5.2013 09:36, Tomas Hozza wrote:
> On 04/09/2013 03:27 PM, Petr Spacek wrote:
>> Hello,
>>
>> Improve LDAP error logging.
>>
>> Diagnostic error message is logged when it is available.
>>
>>
>> Plugin with this patch produces messages like:
>>
>> LDAP error: Server is unwilling to perform: Minimum SSF not met.: bind
>> to LDAP server failed
>>
>> intead of
>>
>> bind to LDAP server failed: Server is unwilling to perform
>>
>>
>> Second example is:
>>
>> LDAP error: Object class violation: attribute "mgrecord" not allowed
>> : while modifying(add) entry 'idnsName=pspacek,
>> idnsname=example.com,cn=dns,dc=e,dc=test'
>>
>> instead of
>>
>> ""
>>
>> :-D
>>
>
> <snip>
>> diff --git a/src/log.h b/src/log.h
<snip>
>> +#define LOG_LDAP_ERR_PREFIX "LDAP error: "
>> +#define log_ldap_error(ld, desc, ...) 							\
>> + 	do { 											\
>> + 		int err; 									\
>> + 		char *errmsg = NULL; 								\
>> + 		char *diagmsg = NULL; 								\
>> + 		if (ldap_get_option(ld, LDAP_OPT_RESULT_CODE, &err) 				\
>> + 			== LDAP_OPT_SUCCESS) { 							\
>> + 				errmsg = ldap_err2string(err); 					\
> Getting error msg for the first time here.
>
>> + 				if (ldap_get_option(ld, LDAP_OPT_DIAGNOSTIC_MESSAGE, &diagmsg) 	\
>> + 					== LDAP_OPT_SUCCESS && diagmsg != NULL) { 		\
>> + 						errmsg = ldap_err2string(err);			\
> Again getting error msg with the same "err". Maybe a copy-paste error?
>
>> + 						log_error(LOG_LDAP_ERR_PREFIX "%s: %s: " desc, 	\
>> + 							errmsg, diagmsg, ##__VA_ARGS__); 	\
>> + 						ldap_memfree(diagmsg); 				\
>> + 				} else 								\

Revised version of the patch is attached. Thank you for catching it.

-- 
Petr Spacek
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bind-dyndb-ldap-pspacek-0142-2-Improve-LDAP-error-logging.patch
Type: text/x-patch
Size: 3982 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20130509/62363f83/attachment.bin>


More information about the Freeipa-devel mailing list