lib/libadmin/util.c | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
New commits:
commit 70e9664b0ceb4602c4bf61128c861fce55daa074
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Jun 29 13:17:32 2012 -0400
Ticket 400 - BIND operation result not checked properly in admin server
Bug Description: There are two issues here. One, we were not calling
ldap_parse_result()
for SIMPLE binds. Two, we were overwriting the error code, with
the
function result code.
Fix Description: Always call ldap_parse_result, and use a separate error code
variable to
preserve the actual result code from the bind operation.
Also did a litte code cleanup.
https://fedorahosted.org/389/ticket/400
Reviewed by: ?
diff --git a/lib/libadmin/util.c b/lib/libadmin/util.c
index 21fbde8..be651b4 100644
--- a/lib/libadmin/util.c
+++ b/lib/libadmin/util.c
@@ -1682,6 +1682,7 @@ util_ldap_bind(
)
{
int rc = LDAP_SUCCESS;
+ int err = LDAP_SUCCESS;
int secure = 0;
struct berval bvcreds = {0, NULL};
LDAPMessage *result = NULL;
@@ -1788,20 +1789,30 @@ util_ldap_bind(
}
/* if we got here, we were able to read success result */
/* Get the controls sent by the server if requested */
- if (returnedctrls) {
- if ((rc = ldap_parse_result(ld, result, &rc, NULL, NULL,
- NULL, returnedctrls,
- 0)) != LDAP_SUCCESS) {
+ if ((rc = ldap_parse_result(ld, result, &err, NULL, NULL,
+ NULL, returnedctrls, 0)) != LDAP_SUCCESS) {
#ifdef DEBUG
- fprintf(stderr, "util_ldap_bind: "
- "Error: could not bind id "
- "[%s] mech [%s]: error %d (%s)\n",
- bindid ? bindid : "(anon)",
- mech ? mech : "SIMPLE",
- rc, ldap_err2string(rc));
+ fprintf(stderr, "util_ldap_bind: "
+ "Error: could not parse bind result "
+ "[%s] mech [%s]: error %d (%s)\n",
+ bindid ? bindid : "(anon)",
+ mech ? mech : "SIMPLE",
+ rc, ldap_err2string(rc));
#endif
- goto done;
- }
+ goto done;
+ }
+
+ if(err){
+ rc = err;
+#ifdef DEBUG
+ fprintf(stderr, "util_ldap_bind: "
+ "Error: could not bind id "
+ "[%s] mech [%s]: error %d (%s)\n",
+ bindid ? bindid : "(anon)",
+ mech ? mech : "SIMPLE",
+ rc, ldap_err2string(rc));
+#endif
+ goto done;
}
/* parse the bind result and get the ldap error code */