diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-07-02 11:39:28 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-07-02 12:49:04 +1000 |
commit | 84c5dd1e4bb1b4c45d7b5ac68ab432cfc399835c (patch) | |
tree | 90c5b942c816295072c89a26f92c58ba06e5417a /source4 | |
parent | 277a9b4aaca60745acfa3f82bd021390de337a26 (diff) | |
download | samba-84c5dd1e4bb1b4c45d7b5ac68ab432cfc399835c.tar.gz samba-84c5dd1e4bb1b4c45d7b5ac68ab432cfc399835c.tar.bz2 samba-84c5dd1e4bb1b4c45d7b5ac68ab432cfc399835c.zip |
s4-ldb: fixed error handling in openldap backend
fixed several bugs in error handling. the ldb context was used without
being initialised in the error paths, and several error paths did not
set an ldb error string.
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/ldb/ldb_ldap/ldb_ldap.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c index b5a0896854..292da7aed0 100644 --- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c +++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c @@ -282,7 +282,7 @@ static int lldb_add(struct lldb_context *lldb_ac) char *dn; int ret; - ldb_module_get_ctx(module); + ldb = ldb_module_get_ctx(module); ldb_request_set_state(req, LDB_ASYNC_PENDING); @@ -321,7 +321,7 @@ static int lldb_modify(struct lldb_context *lldb_ac) char *dn; int ret; - ldb_module_get_ctx(module); + ldb = ldb_module_get_ctx(module); ldb_request_set_state(req, LDB_ASYNC_PENDING); @@ -359,7 +359,7 @@ static int lldb_delete(struct lldb_context *lldb_ac) char *dnstr; int ret; - ldb_module_get_ctx(module); + ldb = ldb_module_get_ctx(module); ldb_request_set_state(req, LDB_ASYNC_PENDING); @@ -391,7 +391,7 @@ static int lldb_rename(struct lldb_context *lldb_ac) char *parentdn; int ret; - ldb_module_get_ctx(module); + ldb = ldb_module_get_ctx(module); ldb_request_set_state(req, LDB_ASYNC_PENDING); @@ -502,20 +502,24 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) ldbmsg = ldb_msg_new(ac); if (!ldbmsg) { + ldb_oom(ldb); ret = LDB_ERR_OPERATIONS_ERROR; break; } dn = ldap_get_dn(lldb->ldap, msg); if (!dn) { + ldb_oom(ldb); talloc_free(ldbmsg); ret = LDB_ERR_OPERATIONS_ERROR; break; } ldbmsg->dn = ldb_dn_new(ldbmsg, ldb, dn); if ( ! ldb_dn_validate(ldbmsg->dn)) { + ldb_asprintf_errstring(ldb, "Invalid DN '%s' in reply", dn); talloc_free(ldbmsg); ret = LDB_ERR_OPERATIONS_ERROR; + ldap_memfree(dn); break; } ldap_memfree(dn); @@ -539,7 +543,8 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) ret = ldb_module_send_entry(ac->req, ldbmsg, NULL /* controls not yet supported */); if (ret != LDB_SUCCESS) { - + ldb_asprintf_errstring(ldb, "entry send failed: %s", + ldb_errstring(ldb)); callback_failed = true; } } else { @@ -568,6 +573,8 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) ret = ldb_module_send_referral(ac->req, referral); if (ret != LDB_SUCCESS) { + ldb_asprintf_errstring(ldb, "referral send failed: %s", + ldb_errstring(ldb)); callback_failed = true; break; } @@ -586,6 +593,8 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) ret = LDB_ERR_OPERATIONS_ERROR; } if (ret != LDB_SUCCESS) { + ldb_asprintf_errstring(ldb, "ldap parse error for type %d: %s : %s", + type, ldap_err2string(ret), errmsgp); break; } @@ -598,6 +607,7 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) break; default: + ldb_asprintf_errstring(ldb, "unknown ldap return type: %d", type); ret = LDB_ERR_PROTOCOL_ERROR; break; } |