diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-07-06 13:21:54 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-07-07 20:14:55 +1000 |
commit | 87df785a68c1c8043b345b71c98764ef36b76179 (patch) | |
tree | a4d3071a393661c93e97f9963e492d494241173c /source4 | |
parent | fc68558ab937859a91214e8675d53c0afaf3c4e6 (diff) | |
download | samba-87df785a68c1c8043b345b71c98764ef36b76179.tar.gz samba-87df785a68c1c8043b345b71c98764ef36b76179.tar.bz2 samba-87df785a68c1c8043b345b71c98764ef36b76179.zip |
s4-dsdb: use ldb_operr() in the dsdb code
this replaces "return LDB_ERR_OPERATIONS_ERROR" with "return ldb_operr(ldb)"
in places in the dsdb code where we don't already explicitly set an
error string. This should make is much easier to track down dsdb
module bugs that result in an operations error.
Diffstat (limited to 'source4')
43 files changed, 455 insertions, 625 deletions
diff --git a/source4/dsdb/common/dsdb_access.c b/source4/dsdb/common/dsdb_access.c index ac0c73643f..c7d8610c50 100644 --- a/source4/dsdb/common/dsdb_access.c +++ b/source4/dsdb/common/dsdb_access.c @@ -27,6 +27,7 @@ #include "includes.h" #include "ldb.h" +#include "ldb_module.h" #include "ldb_errors.h" #include "libcli/security/security.h" #include "librpc/gen_ndr/ndr_security.h" @@ -53,7 +54,8 @@ void dsdb_acl_debug(struct security_descriptor *sd, ndr_print_struct_string(0,(ndr_print_fn_t)ndr_print_security_descriptor,"", sd))); } -int dsdb_get_sd_from_ldb_message(TALLOC_CTX *mem_ctx, +int dsdb_get_sd_from_ldb_message(struct ldb_context *ldb, + TALLOC_CTX *mem_ctx, struct ldb_message *acl_res, struct security_descriptor **sd) { @@ -67,19 +69,20 @@ int dsdb_get_sd_from_ldb_message(TALLOC_CTX *mem_ctx, } *sd = talloc(mem_ctx, struct security_descriptor); if(!*sd) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ndr_err = ndr_pull_struct_blob(&sd_element->values[0], *sd, *sd, (ndr_pull_flags_fn_t)ndr_pull_security_descriptor); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } return LDB_SUCCESS; } -int dsdb_check_access_on_dn_internal(struct ldb_result *acl_res, +int dsdb_check_access_on_dn_internal(struct ldb_context *ldb, + struct ldb_result *acl_res, TALLOC_CTX *mem_ctx, struct security_token *token, struct ldb_dn *dn, @@ -94,9 +97,9 @@ int dsdb_check_access_on_dn_internal(struct ldb_result *acl_res, uint32_t access_granted; int ret; - ret = dsdb_get_sd_from_ldb_message(mem_ctx, acl_res->msgs[0], &sd); + ret = dsdb_get_sd_from_ldb_message(ldb, mem_ctx, acl_res->msgs[0], &sd); if (ret != LDB_SUCCESS) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Theoretically we pass the check if the object has no sd */ if (!sd) { @@ -105,7 +108,7 @@ int dsdb_check_access_on_dn_internal(struct ldb_result *acl_res, sid = samdb_result_dom_sid(mem_ctx, acl_res->msgs[0], "objectSid"); if (guid) { if (!insert_in_object_tree(mem_ctx, guid, access, &root, &new_node)) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } } status = sec_access_check_ds(sd, token, @@ -146,7 +149,7 @@ int dsdb_check_access_on_dn(struct ldb_context *ldb, struct auth_session_info *session_info = (struct auth_session_info *)ldb_get_opaque(ldb, "sessionInfo"); if(!session_info) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = ldb_search(ldb, mem_ctx, &acl_res, dn, LDB_SCOPE_BASE, acl_attrs, NULL); @@ -155,7 +158,7 @@ int dsdb_check_access_on_dn(struct ldb_context *ldb, return ret; } - return dsdb_check_access_on_dn_internal(acl_res, + return dsdb_check_access_on_dn_internal(ldb, acl_res, mem_ctx, session_info->security_token, dn, diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index d24803809d..4866a9a8d9 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -24,6 +24,7 @@ #include "includes.h" #include "events/events.h" #include "ldb.h" +#include "ldb_module.h" #include "ldb_errors.h" #include "../lib/util/util_ldb.h" #include "../lib/crypto/crypto.h" @@ -807,7 +808,7 @@ int samdb_msg_add_string(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struc char *s = talloc_strdup(mem_ctx, str); char *a = talloc_strdup(mem_ctx, attr_name); if (s == NULL || a == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(sam_ldb); } return ldb_msg_add_string(msg, a, s); } @@ -825,7 +826,7 @@ int samdb_msg_add_dom_sid(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, stru sid, (ndr_push_flags_fn_t)ndr_push_dom_sid); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(sam_ldb); } return ldb_msg_add_value(msg, attr_name, &v, NULL); } @@ -859,7 +860,7 @@ int samdb_msg_add_addval(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, v = talloc_strdup(mem_ctx, value); if (v == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(sam_ldb); } val.data = (uint8_t *) v; @@ -889,7 +890,7 @@ int samdb_msg_add_addval(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, vals = talloc_realloc(msg, el->values, struct ldb_val, el->num_values + 1); if (vals == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(sam_ldb); } el->values = vals; el->values[el->num_values] = val; @@ -915,7 +916,7 @@ int samdb_msg_add_delval(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, v = talloc_strdup(mem_ctx, value); if (v == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(sam_ldb); } val.data = (uint8_t *) v; @@ -945,7 +946,7 @@ int samdb_msg_add_delval(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, vals = talloc_realloc(msg, el->values, struct ldb_val, el->num_values + 1); if (vals == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(sam_ldb); } el->values = vals; el->values[el->num_values] = val; @@ -1001,7 +1002,7 @@ int samdb_msg_add_hash(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct struct ldb_val val; val.data = talloc_memdup(mem_ctx, hash->hash, 16); if (!val.data) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(sam_ldb); } val.length = 16; return ldb_msg_add_value(msg, attr_name, &val, NULL); @@ -1010,7 +1011,8 @@ int samdb_msg_add_hash(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct /* add a samr_Password array to a message */ -int samdb_msg_add_hashes(TALLOC_CTX *mem_ctx, struct ldb_message *msg, +int samdb_msg_add_hashes(struct ldb_context *ldb, + TALLOC_CTX *mem_ctx, struct ldb_message *msg, const char *attr_name, struct samr_Password *hashes, unsigned int count) { @@ -1019,7 +1021,7 @@ int samdb_msg_add_hashes(TALLOC_CTX *mem_ctx, struct ldb_message *msg, val.data = talloc_array_size(mem_ctx, 16, count); val.length = count*16; if (!val.data) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } for (i=0;i<count;i++) { memcpy(i*16 + (char *)val.data, hashes[i].hash, 16); @@ -1905,7 +1907,7 @@ int samdb_search_for_parent_domain(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *attrs[] = { NULL }; local_ctx = talloc_new(mem_ctx); - if (local_ctx == NULL) return LDB_ERR_OPERATIONS_ERROR; + if (local_ctx == NULL) return ldb_oom(ldb); while ((sdn = ldb_dn_get_parent(local_ctx, sdn))) { ret = ldb_search(ldb, local_ctx, &res, sdn, LDB_SCOPE_BASE, attrs, @@ -2393,7 +2395,7 @@ int dsdb_find_dn_by_guid(struct ldb_context *ldb, char *guid_str = GUID_string(mem_ctx, guid); if (!guid_str) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = dsdb_search(ldb, mem_ctx, &res, NULL, LDB_SCOPE_SUBTREE, attrs, @@ -2533,7 +2535,7 @@ int dsdb_find_dn_by_sid(struct ldb_context *ldb, char *sid_str = dom_sid_string(mem_ctx, sid); if (!sid_str) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = dsdb_search(ldb, mem_ctx, &res, NULL, LDB_SCOPE_SUBTREE, attrs, @@ -2675,7 +2677,7 @@ int dsdb_load_partition_usn(struct ldb_context *ldb, struct ldb_dn *dn, res = talloc_zero(tmp_ctx, struct ldb_result); if (!res) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = ldb_build_search_req(&req, ldb, tmp_ctx, @@ -2693,7 +2695,7 @@ int dsdb_load_partition_usn(struct ldb_context *ldb, struct ldb_dn *dn, p_ctrl = talloc(req, struct dsdb_control_current_partition); if (p_ctrl == NULL) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } p_ctrl->version = DSDB_CONTROL_CURRENT_PARTITION_VERSION; p_ctrl->dn = dn; @@ -2775,7 +2777,7 @@ int samdb_is_rodc(struct ldb_context *sam_ctx, const struct GUID *objectGUID, bo config_dn = ldb_get_config_basedn(sam_ctx); if (!config_dn) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(sam_ctx); } ret = dsdb_search(sam_ctx, tmp_ctx, &res, config_dn, LDB_SCOPE_SUBTREE, attrs, @@ -2821,7 +2823,7 @@ int samdb_rodc(struct ldb_context *sam_ctx, bool *am_rodc) objectGUID = samdb_ntds_objectGUID(sam_ctx); if (!objectGUID) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(sam_ctx); } ret = samdb_is_rodc(sam_ctx, objectGUID, am_rodc); @@ -2831,14 +2833,14 @@ int samdb_rodc(struct ldb_context *sam_ctx, bool *am_rodc) cached = talloc(sam_ctx, bool); if (cached == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(sam_ctx); } *cached = *am_rodc; ret = ldb_set_opaque(sam_ctx, "cache.am_rodc", cached); if (ret != LDB_SUCCESS) { talloc_free(cached); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(sam_ctx); } return LDB_SUCCESS; @@ -3166,7 +3168,7 @@ int dsdb_wellknown_dn(struct ldb_context *samdb, TALLOC_CTX *mem_ctx, wk_guid, ldb_dn_get_linearized(nc_root)); if (!wkguid_dn) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(samdb); } ret = dsdb_search_dn(samdb, tmp_ctx, &res, dn, attrs, DSDB_SEARCH_SHOW_DELETED); @@ -3202,7 +3204,7 @@ int dsdb_find_nc_root(struct ldb_context *samdb, TALLOC_CTX *mem_ctx, struct ldb tmp_ctx = talloc_new(samdb); if (tmp_ctx == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(samdb); } ret = ldb_search(samdb, tmp_ctx, &root_res, @@ -3224,14 +3226,14 @@ int dsdb_find_nc_root(struct ldb_context *samdb, TALLOC_CTX *mem_ctx, struct ldb nc_dns = talloc_array(tmp_ctx, struct ldb_dn *, el->num_values); if (!nc_dns) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(samdb); } for (i=0; i<el->num_values; i++) { nc_dns[i] = ldb_dn_from_ldb_val(nc_dns, samdb, &el->values[i]); if (nc_dns[i] == NULL) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(samdb); } } @@ -3283,13 +3285,13 @@ int dsdb_tombstone_lifetime(struct ldb_context *ldb, uint32_t *lifetime) } dn = ldb_dn_copy(ldb, dn); if (!dn) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* see MS-ADTS section 7.1.1.2.4.1.1. There doesn't appear to be a wellknown GUID for this */ if (!ldb_dn_add_child_fmt(dn, "CN=Directory Service,CN=Windows NT,CN=Services")) { talloc_free(dn); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } *lifetime = samdb_search_uint(ldb, dn, 180, dn, "tombstoneLifetime", "objectClass=nTDSService"); @@ -3366,7 +3368,7 @@ int dsdb_load_udv_v2(struct ldb_context *samdb, struct ldb_dn *dn, TALLOC_CTX *m if (!our_invocation_id) { DEBUG(0,(__location__ ": No invocationID on samdb - %s\n", ldb_errstring(samdb))); talloc_free(*cursors); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(samdb); } ret = dsdb_load_partition_usn(samdb, dn, &highest_usn, NULL); @@ -3387,7 +3389,7 @@ int dsdb_load_udv_v2(struct ldb_context *samdb, struct ldb_dn *dn, TALLOC_CTX *m (*cursors) = talloc_realloc(mem_ctx, *cursors, struct drsuapi_DsReplicaCursor2, (*count)+1); if (! *cursors) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(samdb); } (*cursors)[*count].source_dsa_invocation_id = *our_invocation_id; @@ -3425,7 +3427,7 @@ int dsdb_load_udv_v1(struct ldb_context *samdb, struct ldb_dn *dn, TALLOC_CTX *m *cursors = talloc_array(mem_ctx, struct drsuapi_DsReplicaCursor, *count); if (*cursors == NULL) { talloc_free(v2); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(samdb); } for (i=0; i<*count; i++) { @@ -3588,7 +3590,7 @@ int dsdb_search_dn(struct ldb_context *ldb, res = talloc_zero(mem_ctx, struct ldb_result); if (!res) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = ldb_build_search_req(&req, ldb, res, @@ -3648,7 +3650,7 @@ int dsdb_search(struct ldb_context *ldb, res = talloc_zero(tmp_ctx, struct ldb_result); if (!res) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } if (exp_fmt) { @@ -3658,7 +3660,7 @@ int dsdb_search(struct ldb_context *ldb, if (!expression) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } } @@ -3734,7 +3736,7 @@ int dsdb_search_one(struct ldb_context *ldb, res = talloc_zero(tmp_ctx, struct ldb_result); if (!res) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } if (exp_fmt) { @@ -3744,7 +3746,7 @@ int dsdb_search_one(struct ldb_context *ldb, if (!expression) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = dsdb_search(ldb, tmp_ctx, &res, basedn, scope, attrs, dsdb_flags, "%s", expression); @@ -3820,13 +3822,13 @@ int dsdb_validate_dsa_guid(struct ldb_context *ldb, DEBUG(1,(__location__ ": Failed to find DSA objectGUID %s for sid %s\n", GUID_string(tmp_ctx, dsa_guid), dom_sid_string(tmp_ctx, sid))); talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } dn = msg->dn; if (!ldb_dn_remove_child_components(dn, 1)) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = dsdb_search_one(ldb, tmp_ctx, &msg, dn, LDB_SCOPE_BASE, @@ -3836,7 +3838,7 @@ int dsdb_validate_dsa_guid(struct ldb_context *ldb, DEBUG(1,(__location__ ": Failed to find server record for DSA with objectGUID %s, sid %s\n", GUID_string(tmp_ctx, dsa_guid), dom_sid_string(tmp_ctx, sid))); talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } account_dn = ldb_msg_find_attr_as_dn(ldb, tmp_ctx, msg, "serverReference"); @@ -3844,7 +3846,7 @@ int dsdb_validate_dsa_guid(struct ldb_context *ldb, DEBUG(1,(__location__ ": Failed to find account_dn for DSA with objectGUID %s, sid %s\n", GUID_string(tmp_ctx, dsa_guid), dom_sid_string(tmp_ctx, sid))); talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } status = dsdb_get_extended_dn_sid(account_dn, &sid2, "SID"); @@ -3852,7 +3854,7 @@ int dsdb_validate_dsa_guid(struct ldb_context *ldb, DEBUG(1,(__location__ ": Failed to find SID for DSA with objectGUID %s, sid %s\n", GUID_string(tmp_ctx, dsa_guid), dom_sid_string(tmp_ctx, sid))); talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } if (!dom_sid_equal(sid, &sid2)) { @@ -3862,7 +3864,7 @@ int dsdb_validate_dsa_guid(struct ldb_context *ldb, dom_sid_string(tmp_ctx, sid), dom_sid_string(tmp_ctx, &sid2))); talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } talloc_free(tmp_ctx); diff --git a/source4/dsdb/repl/drepl_ridalloc.c b/source4/dsdb/repl/drepl_ridalloc.c index 2baf555d3c..7b225d5f20 100644 --- a/source4/dsdb/repl/drepl_ridalloc.c +++ b/source4/dsdb/repl/drepl_ridalloc.c @@ -24,6 +24,7 @@ */ #include "includes.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" #include "smbd/service.h" #include "dsdb/repl/drepl_service.h" @@ -156,7 +157,7 @@ static int drepl_ridalloc_pool_exhausted(struct ldb_context *ldb, bool *exhauste server_dn = ldb_dn_get_parent(tmp_ctx, samdb_ntds_settings_dn(ldb)); if (!server_dn) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = samdb_reference_dn(ldb, tmp_ctx, server_dn, "serverReference", &machine_dn); diff --git a/source4/dsdb/samdb/ldb_modules/acl.c b/source4/dsdb/samdb/ldb_modules/acl.c index d0e1c90746..1d5e805101 100644 --- a/source4/dsdb/samdb/ldb_modules/acl.c +++ b/source4/dsdb/samdb/ldb_modules/acl.c @@ -105,7 +105,7 @@ int dsdb_module_check_access_on_dn(struct ldb_module *module, struct auth_session_info *session_info = (struct auth_session_info *)ldb_get_opaque(ldb, "sessionInfo"); if(!session_info) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = dsdb_module_search_dn(module, mem_ctx, &acl_res, dn, acl_attrs, DSDB_SEARCH_SHOW_DELETED); @@ -113,7 +113,7 @@ int dsdb_module_check_access_on_dn(struct ldb_module *module, DEBUG(10,("access_check: failed to find object %s\n", ldb_dn_get_linearized(dn))); return ret; } - return dsdb_check_access_on_dn_internal(acl_res, + return dsdb_check_access_on_dn_internal(ldb, acl_res, mem_ctx, session_info->security_token, dn, @@ -139,13 +139,12 @@ static int acl_module_init(struct ldb_module *module) if (ret != LDB_SUCCESS) { ldb_debug(ldb, LDB_DEBUG_ERROR, "acl_module_init: Unable to register control with rootdse!\n"); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } data = talloc(module, struct acl_private); if (data == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } data->password_attrs = NULL; @@ -154,8 +153,7 @@ static int acl_module_init(struct ldb_module *module) ldb_module_set_private(module, data); if (!mem_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = dsdb_module_search_dn(module, mem_ctx, &res, @@ -182,8 +180,7 @@ static int acl_module_init(struct ldb_module *module) data->password_attrs = talloc_array(data, const char *, password_attributes->num_values + 1); if (!data->password_attrs) { talloc_free(mem_ctx); - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } for (i=0; i < password_attributes->num_values; i++) { data->password_attrs[i] = (const char *)password_attributes->values[i].data; @@ -263,7 +260,7 @@ static int acl_check_access_on_attribute(struct ldb_module *module, return ret; fail: talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } static int acl_check_access_on_class(struct ldb_module *module, @@ -309,7 +306,7 @@ static int acl_check_access_on_class(struct ldb_module *module, } return ret; fail: - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } static int acl_allowedAttributes(struct ldb_module *module, @@ -337,8 +334,7 @@ static int acl_allowedAttributes(struct ldb_module *module, mem_ctx = talloc_new(msg); if (!mem_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } oc_el = ldb_msg_find_element(sd_msg, "objectClass"); @@ -371,7 +367,7 @@ static int acl_allowedAttributes(struct ldb_module *module, return LDB_SUCCESS; } - ret = dsdb_get_sd_from_ldb_message(mem_ctx, sd_msg, &sd); + ret = dsdb_get_sd_from_ldb_message(ldb_module_get_ctx(module), mem_ctx, sd_msg, &sd); if (ret != LDB_SUCCESS) { return ret; @@ -382,7 +378,7 @@ static int acl_allowedAttributes(struct ldb_module *module, const struct dsdb_attribute *attr = dsdb_attribute_by_lDAPDisplayName(schema, attr_list[i]); if (!attr) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* remove constructed attributes */ if (attr->systemFlags & DS_FLAG_ATTR_IS_CONSTRUCTED @@ -492,7 +488,7 @@ static int acl_childClassesEffective(struct ldb_module *module, ldb_msg_remove_attr(msg, "allowedChildClassesEffective"); oc_el = ldb_msg_find_element(sd_msg, "objectClass"); - ret = dsdb_get_sd_from_ldb_message(msg, sd_msg, &sd); + ret = dsdb_get_sd_from_ldb_message(ldb_module_get_ctx(module), msg, sd_msg, &sd); if (ret != LDB_SUCCESS) { return ret; } @@ -567,7 +563,7 @@ static int acl_sDRightsEffective(struct ldb_module *module, } else { /* Get the security descriptor from the message */ - ret = dsdb_get_sd_from_ldb_message(msg, sd_msg, &sd); + ret = dsdb_get_sd_from_ldb_message(ldb_module_get_ctx(module), msg, sd_msg, &sd); if (ret != LDB_SUCCESS) { return ret; } @@ -638,7 +634,7 @@ static int acl_add(struct ldb_module *module, struct ldb_request *req) schema = dsdb_get_schema(ldb, req); if (!schema) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } oc_el = ldb_msg_find_element(req->op.add.message, "objectClass"); @@ -724,7 +720,7 @@ static int acl_check_self_membership(TALLOC_CTX *mem_ctx, } member_el = ldb_msg_find_element(req->op.mod.message, "member"); if (!member_el) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* user can only remove oneself */ if (member_el->num_values == 0) { @@ -766,7 +762,7 @@ static int acl_check_password_rights(TALLOC_CTX *mem_ctx, msg = ldb_msg_copy_shallow(tmp_ctx, req->op.mod.message); if (msg == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } for (l = passwordAttrs; *l != NULL; l++) { while ((el = ldb_msg_find_element(msg, *l)) != NULL) { @@ -865,7 +861,7 @@ static int acl_modify(struct ldb_module *module, struct ldb_request *req) goto fail; } - ret = dsdb_get_sd_from_ldb_message(tmp_ctx, acl_res->msgs[0], &sd); + ret = dsdb_get_sd_from_ldb_message(ldb, tmp_ctx, acl_res->msgs[0], &sd); if (ret != LDB_SUCCESS) { DEBUG(10, ("acl_modify: cannot get descriptor\n")); goto fail; @@ -1095,37 +1091,37 @@ static int acl_rename(struct ldb_module *module, struct ldb_request *req) schema = dsdb_get_schema(ldb, acl_res); if (!schema) { talloc_free(acl_res); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } guid = get_oc_guid_from_message(module, schema, acl_res->msgs[0]); if (!insert_in_object_tree(tmp_ctx, guid, SEC_ADS_WRITE_PROP, &root, &new_node)) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); }; guid = attribute_schemaid_guid_by_lDAPDisplayName(schema, "name"); if (!insert_in_object_tree(tmp_ctx, guid, SEC_ADS_WRITE_PROP, &new_node, &new_node)) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); }; rdn_name = ldb_dn_get_rdn_name(req->op.rename.olddn); if (rdn_name == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } guid = attribute_schemaid_guid_by_lDAPDisplayName(schema, rdn_name); if (!insert_in_object_tree(tmp_ctx, guid, SEC_ADS_WRITE_PROP, &new_node, &new_node)) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); }; - ret = dsdb_get_sd_from_ldb_message(req, acl_res->msgs[0], &sd); + ret = dsdb_get_sd_from_ldb_message(ldb, req, acl_res->msgs[0], &sd); if (ret != LDB_SUCCESS) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Theoretically we pass the check if the object has no sd */ if (!sd) { @@ -1298,8 +1294,7 @@ static int acl_search(struct ldb_module *module, struct ldb_request *req) ac = talloc_zero(req, struct acl_context); if (ac == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } data = talloc_get_type(ldb_module_get_private(module), struct acl_private); diff --git a/source4/dsdb/samdb/ldb_modules/anr.c b/source4/dsdb/samdb/ldb_modules/anr.c index 8411d98bdb..68f007ebd9 100644 --- a/source4/dsdb/samdb/ldb_modules/anr.c +++ b/source4/dsdb/samdb/ldb_modules/anr.c @@ -151,8 +151,7 @@ static int anr_replace_value(struct anr_context *ac, struct ldb_val *match2 = talloc(mem_ctx, struct ldb_val); *match2 = data_blob_const(match->data+1, match->length - 1); if (match2 == NULL){ - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } match = match2; op = LDB_OP_EQUALITY; @@ -167,8 +166,7 @@ static int anr_replace_value(struct anr_context *ac, /* Inject an 'or' with the current tree */ tree = make_parse_list(module, mem_ctx, LDB_OP_OR, tree, match_tree); if (tree == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } } else { tree = match_tree; @@ -186,8 +184,7 @@ static int anr_replace_value(struct anr_context *ac, struct ldb_val *first_match = talloc(tree, struct ldb_val); struct ldb_val *second_match = talloc(tree, struct ldb_val); if (!first_match || !second_match) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } *first_match = data_blob_const(match->data, p-match->data); *second_match = data_blob_const(p+1, match->length - (p-match->data) - 1); @@ -199,8 +196,7 @@ static int anr_replace_value(struct anr_context *ac, first_split_filter = make_parse_list(module, ac, LDB_OP_AND, match_tree_1, match_tree_2); if (first_split_filter == NULL){ - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } match_tree_1 = make_match_tree(module, mem_ctx, op, "sn", first_match); @@ -208,15 +204,13 @@ static int anr_replace_value(struct anr_context *ac, second_split_filter = make_parse_list(module, ac, LDB_OP_AND, match_tree_1, match_tree_2); if (second_split_filter == NULL){ - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } split_filters = make_parse_list(module, mem_ctx, LDB_OP_OR, first_split_filter, second_split_filter); if (split_filters == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } if (tree) { @@ -331,8 +325,7 @@ static int anr_search(struct ldb_module *module, struct ldb_request *req) ac = talloc(req, struct anr_context); if (!ac) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ac->module = module; @@ -345,7 +338,7 @@ static int anr_search(struct ldb_module *module, struct ldb_request *req) ret = anr_replace_subtrees(ac, req->op.search.tree, "anr", &anr_tree); if (ret != LDB_SUCCESS) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } if (!ac->found_anr) { @@ -363,7 +356,7 @@ static int anr_search(struct ldb_module *module, struct ldb_request *req) ac, anr_search_callback, req); if (ret != LDB_SUCCESS) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } talloc_steal(down_req, anr_tree); diff --git a/source4/dsdb/samdb/ldb_modules/descriptor.c b/source4/dsdb/samdb/ldb_modules/descriptor.c index 0e9558278d..d96e18e15f 100644 --- a/source4/dsdb/samdb/ldb_modules/descriptor.c +++ b/source4/dsdb/samdb/ldb_modules/descriptor.c @@ -675,7 +675,7 @@ static int descriptor_do_add(struct descriptor_context *ac) schema = dsdb_get_schema(ldb, ac); mem_ctx = talloc_new(ac); if (mem_ctx == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } switch (ac->req->operation) { case LDB_ADD: @@ -692,7 +692,7 @@ static int descriptor_do_add(struct descriptor_context *ac) msg = ldb_msg_copy_shallow(ac, ac->req->op.mod.message); break; default: - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } @@ -791,7 +791,7 @@ static int descriptor_change(struct ldb_module *module, struct ldb_request *req) } break; default: - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ldb_debug(ldb, LDB_DEBUG_TRACE,"descriptor_change: %s\n", ldb_dn_get_linearized(dn)); @@ -801,7 +801,7 @@ static int descriptor_change(struct ldb_module *module, struct ldb_request *req) ac = descriptor_init_context(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* If there isn't a parent, just go on to the add processing */ @@ -812,8 +812,7 @@ static int descriptor_change(struct ldb_module *module, struct ldb_request *req) /* get copy of parent DN */ parent_dn = ldb_dn_get_parent(ac, dn); if (parent_dn == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = ldb_build_search_req(&search_req, ldb, @@ -848,7 +847,7 @@ static int descriptor_search(struct ldb_module *module, struct ldb_request *req) ldb = ldb_module_get_ctx(module); ac = descriptor_init_context(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = ldb_build_search_req_ex(&down_req, ldb, ac, @@ -884,7 +883,7 @@ static int descriptor_init(struct ldb_module *module) if (ret != LDB_SUCCESS) { ldb_debug(ldb, LDB_DEBUG_ERROR, "descriptor: Unable to register control with rootdse!\n"); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } return ldb_next_init(module); } diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn_in.c b/source4/dsdb/samdb/ldb_modules/extended_dn_in.c index e040ee1b5e..74417d2bbf 100644 --- a/source4/dsdb/samdb/ldb_modules/extended_dn_in.c +++ b/source4/dsdb/samdb/ldb_modules/extended_dn_in.c @@ -279,8 +279,7 @@ static int extended_dn_in_fix(struct ldb_module *module, struct ldb_request *req base_dn_filter = talloc_asprintf(req, "(objectSid=%s)", ldb_binary_encode(req, *sid_val)); if (!base_dn_filter) { - ldb_oom(ldb_module_get_ctx(module)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } base_dn_scope = LDB_SCOPE_SUBTREE; base_dn_attrs = no_attr; @@ -292,8 +291,7 @@ static int extended_dn_in_fix(struct ldb_module *module, struct ldb_request *req base_dn_filter = talloc_asprintf(req, "(objectGUID=%s)", ldb_binary_encode(req, *guid_val)); if (!base_dn_filter) { - ldb_oom(ldb_module_get_ctx(module)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } base_dn_scope = LDB_SCOPE_SUBTREE; base_dn_attrs = no_attr; @@ -316,8 +314,7 @@ static int extended_dn_in_fix(struct ldb_module *module, struct ldb_request *req wellknown_object = talloc_asprintf(req, "B:32:%s:", wkguid_dup); if (!wellknown_object) { - ldb_oom(ldb_module_get_ctx(module)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } tail_str = p; @@ -325,13 +322,11 @@ static int extended_dn_in_fix(struct ldb_module *module, struct ldb_request *req base_dn = ldb_dn_new(req, ldb_module_get_ctx(module), tail_str); talloc_free(wkguid_dup); if (!base_dn) { - ldb_oom(ldb_module_get_ctx(module)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } base_dn_filter = talloc_strdup(req, "(objectClass=*)"); if (!base_dn_filter) { - ldb_oom(ldb_module_get_ctx(module)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } base_dn_scope = LDB_SCOPE_BASE; base_dn_attrs = wkattr; @@ -341,8 +336,7 @@ static int extended_dn_in_fix(struct ldb_module *module, struct ldb_request *req ac = talloc_zero(req, struct extended_search_context); if (ac == NULL) { - ldb_oom(ldb_module_get_ctx(module)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } ac->module = module; @@ -363,7 +357,7 @@ static int extended_dn_in_fix(struct ldb_module *module, struct ldb_request *req ac, extended_base_callback, req); if (ret != LDB_SUCCESS) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } if (all_partitions) { diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn_out.c b/source4/dsdb/samdb/ldb_modules/extended_dn_out.c index 12adf16181..ba4054a4c3 100644 --- a/source4/dsdb/samdb/ldb_modules/extended_dn_out.c +++ b/source4/dsdb/samdb/ldb_modules/extended_dn_out.c @@ -96,7 +96,7 @@ static bool add_attrs(void *mem_ctx, char ***attrs, const char *attr) */ -static int fix_dn(struct ldb_dn *dn) +static int fix_dn(struct ldb_context *ldb, struct ldb_dn *dn) { int i, ret; char *upper_rdn_attr; @@ -106,7 +106,7 @@ static int fix_dn(struct ldb_dn *dn) upper_rdn_attr = strupper_talloc(dn, ldb_dn_get_component_name(dn, i)); if (!upper_rdn_attr) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* And replace it with CN=foo (we need the attribute in upper case */ @@ -338,7 +338,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares, } if (p && p->normalise) { - ret = fix_dn(ares->message->dn); + ret = fix_dn(ldb, ares->message->dn); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, NULL, NULL, ret); } @@ -368,8 +368,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares, ares->message->dn); } if (ret != LDB_SUCCESS) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } } } @@ -468,7 +467,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares, } if (p->normalise) { - ret = fix_dn(dn); + ret = fix_dn(ldb, dn); if (ret != LDB_SUCCESS) { talloc_free(dsdb_dn); return ldb_module_done(ac->req, NULL, NULL, ret); @@ -581,8 +580,7 @@ static int extended_dn_out_search(struct ldb_module *module, struct ldb_request ac = talloc_zero(req, struct extended_search_context); if (ac == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ac->module = module; @@ -617,17 +615,16 @@ static int extended_dn_out_search(struct ldb_module *module, struct ldb_request if (ac->remove_guid || ac->remove_sid) { new_attrs = copy_attrs(ac, req->op.search.attrs); if (new_attrs == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } if (ac->remove_guid) { if (!add_attrs(ac, &new_attrs, "objectGUID")) - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } if (ac->remove_sid) { if (!add_attrs(ac, &new_attrs, "objectSID")) - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } const_attrs = (const char * const *)new_attrs; } @@ -697,15 +694,13 @@ static int extended_dn_out_ldb_init(struct ldb_module *module) ldb_module_set_private(module, p); if (!p) { - ldb_oom(ldb_module_get_ctx(module)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } dn_format = talloc(p, struct dsdb_extended_dn_store_format); if (!dn_format) { talloc_free(p); - ldb_oom(ldb_module_get_ctx(module)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } dn_format->store_extended_dn_in_ldb = true; @@ -722,7 +717,7 @@ static int extended_dn_out_ldb_init(struct ldb_module *module) if (ret != LDB_SUCCESS) { ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_ERROR, "extended_dn_out: Unable to register control with rootdse!\n"); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } return ldb_next_init(module); @@ -742,15 +737,13 @@ static int extended_dn_out_dereference_init(struct ldb_module *module, const cha ldb_module_set_private(module, p); if (!p) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } dn_format = talloc(p, struct dsdb_extended_dn_store_format); if (!dn_format) { talloc_free(p); - ldb_oom(ldb_module_get_ctx(module)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } dn_format->store_extended_dn_in_ldb = false; @@ -771,7 +764,7 @@ static int extended_dn_out_dereference_init(struct ldb_module *module, const cha if (ret != LDB_SUCCESS) { ldb_debug(ldb, LDB_DEBUG_ERROR, "extended_dn_out: Unable to register control with rootdse!\n"); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = ldb_next_init(module); @@ -790,8 +783,7 @@ static int extended_dn_out_dereference_init(struct ldb_module *module, const cha = talloc_zero(p, struct dsdb_openldap_dereference_control); if (!p->dereference_control) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } for (cur = schema->attributes; cur; cur = cur->next) { @@ -802,14 +794,12 @@ static int extended_dn_out_dereference_init(struct ldb_module *module, const cha = talloc_realloc(p, dereference_control->dereference, struct dsdb_openldap_dereference *, i + 2); if (!dereference_control) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } dereference_control->dereference[i] = talloc(dereference_control->dereference, struct dsdb_openldap_dereference); if (!dereference_control->dereference[i]) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } dereference_control->dereference[i]->source_attribute = cur->lDAPDisplayName; dereference_control->dereference[i]->dereference_attribute = attrs; diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn_store.c b/source4/dsdb/samdb/ldb_modules/extended_dn_store.c index 731e4c368b..07d106e222 100644 --- a/source4/dsdb/samdb/ldb_modules/extended_dn_store.c +++ b/source4/dsdb/samdb/ldb_modules/extended_dn_store.c @@ -233,7 +233,7 @@ static int extended_store_replace(struct extended_dn_context *ac, os = talloc_zero(ac, struct extended_dn_replace_list); if (!os) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ac->ldb); } os->ac = ac; @@ -307,7 +307,7 @@ static int extended_dn_add(struct ldb_module *module, struct ldb_request *req) ac = extended_dn_context_init(module, req); if (!ac) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } if (!ac->schema) { @@ -333,8 +333,7 @@ static int extended_dn_add(struct ldb_module *module, struct ldb_request *req) if (!ac->new_req) { struct ldb_message *msg = ldb_msg_copy(ac, req->op.add.message); if (!msg) { - ldb_oom(ldb_module_get_ctx(module)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } ret = ldb_build_add_req(&ac->new_req, ac->ldb, ac, msg, req->controls, ac, extended_final_callback, req); @@ -382,7 +381,7 @@ static int extended_dn_modify(struct ldb_module *module, struct ldb_request *req ac = extended_dn_context_init(module, req); if (!ac) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } if (!ac->schema) { @@ -409,8 +408,7 @@ static int extended_dn_modify(struct ldb_module *module, struct ldb_request *req struct ldb_message *msg = ldb_msg_copy(ac, req->op.mod.message); if (!msg) { talloc_free(ac); - ldb_oom(ac->ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ac->ldb); } ret = ldb_build_mod_req(&ac->new_req, ac->ldb, ac, msg, req->controls, ac, extended_final_callback, req); diff --git a/source4/dsdb/samdb/ldb_modules/instancetype.c b/source4/dsdb/samdb/ldb_modules/instancetype.c index f71a8d3948..7360c7c993 100644 --- a/source4/dsdb/samdb/ldb_modules/instancetype.c +++ b/source4/dsdb/samdb/ldb_modules/instancetype.c @@ -118,7 +118,7 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) * entries (lost+found, deleted objects) */ ac = talloc(req, struct it_context); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ac->module = module; ac->req = req; @@ -140,8 +140,7 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) /* we have to copy the message as the caller might have it as a const */ msg = ldb_msg_copy_shallow(req, req->op.add.message); if (msg == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* @@ -151,8 +150,7 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) ret = ldb_msg_add_fmt(msg, "instanceType", "%u", instance_type); if (ret != LDB_SUCCESS) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = ldb_build_add_req(&down_req, ldb, req, diff --git a/source4/dsdb/samdb/ldb_modules/kludge_acl.c b/source4/dsdb/samdb/ldb_modules/kludge_acl.c index 42f0a306f4..86f9bc43cc 100644 --- a/source4/dsdb/samdb/ldb_modules/kludge_acl.c +++ b/source4/dsdb/samdb/ldb_modules/kludge_acl.c @@ -115,8 +115,7 @@ static int kludge_acl_allowedAttributes(struct ldb_context *ldb, struct ldb_mess mem_ctx = talloc_new(msg); if (!mem_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* To ensure that oc_el is valid, we must look for it after @@ -323,8 +322,7 @@ static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req) ac = talloc(req, struct kludge_acl_context); if (ac == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } data = talloc_get_type(ldb_module_get_private(module), struct kludge_private_data); @@ -457,8 +455,7 @@ static int kludge_acl_init(struct ldb_module *module) data = talloc(module, struct kludge_private_data); if (data == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } data->password_attrs = NULL; @@ -467,8 +464,7 @@ static int kludge_acl_init(struct ldb_module *module) ldb_module_set_private(module, data); if (!mem_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = ldb_search(ldb, mem_ctx, &res, @@ -495,8 +491,7 @@ static int kludge_acl_init(struct ldb_module *module) data->password_attrs = talloc_array(data, const char *, password_attributes->num_values + 1); if (!data->password_attrs) { talloc_free(mem_ctx); - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } for (i=0; i < password_attributes->num_values; i++) { data->password_attrs[i] = (const char *)password_attributes->values[i].data; diff --git a/source4/dsdb/samdb/ldb_modules/lazy_commit.c b/source4/dsdb/samdb/ldb_modules/lazy_commit.c index b4eaf50d51..5c9c772f08 100644 --- a/source4/dsdb/samdb/ldb_modules/lazy_commit.c +++ b/source4/dsdb/samdb/ldb_modules/lazy_commit.c @@ -113,7 +113,7 @@ static int unlazy_init(struct ldb_module *module) if (ret != LDB_SUCCESS) { ldb_debug(ldb, LDB_DEBUG_ERROR, "lazy_commit: Unable to register control with rootdse!\n"); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } return ldb_next_init(module); diff --git a/source4/dsdb/samdb/ldb_modules/linked_attributes.c b/source4/dsdb/samdb/ldb_modules/linked_attributes.c index 8648ab3bfd..67ae236fb1 100644 --- a/source4/dsdb/samdb/ldb_modules/linked_attributes.c +++ b/source4/dsdb/samdb/ldb_modules/linked_attributes.c @@ -103,7 +103,7 @@ static int la_guid_from_dn(struct la_context *ac, struct ldb_dn *dn, struct GUID if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { DEBUG(4,(__location__ ": Unable to parse GUID for dn %s\n", ldb_dn_get_linearized(dn))); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(ac->module)); } ret = dsdb_find_guid_by_dn(ldb_module_get_ctx(ac->module), dn, guid); @@ -138,8 +138,7 @@ static int la_store_op(struct la_context *ac, os = talloc_zero(ac, struct la_op_store); if (!os) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } os->op = op; @@ -162,8 +161,7 @@ static int la_store_op(struct la_context *ac, os->name = talloc_strdup(os, name); if (!os->name) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* Do deletes before adds */ @@ -209,7 +207,7 @@ static int linked_attributes_add(struct ldb_module *module, struct ldb_request * ac = linked_attributes_init(module, req); if (!ac) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } if (!ac->schema) { @@ -434,7 +432,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques ac = linked_attributes_init(module, req); if (!ac) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } if (!ac->schema) { @@ -444,8 +442,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques ac->rc = talloc_zero(ac, struct replace_context); if (!ac->rc) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } for (i=0; i < req->op.mod.message->num_elements; i++) { @@ -536,8 +533,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques struct ldb_message_element, ac->rc->num_elements +1); if (!search_el) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ac->rc->el = search_el; @@ -552,8 +548,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques attrs = talloc_array(ac->rc, const char *, ac->rc->num_elements + 1); if (!attrs) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } for (i = 0; ac->rc && i < ac->rc->num_elements; i++) { attrs[i] = ac->rc->el[i].name; @@ -724,8 +719,7 @@ static int linked_attributes_rename(struct ldb_module *module, struct ldb_reques schema = dsdb_get_schema(ldb, res); if (!schema) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } msg = res->msgs[0]; @@ -760,7 +754,7 @@ static int la_queue_mod_request(struct la_context *ac) if (la_private == NULL) { ldb_debug(ldb_module_get_ctx(ac->module), LDB_DEBUG_ERROR, __location__ ": No la_private transaction setup\n"); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(ac->module)); } talloc_steal(la_private, ac); @@ -935,8 +929,7 @@ static int la_do_op_request(struct ldb_module *module, struct la_context *ac, st /* Create the modify request */ new_msg = ldb_msg_new(ac); if (!new_msg) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = la_find_dn_target(module, ac, &op->guid, &new_msg->dn); @@ -956,8 +949,7 @@ static int la_do_op_request(struct ldb_module *module, struct la_context *ac, st } ret_el->values = talloc_array(new_msg, struct ldb_val, 1); if (!ret_el->values) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret_el->num_values = 1; if (op->op == LA_OP_ADD) { @@ -1021,7 +1013,7 @@ static int linked_attributes_start_transaction(struct ldb_module *module) talloc_free(la_private); la_private = talloc(module, struct la_private); if (la_private == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } la_private->la_list = NULL; ldb_module_set_private(module, la_private); diff --git a/source4/dsdb/samdb/ldb_modules/local_password.c b/source4/dsdb/samdb/ldb_modules/local_password.c index 4f9cfd63d4..942b5a2543 100644 --- a/source4/dsdb/samdb/ldb_modules/local_password.c +++ b/source4/dsdb/samdb/ldb_modules/local_password.c @@ -187,12 +187,12 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req /* From here, we assume we have password attributes to split off */ ac = lpdb_init_context(module, req); if (!ac) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } remote_message = ldb_msg_copy_shallow(remote_req, req->op.add.message); if (remote_message == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Remove any password attributes from the remote message */ @@ -205,7 +205,7 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req ac->local_message = ldb_msg_copy_shallow(ac, req->op.add.message); if (ac->local_message == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Remove anything seen in the remote message from the local @@ -232,7 +232,7 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req PASSWORD_GUID_ATTR "=%s", GUID_string(ac->local_message, &objectGUID)))) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = ldb_build_add_req(&remote_req, ldb, ac, @@ -339,12 +339,12 @@ static int local_password_modify(struct ldb_module *module, struct ldb_request * /* From here, we assume we have password attributes to split off */ ac = lpdb_init_context(module, req); if (!ac) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } remote_message = ldb_msg_copy_shallow(ac, ac->req->op.mod.message); if (remote_message == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Remove any password attributes from the remote message */ @@ -354,7 +354,7 @@ static int local_password_modify(struct ldb_module *module, struct ldb_request * ac->local_message = ldb_msg_copy_shallow(ac, ac->req->op.mod.message); if (ac->local_message == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Remove anything seen in the remote message from the local @@ -571,7 +571,7 @@ static int local_password_delete(struct ldb_module *module, /* From here, we assume we have password attributes to split off */ ac = lpdb_init_context(module, req); if (!ac) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = ldb_build_del_req(&remote_req, ldb, ac, @@ -769,7 +769,7 @@ static int lpdb_local_search(struct lpdb_context *ac) ac, lpdb_local_search_callback, ac->req); if (ret != LDB_SUCCESS) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } return ldb_next_request(ac->module, local_req); @@ -1046,7 +1046,7 @@ static int local_password_search(struct ldb_module *module, struct ldb_request * ac = lpdb_init_context(module, req); if (!ac) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Remote search is for all attributes: if the remote LDAP server has these attributes, then it overrides the local database */ @@ -1055,7 +1055,7 @@ static int local_password_search(struct ldb_module *module, struct ldb_request * search_attrs = ldb_attr_list_copy_add(ac, req->op.search.attrs, "objectGUID"); ac->added_objectGUID = true; if (!search_attrs) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } } else { search_attrs = req->op.search.attrs; @@ -1064,7 +1064,7 @@ static int local_password_search(struct ldb_module *module, struct ldb_request * search_attrs = ldb_attr_list_copy_add(ac, search_attrs, "objectClass"); ac->added_objectClass = true; if (!search_attrs) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } } } else { diff --git a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c index 3a10a604ec..5023657d86 100644 --- a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c @@ -47,8 +47,7 @@ static int naming_fsmo_init(struct ldb_module *module) mem_ctx = talloc_new(module); if (!mem_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } naming_dn = samdb_partitions_dn(ldb, mem_ctx); @@ -61,8 +60,7 @@ static int naming_fsmo_init(struct ldb_module *module) naming_fsmo = talloc_zero(mem_ctx, struct dsdb_naming_fsmo); if (!naming_fsmo) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ldb_module_set_private(module, naming_fsmo); @@ -84,8 +82,7 @@ static int naming_fsmo_init(struct ldb_module *module) } if (ldb_set_opaque(ldb, "dsdb_naming_fsmo", naming_fsmo) != LDB_SUCCESS) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } talloc_steal(module, naming_fsmo); diff --git a/source4/dsdb/samdb/ldb_modules/new_partition.c b/source4/dsdb/samdb/ldb_modules/new_partition.c index a6102d6a6f..33da2a445b 100644 --- a/source4/dsdb/samdb/ldb_modules/new_partition.c +++ b/source4/dsdb/samdb/ldb_modules/new_partition.c @@ -114,8 +114,7 @@ static int np_part_search_callback(struct ldb_request *req, struct ldb_reply *ar /* Now that we know it does not exist, we can try and create the partition */ ex_op = talloc(ac, struct dsdb_create_partition_exop); if (ex_op == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ex_op->new_dn = ac->req->op.add.message->dn; @@ -174,7 +173,7 @@ static int new_partition_add(struct ldb_module *module, struct ldb_request *req) * record already exists */ ac = talloc(req, struct np_context); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ac->module = module; ac->req = req; diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c index ed97a7d429..5883d5c97e 100644 --- a/source4/dsdb/samdb/ldb_modules/objectclass.c +++ b/source4/dsdb/samdb/ldb_modules/objectclass.c @@ -136,8 +136,7 @@ static int objectclass_sort(struct ldb_module *module, for (i=0; i < objectclass_element->num_values; i++) { current = talloc(mem_ctx, struct class_list); if (!current) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } current->objectclass = dsdb_class_by_lDAPDisplayName_ldb_val(schema, &objectclass_element->values[i]); if (!current->objectclass) { @@ -311,7 +310,8 @@ static int oc_op_callback(struct ldb_request *req, struct ldb_reply *ares) CN=Admins,CN=Users,DC=samba,DC=example,DC=com */ -static int fix_dn(TALLOC_CTX *mem_ctx, +static int fix_dn(struct ldb_context *ldb, + TALLOC_CTX *mem_ctx, struct ldb_dn *newdn, struct ldb_dn *parent_dn, struct ldb_dn **fixed_dn) { @@ -325,12 +325,12 @@ static int fix_dn(TALLOC_CTX *mem_ctx, upper_rdn_attr = strupper_talloc(*fixed_dn, ldb_dn_get_rdn_name(newdn)); if (!upper_rdn_attr) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Create a new child */ if (ldb_dn_add_child_fmt(*fixed_dn, "X=X") == false) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } @@ -386,12 +386,12 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req) val = ldb_dn_get_component_val(req->op.add.message->dn, ldb_dn_get_comp_num(req->op.add.message->dn) - 1); if (val == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } value = talloc_asprintf(req, "ldap://%s/%s", val->data, ldb_dn_get_linearized(req->op.add.message->dn)); if (value == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } return ldb_module_send_referral(req, value); @@ -407,7 +407,7 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req) ac = oc_init_context(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* If there isn't a parent, just go on to the add processing */ @@ -418,8 +418,7 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req) /* get copy of parent DN */ parent_dn = ldb_dn_get_parent(ac, ac->req->op.add.message->dn); if (parent_dn == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = ldb_build_search_req(&search_req, ldb, @@ -470,7 +469,7 @@ static int objectclass_do_add(struct oc_context *ac) } else { /* Fix up the DN to be in the standard form, taking * particular care to match the parent DN */ - ret = fix_dn(msg, + ret = fix_dn(ldb, msg, ac->req->op.add.message->dn, ac->search_res->message->dn, &msg->dn); @@ -483,8 +482,7 @@ static int objectclass_do_add(struct oc_context *ac) mem_ctx = talloc_new(ac); if (mem_ctx == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } if (ac->schema != NULL) { @@ -494,7 +492,7 @@ static int objectclass_do_add(struct oc_context *ac) if (!objectclass_element) { /* Where did it go? bail now... */ talloc_free(mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = objectclass_sort(ac->module, ac->schema, mem_ctx, objectclass_element, &sorted); @@ -518,9 +516,8 @@ static int objectclass_do_add(struct oc_context *ac) for (current = sorted; current; current = current->next) { value = talloc_strdup(msg, current->objectclass->lDAPDisplayName); if (value == NULL) { - ldb_oom(ldb); talloc_free(mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = ldb_msg_add_string(msg, "objectClass", value); if (ret != LDB_SUCCESS) { @@ -601,9 +598,8 @@ static int objectclass_do_add(struct oc_context *ac) value = talloc_strdup(msg, objectclass->defaultObjectCategory); } if (value == NULL) { - ldb_oom(ldb); talloc_free(mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ldb_msg_add_string(msg, "objectCategory", value); } @@ -699,7 +695,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req ac = oc_init_context(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Without schema, there isn't much to do here */ @@ -710,7 +706,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req msg = ldb_msg_copy_shallow(ac, req->op.mod.message); if (msg == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* For now change everything except the objectclasses */ @@ -808,36 +804,34 @@ static int objectclass_do_mod(struct oc_context *ac) /* we should always have a valid entry when we enter here */ if (ac->search_res == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } oc_el_entry = ldb_msg_find_element(ac->search_res->message, "objectClass"); if (oc_el_entry == NULL) { /* existing entry without a valid object class? */ - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } oc_el_change = ldb_msg_find_element(ac->req->op.mod.message, "objectClass"); if (oc_el_change == NULL) { /* we should have an objectclass change operation */ - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* use a new message structure */ msg = ldb_msg_new(ac); if (msg == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } msg->dn = ac->req->op.mod.message->dn; mem_ctx = talloc_new(ac); if (mem_ctx == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } switch (oc_el_change->flags & LDB_FLAG_MOD_MASK) { @@ -858,9 +852,8 @@ static int objectclass_do_mod(struct oc_context *ac) struct ldb_val, oc_el_entry->num_values + 1); if (vals == NULL) { - ldb_oom(ldb); talloc_free(mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } oc_el_entry->values = vals; oc_el_entry->values[oc_el_entry->num_values] = @@ -906,7 +899,7 @@ static int objectclass_do_mod(struct oc_context *ac) oc_el_entry); if (objectclass == NULL) { talloc_free(mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Merge the two message elements */ @@ -974,9 +967,8 @@ static int objectclass_do_mod(struct oc_context *ac) value = talloc_strdup(msg, current->objectclass->lDAPDisplayName); if (value == NULL) { - ldb_oom(ldb); talloc_free(mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = ldb_msg_add_string(msg, "objectClass", value); if (ret != LDB_SUCCESS) { @@ -1049,7 +1041,7 @@ static int objectclass_rename(struct ldb_module *module, struct ldb_request *req ac = oc_init_context(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } parent_dn = ldb_dn_get_parent(ac, req->op.rename.newdn); @@ -1155,12 +1147,12 @@ static int objectclass_do_rename2(struct oc_context *ac) "objectClass"); if (oc_el_entry == NULL) { /* existing entry without a valid object class? */ - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } objectclass = get_last_structural_class(ac->schema, oc_el_entry); if (objectclass == NULL) { /* existing entry without a valid object class? */ - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } rdn_name = ldb_dn_get_rdn_name(ac->req->op.rename.newdn); @@ -1178,7 +1170,7 @@ static int objectclass_do_rename2(struct oc_context *ac) "objectClass"); if (oc_el_parent == NULL) { /* existing entry without a valid object class? */ - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } for (i=0; allowed_class == false && i < oc_el_parent->num_values; i++) { @@ -1218,7 +1210,7 @@ static int objectclass_do_rename2(struct oc_context *ac) /* Fix up the DN to be in the standard form, taking * particular care to match the parent DN */ - ret = fix_dn(ac, + ret = fix_dn(ldb, ac, ac->req->op.rename.newdn, ac->search_res2->message->dn, &fixed_dn); @@ -1269,7 +1261,7 @@ static int objectclass_delete(struct ldb_module *module, struct ldb_request *req ac = oc_init_context(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* this looks up the entry object for fetching some important diff --git a/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c b/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c index 36bd86072d..6cfecc0d72 100644 --- a/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c +++ b/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c @@ -88,8 +88,7 @@ static int attr_handler(struct oc_context *ac) msg = ldb_msg_copy_shallow(ac, ac->req->op.mod.message); } if (msg == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* Check if attributes exist in the schema, if the values match, @@ -167,7 +166,7 @@ static int attr_handler2(struct oc_context *ac) ldb = ldb_module_get_ctx(ac->module); if (ac->search_res == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* We rely here on the preceeding "objectclass" LDB module which did @@ -175,7 +174,7 @@ static int attr_handler2(struct oc_context *ac) oc_element = ldb_msg_find_element(ac->search_res->message, "objectClass"); if (oc_element == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } must_contain = dsdb_full_attribute_list(ac, ac->schema, oc_element, @@ -185,7 +184,7 @@ static int attr_handler2(struct oc_context *ac) found_must_contain = const_str_list(str_list_copy(ac, must_contain)); if ((must_contain == NULL) || (may_contain == NULL) || (found_must_contain == NULL)) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Check if all specified attributes are valid in the given @@ -195,7 +194,7 @@ static int attr_handler2(struct oc_context *ac) attr = dsdb_attribute_by_lDAPDisplayName(ac->schema, msg->elements[i].name); if (attr == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Check if they're single-valued if this is requested */ @@ -365,7 +364,7 @@ static int objectclass_attrs_add(struct ldb_module *module, ac = oc_init_context(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* without schema, there isn't much to do here */ @@ -394,7 +393,7 @@ static int objectclass_attrs_modify(struct ldb_module *module, ac = oc_init_context(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* without schema, there isn't much to do here */ diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c index 7f95c9788b..b7dbb51bd7 100644 --- a/source4/dsdb/samdb/ldb_modules/objectguid.c +++ b/source4/dsdb/samdb/ldb_modules/objectguid.c @@ -158,7 +158,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) ac = talloc(req, struct og_context); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ac->module = module; ac->req = req; @@ -167,7 +167,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) msg = ldb_msg_copy_shallow(ac, req->op.add.message); if (msg == NULL) { talloc_free(down_req); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* a new GUID */ @@ -180,7 +180,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) if (add_time_element(msg, "whenCreated", t) != 0 || add_time_element(msg, "whenChanged", t) != 0) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Get a sequence number from the backend */ @@ -190,7 +190,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) if (ret == LDB_SUCCESS) { if (add_uint64_element(msg, "uSNCreated", seq_num) != 0 || add_uint64_element(msg, "uSNChanged", seq_num) != 0) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } } @@ -229,7 +229,7 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req) ac = talloc(req, struct og_context); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ac->module = module; ac->req = req; @@ -237,18 +237,18 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req) /* we have to copy the message as the caller might have it as a const */ msg = ldb_msg_copy_shallow(ac, req->op.mod.message); if (msg == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } if (add_time_element(msg, "whenChanged", t) != 0) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Get a sequence number from the backend */ ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret == LDB_SUCCESS) { if (add_uint64_element(msg, "uSNChanged", seq_num) != 0) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } } diff --git a/source4/dsdb/samdb/ldb_modules/operational.c b/source4/dsdb/samdb/ldb_modules/operational.c index f249b357f8..03502d3de3 100644 --- a/source4/dsdb/samdb/ldb_modules/operational.c +++ b/source4/dsdb/samdb/ldb_modules/operational.c @@ -93,7 +93,7 @@ static int construct_canonical_name(struct ldb_module *module, char *canonicalName; canonicalName = ldb_dn_canonical_string(msg, msg->dn); if (canonicalName == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } return ldb_msg_add_steal_string(msg, "canonicalName", canonicalName); } @@ -146,8 +146,7 @@ static int construct_token_groups(struct ldb_module *module, status = auth_context_create_from_ldb(tmp_ctx, ldb, &auth_context); if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MEMORY)) { talloc_free(tmp_ctx); - ldb_module_oom(module); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } else if (!NT_STATUS_IS_OK(status)) { ldb_set_errstring(ldb, "Cannot provide tokenGroups attribute, could not create authContext"); talloc_free(tmp_ctx); @@ -157,8 +156,7 @@ static int construct_token_groups(struct ldb_module *module, status = auth_get_server_info_principal(tmp_ctx, auth_context, NULL, msg->dn, &server_info); if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MEMORY)) { talloc_free(tmp_ctx); - ldb_module_oom(module); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } else if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER)) { /* Not a user, we have no tokenGroups */ talloc_free(tmp_ctx); @@ -172,8 +170,7 @@ static int construct_token_groups(struct ldb_module *module, status = auth_generate_session_info(tmp_ctx, auth_context, server_info, 0, &session_info); if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MEMORY)) { talloc_free(tmp_ctx); - ldb_module_oom(module); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } else if (!NT_STATUS_IS_OK(status)) { talloc_free(tmp_ctx); ldb_asprintf_errstring(ldb, "Cannot provide tokenGroups attribute: auth_generate_session_info failed: %s", nt_errstr(status)); @@ -236,7 +233,7 @@ static int construct_parent_guid(struct ldb_module *module, v = data_blob_dup_talloc(res, parent_guid); if (!v.data) { talloc_free(res); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } ret = ldb_msg_add_steal_value(msg, "parentGUID", &v); talloc_free(res); @@ -284,21 +281,21 @@ static int construct_msds_isrodc_with_dn(struct ldb_module *module, ldb = ldb_module_get_ctx(module); if (!ldb) { DEBUG(4, (__location__ ": Failed to get ldb \n")); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } dn = ldb_dn_new(msg, ldb, (const char *)object_category->values[0].data); if (!dn) { DEBUG(4, (__location__ ": Failed to create dn from %s \n", (const char *)object_category->values[0].data)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } val = ldb_dn_get_rdn_val(dn); if (!val) { DEBUG(4, (__location__ ": Failed to get rdn val from %s \n", ldb_dn_get_linearized(dn))); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } if (strequal((const char *)val->data, "NTDS-DSA")) { @@ -323,7 +320,7 @@ static int construct_msds_isrodc_with_server_dn(struct ldb_module *module, if (!ldb_dn_add_child_fmt(server_dn, "CN=NTDS Settings")) { DEBUG(4, (__location__ ": Failed to add child to %s \n", ldb_dn_get_linearized(server_dn))); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } ret = dsdb_module_search_dn(module, msg, &res, server_dn, attr_obj_cat, 0); @@ -390,7 +387,7 @@ static int construct_msds_isrodc(struct ldb_module *module, if (!object_class) { DEBUG(4,(__location__ ": Can't get objectClass for %s \n", ldb_dn_get_linearized(msg->dn))); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } for (i=0; i<object_class->num_values; i++) { @@ -460,7 +457,7 @@ static int construct_msds_keyversionnumber(struct ldb_module *module, if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { DEBUG(0,(__location__ ": Failed to parse replPropertyMetaData for %s when trying to add msDS-KeyVersionNumber\n", ldb_dn_get_linearized(msg->dn))); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } if (omd->version != 1) { @@ -732,7 +729,7 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req ac = talloc(req, struct operational_context); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ac->module = module; @@ -777,7 +774,7 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req : ac->attrs, search_sub[i].extra_attr); if (search_attrs2 == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* may be NULL, talloc_free() doesn't mind */ talloc_free(search_attrs); @@ -787,7 +784,7 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req if (!search_attrs) { search_attrs = ldb_attr_list_copy(req, ac->attrs); if (search_attrs == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } } /* Despite the ldb_attr_list_copy_add, this is safe as that fn only adds to the end */ @@ -806,7 +803,7 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req ac, operational_callback, req); if (ret != LDB_SUCCESS) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* perform the search */ @@ -827,8 +824,7 @@ static int operational_init(struct ldb_module *ctx) data = talloc_zero(ctx, struct operational_data); if (!data) { - ldb_module_oom(ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(ctx); } ldb_module_set_private(ctx, data); diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c index ba695d2221..e6a315d2ef 100644 --- a/source4/dsdb/samdb/ldb_modules/partition.c +++ b/source4/dsdb/samdb/ldb_modules/partition.c @@ -244,8 +244,7 @@ static int partition_prep_request(struct partition_context *ac, struct part_request, ac->num_requests + 1); if (ac->part_req == NULL) { - ldb_oom(ldb_module_get_ctx(ac->module)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(ac->module)); } switch (ac->req->operation) { @@ -314,8 +313,7 @@ static int partition_prep_request(struct partition_context *ac, req->controls = talloc_memdup(req, ac->req->controls, talloc_get_size(ac->req->controls)); if (req->controls == NULL) { - ldb_oom(ldb_module_get_ctx(ac->module)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(ac->module)); } } @@ -406,7 +404,7 @@ static int partition_replicate(struct ldb_module *module, struct ldb_request *re ac = partition_init_ctx(module, req); if (!ac) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } return partition_send_all(module, ac, req); @@ -432,7 +430,7 @@ static int partition_replicate(struct ldb_module *module, struct ldb_request *re ac = partition_init_ctx(module, req); if (!ac) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } /* we need to add a control but we never touch the original request */ @@ -490,8 +488,7 @@ static int partition_search(struct ldb_module *module, struct ldb_request *req) /* Remove the "domain_scope" control, so we don't confuse a backend * server */ if (domain_scope_control && !save_controls(domain_scope_control, req, &saved_controls)) { - ldb_oom(ldb_module_get_ctx(module)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } /* Locate the options */ @@ -514,7 +511,7 @@ static int partition_search(struct ldb_module *module, struct ldb_request *req) ac = partition_init_ctx(module, req); if (!ac) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } ldb = ldb_module_get_ctx(ac->module); @@ -590,16 +587,14 @@ static int partition_search(struct ldb_module *module, struct ldb_request *req) req->op.search.scope == LDB_SCOPE_ONELEVEL ? "??base" : ""); if (ref == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* Initialise the referrals list */ if (ac->referrals == NULL) { ac->referrals = (const char **) str_list_make_empty(ac); if (ac->referrals == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } } @@ -623,8 +618,7 @@ static int partition_search(struct ldb_module *module, struct ldb_request *req) talloc_free(ref); if (ac->referrals == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } } if (ldb_dn_compare_base(data->partitions[i]->ctrl->dn, req->op.search.base) == 0) { @@ -682,7 +676,7 @@ static int partition_rename(struct ldb_module *module, struct ldb_request *req) /* Skip the lot if 'data' isn't here yet (initialisation) */ if (!data) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } backend = find_partition(data, req->op.rename.olddn, req); @@ -844,7 +838,7 @@ static int partition_del_trans(struct ldb_module *module) if (data->in_transaction == 0) { DEBUG(0,("partition del transaction mismatch\n")); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } data->in_transaction--; @@ -868,12 +862,12 @@ int partition_primary_sequence_number(struct ldb_module *module, TALLOC_CTX *mem struct ldb_seqnum_result *seqr; res = talloc_zero(mem_ctx, struct ldb_result); if (res == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } tseq = talloc_zero(res, struct ldb_seqnum_request); if (tseq == NULL) { talloc_free(res); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } tseq->type = type; @@ -957,12 +951,12 @@ static int partition_sequence_number(struct ldb_module *module, struct ldb_reque res = talloc_zero(req, struct ldb_result); if (res == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } tseq = talloc_zero(res, struct ldb_seqnum_request); if (tseq == NULL) { talloc_free(res); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } tseq->type = seq->type; @@ -1013,13 +1007,13 @@ static int partition_sequence_number(struct ldb_module *module, struct ldb_reque res = talloc_zero(req, struct ldb_result); if (res == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } tseq = talloc_zero(res, struct ldb_seqnum_request); if (tseq == NULL) { talloc_free(res); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } tseq->type = LDB_SEQ_HIGHEST_TIMESTAMP; @@ -1057,13 +1051,13 @@ static int partition_sequence_number(struct ldb_module *module, struct ldb_reque res = talloc_zero(req, struct ldb_result); if (res == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } tseq = talloc_zero(res, struct ldb_seqnum_request); if (tseq == NULL) { talloc_free(res); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } tseq->type = LDB_SEQ_HIGHEST_TIMESTAMP; @@ -1112,12 +1106,12 @@ static int partition_sequence_number(struct ldb_module *module, struct ldb_reque ext = talloc_zero(req, struct ldb_extended); if (!ext) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } seqr = talloc_zero(ext, struct ldb_seqnum_result); if (seqr == NULL) { talloc_free(ext); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } ext->oid = LDB_EXTENDED_SEQUENCE_NUMBER; ext->data = seqr; @@ -1185,7 +1179,7 @@ static int partition_extended(struct ldb_module *module, struct ldb_request *req ac = partition_init_ctx(module, req); if (!ac) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } return partition_send_all(module, ac, req); diff --git a/source4/dsdb/samdb/ldb_modules/partition_init.c b/source4/dsdb/samdb/ldb_modules/partition_init.c index b3b52e3cb1..99d2f1de47 100644 --- a/source4/dsdb/samdb/ldb_modules/partition_init.c +++ b/source4/dsdb/samdb/ldb_modules/partition_init.c @@ -55,7 +55,7 @@ static int partition_load_replicate_dns(struct ldb_context *ldb, struct partitio int i; data->replicate = talloc_array(data, struct ldb_dn *, replicate_attributes->num_values + 1); if (!data->replicate) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } for (i=0; i < replicate_attributes->num_values; i++) { @@ -86,8 +86,7 @@ static int partition_load_modules(struct ldb_context *ldb, data->modules = talloc_array(data, struct partition_module *, modules_attributes->num_values + 1); if (!data->modules) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } for (i=0; i < modules_attributes->num_values; i++) { @@ -95,8 +94,7 @@ static int partition_load_modules(struct ldb_context *ldb, DATA_BLOB dn_blob; data->modules[i] = talloc(data->modules, struct partition_module); if (!data->modules[i]) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } dn_blob = modules_attributes->values[i]; @@ -120,7 +118,7 @@ static int partition_load_modules(struct ldb_context *ldb, } else { data->modules[i]->dn = ldb_dn_from_ldb_val(data->modules[i], ldb, &dn_blob); if (!data->modules[i]->dn || !ldb_dn_validate(data->modules[i]->dn)) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } } } @@ -205,14 +203,13 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva (*partition) = talloc(mem_ctx, struct dsdb_partition); if (!*partition) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } (*partition)->ctrl = ctrl = talloc((*partition), struct dsdb_control_current_partition); if (!ctrl) { talloc_free(*partition); - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* See if an LDAP backend has been specified */ @@ -227,7 +224,7 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva ldb_asprintf_errstring(ldb, "partition_init: unable to determine an relative path for partition: %s", filename); talloc_free(*partition); - return LDB_ERR_OPERATIONS_ERROR; + return LDB_ERR_OPERATIONS_ERROR; } (*partition)->backend_url = talloc_steal((*partition), backend_url); @@ -285,9 +282,8 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva /* This weirdness allows us to use ldb_next_request() in partition.c */ (*partition)->module = ldb_module_new(*partition, ldb, "partition_next", NULL); if (!(*partition)->module) { - ldb_oom(ldb); talloc_free(*partition); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } (*partition)->module->next = talloc_steal((*partition)->module, module_chain); @@ -313,8 +309,7 @@ static int partition_register(struct ldb_context *ldb, struct dsdb_control_curre req = talloc_zero(NULL, struct ldb_request); if (req == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } req->operation = LDB_REQ_REGISTER_PARTITION; @@ -326,7 +321,7 @@ static int partition_register(struct ldb_context *ldb, struct dsdb_control_curre req->handle = ldb_handle_new(req, ldb); if (req->handle == NULL) { talloc_free(req); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = ldb_request(ldb, req); @@ -356,8 +351,7 @@ static int add_partition_to_data(struct ldb_context *ldb, struct partition_priva /* Add partition to list of partitions */ data->partitions = talloc_realloc(data, data->partitions, struct dsdb_partition *, i + 2); if (!data->partitions) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } data->partitions[i] = talloc_steal(data->partitions, partition); data->partitions[i+1] = NULL; @@ -390,8 +384,7 @@ int partition_reload_if_required(struct ldb_module *module, mem_ctx = talloc_new(data); if (!mem_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = partition_primary_sequence_number(module, mem_ctx, LDB_SEQ_HIGHEST_SEQ, &seq); @@ -701,8 +694,7 @@ int partition_create(struct ldb_module *module, struct ldb_request *req) new_partition = true; mod_msg = ldb_msg_new(req); if (!mod_msg) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } mod_msg->dn = ldb_dn_new(mod_msg, ldb, DSDB_PARTITION_DN); @@ -718,7 +710,7 @@ int partition_create(struct ldb_module *module, struct ldb_request *req) const char *p, *sam_name; sam_name = strrchr((const char *)ldb_get_opaque(ldb, "ldb_url"), '/'); if (!sam_name) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } sam_name++; @@ -735,8 +727,7 @@ int partition_create(struct ldb_module *module, struct ldb_request *req) if (*p) { escaped = rfc1738_escape_part(mod_msg, casefold_dn); if (!escaped) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } filename = talloc_asprintf(mod_msg, "%s.d/%s.ldb", sam_name, escaped); talloc_free(escaped); @@ -745,8 +736,7 @@ int partition_create(struct ldb_module *module, struct ldb_request *req) } if (!filename) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } } partition_record = talloc_asprintf(mod_msg, "%s:%s", casefold_dn, filename); @@ -809,12 +799,12 @@ int partition_init(struct ldb_module *module) struct partition_private_data *data; if (!mem_ctx) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } data = talloc_zero(mem_ctx, struct partition_private_data); if (data == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* When used from Samba4, this message is set by the samba4 @@ -838,14 +828,14 @@ int partition_init(struct ldb_module *module) if (ret != LDB_SUCCESS) { ldb_debug(ldb, LDB_DEBUG_ERROR, "partition: Unable to register control with rootdse!\n"); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = ldb_mod_register_control(module, LDB_CONTROL_SEARCH_OPTIONS_OID); if (ret != LDB_SUCCESS) { ldb_debug(ldb, LDB_DEBUG_ERROR, "partition: Unable to register control with rootdse!\n"); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } return ldb_next_init(module); diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c index 505f2c26f7..99bba57d10 100644 --- a/source4/dsdb/samdb/ldb_modules/password_hash.c +++ b/source4/dsdb/samdb/ldb_modules/password_hash.c @@ -177,8 +177,7 @@ static int setup_nt_fields(struct setup_password_fields_io *io) struct samr_Password, io->ac->status->domain_data.pwdHistoryLength); if (!io->g.nt_history) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } for (i = 0; i < MIN(io->ac->status->domain_data.pwdHistoryLength-1, @@ -220,8 +219,7 @@ static int setup_lm_fields(struct setup_password_fields_io *io) struct samr_Password, io->ac->status->domain_data.pwdHistoryLength); if (!io->g.lm_history) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } for (i = 0; i < MIN(io->ac->status->domain_data.pwdHistoryLength-1, @@ -265,8 +263,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) name = strlower_talloc(io->ac, io->u.sAMAccountName); if (!name) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } if (name[strlen(name)-1] == '$') { @@ -276,8 +273,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) saltbody = talloc_asprintf(io->ac, "%s.%s", name, io->ac->status->domain_data.dns_domain); if (!saltbody) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } krb5_ret = krb5_make_principal(io->smb_krb5_context->krb5_context, @@ -290,8 +286,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) user_principal_name = talloc_strdup(io->ac, io->u.user_principal_name); if (!user_principal_name) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } p = strchr(user_principal_name, '@'); @@ -338,8 +333,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) salt.saltvalue.length); krb5_free_salt(io->smb_krb5_context->krb5_context, salt); if (!io->g.salt) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } salt.saltvalue.data = discard_const(io->g.salt); salt.saltvalue.length = strlen(io->g.salt); @@ -366,8 +360,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) key.keyvalue.length); krb5_free_keyblock_contents(io->smb_krb5_context->krb5_context, &key); if (!io->g.aes_256.data) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* @@ -392,8 +385,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) key.keyvalue.length); krb5_free_keyblock_contents(io->smb_krb5_context->krb5_context, &key); if (!io->g.aes_128.data) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* @@ -418,8 +410,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) key.keyvalue.length); krb5_free_keyblock_contents(io->smb_krb5_context->krb5_context, &key); if (!io->g.des_md5.data) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* @@ -444,8 +435,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) key.keyvalue.length); krb5_free_keyblock_contents(io->smb_krb5_context->krb5_context, &key); if (!io->g.des_crc.data) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } return LDB_SUCCESS; @@ -478,8 +468,7 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io, struct package_PrimaryKerberosKey3, pkb3->num_keys); if (!pkb3->keys) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } pkb3->keys[0].keytype = ENCTYPE_DES_CBC_MD5; @@ -514,8 +503,7 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io, blob = strhex_to_data_blob(io->ac, old_scp->data); if (!blob.data) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* TODO: use ndr_pull_struct_blob_all(), when the ndr layer handles it correct with relative pointers */ @@ -584,8 +572,7 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io, struct package_PrimaryKerberosKey4, pkb4->num_keys); if (!pkb4->keys) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } pkb4->keys[0].iteration_count = 4096; @@ -630,8 +617,7 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io, blob = strhex_to_data_blob(io->ac, old_scp->data); if (!blob.data) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* TODO: use ndr_pull_struct_blob_all(), when the ndr layer handles it correct with relative pointers */ @@ -923,13 +909,11 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, sAMAccountName = data_blob_string_const(io->u.sAMAccountName); sAMAccountName_l = data_blob_string_const(strlower_talloc(io->ac, io->u.sAMAccountName)); if (!sAMAccountName_l.data) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } sAMAccountName_u = data_blob_string_const(strupper_talloc(io->ac, io->u.sAMAccountName)); if (!sAMAccountName_u.data) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* if the user doesn't have a userPrincipalName, create one (with lower case realm) */ @@ -938,34 +922,29 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, io->u.sAMAccountName, io->ac->status->domain_data.dns_domain); if (!user_principal_name) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } } userPrincipalName = data_blob_string_const(user_principal_name); userPrincipalName_l = data_blob_string_const(strlower_talloc(io->ac, user_principal_name)); if (!userPrincipalName_l.data) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } userPrincipalName_u = data_blob_string_const(strupper_talloc(io->ac, user_principal_name)); if (!userPrincipalName_u.data) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } netbios_domain = data_blob_string_const(io->ac->status->domain_data.netbios_domain); netbios_domain_l = data_blob_string_const(strlower_talloc(io->ac, io->ac->status->domain_data.netbios_domain)); if (!netbios_domain_l.data) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } netbios_domain_u = data_blob_string_const(strupper_talloc(io->ac, io->ac->status->domain_data.netbios_domain)); if (!netbios_domain_u.data) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } dns_domain = data_blob_string_const(io->ac->status->domain_data.dns_domain); @@ -981,8 +960,7 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, pdb->hashes = talloc_array(io->ac, struct package_PrimaryWDigestHash, pdb->num_hashes); if (!pdb->hashes) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } for (i=0; i < ARRAY_SIZE(wdigest); i++) { @@ -1158,8 +1136,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pknb_hexstr = data_blob_hex_string_upper(io->ac, &pknb_blob); if (!pknb_hexstr) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } pkn->name = "Primary:Kerberos-Newer-Keys"; pkn->reserved = 1; @@ -1189,8 +1166,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pkb_hexstr = data_blob_hex_string_upper(io->ac, &pkb_blob); if (!pkb_hexstr) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } pk->name = "Primary:Kerberos"; pk->reserved = 1; @@ -1219,8 +1195,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pdb_hexstr = data_blob_hex_string_upper(io->ac, &pdb_blob); if (!pdb_hexstr) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } pd->name = "Primary:WDigest"; pd->reserved = 1; @@ -1247,8 +1222,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pcb_hexstr = data_blob_hex_string_upper(io->ac, &pcb_blob); if (!pcb_hexstr) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } pc->name = "Primary:CLEARTEXT"; pc->reserved = 1; @@ -1272,8 +1246,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pb_hexstr = data_blob_hex_string_upper(io->ac, &pb_blob); if (!pb_hexstr) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } pp->name = "Packages"; pp->reserved = 2; @@ -1324,8 +1297,7 @@ static int setup_given_passwords(struct setup_password_fields_io *io, cleartext_utf16_blob = talloc(io->ac, struct ldb_val); if (!cleartext_utf16_blob) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } if (!convert_string_talloc(io->ac, CH_UTF8, CH_UTF16, @@ -1348,8 +1320,7 @@ static int setup_given_passwords(struct setup_password_fields_io *io, cleartext_utf8_blob = talloc(io->ac, struct ldb_val); if (!cleartext_utf8_blob) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } if (!convert_string_talloc(io->ac, CH_UTF16MUNGED, CH_UTF8, @@ -1371,8 +1342,7 @@ static int setup_given_passwords(struct setup_password_fields_io *io, nt_hash = talloc(io->ac, struct samr_Password); if (!nt_hash) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } g->nt_hash = nt_hash; @@ -1387,8 +1357,7 @@ static int setup_given_passwords(struct setup_password_fields_io *io, lm_hash = talloc(io->ac, struct samr_Password); if (!lm_hash) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* compute the new lm hash */ @@ -1644,7 +1613,7 @@ static int setup_io(struct ph_context *ac, ldb_get_event_context(ldb), (struct loadparm_context *)ldb_get_opaque(ldb, "loadparm"), &io->smb_krb5_context) != 0) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } io->ac = ac; @@ -1738,8 +1707,7 @@ static int setup_io(struct ph_context *ac, */ quoted_utf16_2 = talloc(io->ac, struct ldb_val); if (quoted_utf16_2 == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } quoted_utf16_2->data = quoted_utf16->data + 2; @@ -1795,8 +1763,7 @@ static int setup_io(struct ph_context *ac, */ old_quoted_utf16_2 = talloc(io->ac, struct ldb_val); if (old_quoted_utf16_2 == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } old_quoted_utf16_2->data = old_quoted_utf16->data + 2; @@ -1927,7 +1894,7 @@ static int setup_io(struct ph_context *ac, } } else { /* this shouldn't happen */ - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } return LDB_SUCCESS; @@ -2253,7 +2220,7 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) ac = ph_init_context(module, req); if (ac == NULL) { DEBUG(0,(__location__ ": %s\n", ldb_errstring(ldb))); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ph_apply_controls(ac); @@ -2280,9 +2247,11 @@ static int password_hash_add_do_add(struct ph_context *ac) return ret; } + ldb = ldb_module_get_ctx(ac->module); + msg = ldb_msg_copy_shallow(ac, ac->req->op.add.message); if (msg == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* remove attributes that we just read into 'io' */ @@ -2292,8 +2261,6 @@ static int password_hash_add_do_add(struct ph_context *ac) ldb_msg_remove_attr(msg, "dBCSPwd"); ldb_msg_remove_attr(msg, "pwdLastSet"); - ldb = ldb_module_get_ctx(ac->module); - ret = setup_password_fields(&io); if (ret != LDB_SUCCESS) { return ret; @@ -2319,7 +2286,7 @@ static int password_hash_add_do_add(struct ph_context *ac) } } if (io.g.nt_history_len > 0) { - ret = samdb_msg_add_hashes(ac, msg, + ret = samdb_msg_add_hashes(ldb, ac, msg, "ntPwdHistory", io.g.nt_history, io.g.nt_history_len); @@ -2328,7 +2295,7 @@ static int password_hash_add_do_add(struct ph_context *ac) } } if (io.g.lm_history_len > 0) { - ret = samdb_msg_add_hashes(ac, msg, + ret = samdb_msg_add_hashes(ldb, ac, msg, "lmPwdHistory", io.g.lm_history, io.g.lm_history_len); @@ -2426,15 +2393,14 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r ac = ph_init_context(module, req); if (!ac) { DEBUG(0,(__location__ ": %s\n", ldb_errstring(ldb))); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ph_apply_controls(ac); /* use a new message structure so that we can modify it */ msg = ldb_msg_copy_shallow(ac, req->op.mod.message); if (msg == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* - check for single-valued password attributes @@ -2677,7 +2643,7 @@ static int password_hash_mod_do_mod(struct ph_context *ac) /* use a new message structure so that we can modify it */ msg = ldb_msg_new(ac); if (msg == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* modify dn */ @@ -2698,7 +2664,7 @@ static int password_hash_mod_do_mod(struct ph_context *ac) discard_const_p(struct ldb_message, searched_msg), &io.o.lm_hash, &io.o.nt_hash); if (!NT_STATUS_IS_OK(status)) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } io.o.nt_history_len = samdb_result_hashes(io.ac, searched_msg, "ntPwdHistory", &io.o.nt_history); @@ -2738,7 +2704,7 @@ static int password_hash_mod_do_mod(struct ph_context *ac) } } if (io.g.nt_history_len > 0) { - ret = samdb_msg_add_hashes(ac, msg, + ret = samdb_msg_add_hashes(ldb, ac, msg, "ntPwdHistory", io.g.nt_history, io.g.nt_history_len); @@ -2747,7 +2713,7 @@ static int password_hash_mod_do_mod(struct ph_context *ac) } } if (io.g.lm_history_len > 0) { - ret = samdb_msg_add_hashes(ac, msg, + ret = samdb_msg_add_hashes(ldb, ac, msg, "lmPwdHistory", io.g.lm_history, io.g.lm_history_len); diff --git a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c index 0c5afd8e9c..2d45ae28ae 100644 --- a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c @@ -46,8 +46,7 @@ static int pdc_fsmo_init(struct ldb_module *module) mem_ctx = talloc_new(module); if (!mem_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } pdc_dn = ldb_get_default_basedn(ldb); @@ -60,8 +59,7 @@ static int pdc_fsmo_init(struct ldb_module *module) pdc_fsmo = talloc_zero(mem_ctx, struct dsdb_pdc_fsmo); if (!pdc_fsmo) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ldb_module_set_private(module, pdc_fsmo); @@ -89,8 +87,7 @@ static int pdc_fsmo_init(struct ldb_module *module) } if (ldb_set_opaque(ldb, "dsdb_pdc_fsmo", pdc_fsmo) != LDB_SUCCESS) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } talloc_steal(module, pdc_fsmo); diff --git a/source4/dsdb/samdb/ldb_modules/proxy.c b/source4/dsdb/samdb/ldb_modules/proxy.c index 616563e2d0..109afd22fe 100644 --- a/source4/dsdb/samdb/ldb_modules/proxy.c +++ b/source4/dsdb/samdb/ldb_modules/proxy.c @@ -155,7 +155,7 @@ failed: talloc_free(proxy->newdn); talloc_free(proxy->upstream); proxy->upstream = NULL; - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } @@ -319,7 +319,7 @@ static int proxy_search_bytree(struct ldb_module *module, struct ldb_request *re } if (load_proxy_info(module) != LDB_SUCCESS) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* see if the dn is within olddn */ @@ -329,7 +329,7 @@ static int proxy_search_bytree(struct ldb_module *module, struct ldb_request *re ac = talloc(req, struct proxy_ctx); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ac->module = module; diff --git a/source4/dsdb/samdb/ldb_modules/ranged_results.c b/source4/dsdb/samdb/ldb_modules/ranged_results.c index 0c992e0e12..a3a1aae984 100644 --- a/source4/dsdb/samdb/ldb_modules/ranged_results.c +++ b/source4/dsdb/samdb/ldb_modules/ranged_results.c @@ -216,15 +216,14 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) (size_t)(p - new_attrs[i])); if (!new_attrs[i]) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } } if (found_rr) { ac = rr_init_context(module, req); if (!ac) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = ldb_build_search_req_ex(&down_req, ldb, ac, diff --git a/source4/dsdb/samdb/ldb_modules/resolve_oids.c b/source4/dsdb/samdb/ldb_modules/resolve_oids.c index 16cabc18cd..3c9ebcd745 100644 --- a/source4/dsdb/samdb/ldb_modules/resolve_oids.c +++ b/source4/dsdb/samdb/ldb_modules/resolve_oids.c @@ -53,8 +53,7 @@ static int resolve_oids_need_value(struct ldb_context *ldb, case DRSUAPI_ATTRIBUTE_possSuperiors: str = talloc_strndup(ldb, (char *)valp->data, valp->length); if (!str) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } vo = dsdb_class_by_governsID_oid(schema, str); talloc_free(str); @@ -68,8 +67,7 @@ static int resolve_oids_need_value(struct ldb_context *ldb, case DRSUAPI_ATTRIBUTE_mayContain: str = talloc_strndup(ldb, (char *)valp->data, valp->length); if (!str) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } va = dsdb_attribute_by_attributeID_oid(schema, str); talloc_free(str); @@ -246,8 +244,7 @@ static int resolve_oids_replace_value(struct ldb_context *ldb, case DRSUAPI_ATTRIBUTE_possSuperiors: str = talloc_strndup(schema, (char *)valp->data, valp->length); if (!str) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } vo = dsdb_class_by_governsID_oid(schema, str); talloc_free(str); @@ -262,8 +259,7 @@ static int resolve_oids_replace_value(struct ldb_context *ldb, case DRSUAPI_ATTRIBUTE_mayContain: str = talloc_strndup(schema, (char *)valp->data, valp->length); if (!str) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } va = dsdb_attribute_by_attributeID_oid(schema, str); talloc_free(str); @@ -509,22 +505,19 @@ static int resolve_oids_search(struct ldb_module *module, struct ldb_request *re ac = talloc(req, struct resolve_oids_context); if (ac == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ac->module = module; ac->req = req; tree = ldb_parse_tree_copy_shallow(ac, req->op.search.tree); if (!tree) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } schema = talloc_reference(tree, schema); if (!schema) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = resolve_oids_parse_tree_replace(ldb, schema, @@ -536,8 +529,7 @@ static int resolve_oids_search(struct ldb_module *module, struct ldb_request *re attrs2 = str_list_copy_const(ac, discard_const_p(const char *, req->op.search.attrs)); if (req->op.search.attrs && !attrs2) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } for (i=0; attrs2 && attrs2[i]; i++) { @@ -604,21 +596,18 @@ static int resolve_oids_add(struct ldb_module *module, struct ldb_request *req) ac = talloc(req, struct resolve_oids_context); if (ac == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ac->module = module; ac->req = req; msg = ldb_msg_copy_shallow(ac, ac->req->op.add.message); if (!msg) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } if (!talloc_reference(msg, schema)) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = resolve_oids_message_replace(ldb, schema, msg); @@ -670,8 +659,7 @@ static int resolve_oids_modify(struct ldb_module *module, struct ldb_request *re ac = talloc(req, struct resolve_oids_context); if (ac == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ac->module = module; ac->req = req; @@ -679,13 +667,11 @@ static int resolve_oids_modify(struct ldb_module *module, struct ldb_request *re /* we have to copy the message as the caller might have it as a const */ msg = ldb_msg_copy_shallow(ac, req->op.mod.message); if (msg == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } if (!talloc_reference(msg, schema)) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = resolve_oids_message_replace(ldb, schema, msg); diff --git a/source4/dsdb/samdb/ldb_modules/ridalloc.c b/source4/dsdb/samdb/ldb_modules/ridalloc.c index c14a679ec3..55636d13a7 100644 --- a/source4/dsdb/samdb/ldb_modules/ridalloc.c +++ b/source4/dsdb/samdb/ldb_modules/ridalloc.c @@ -178,9 +178,8 @@ static int ridalloc_create_rid_set_ntds(struct ldb_module *module, TALLOC_CTX *m server_dn = ldb_dn_get_parent(tmp_ctx, ntds_dn); if (!server_dn) { - ldb_module_oom(module); talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } ret = dsdb_module_reference_dn(module, tmp_ctx, server_dn, "serverReference", &machine_dn); @@ -193,15 +192,13 @@ static int ridalloc_create_rid_set_ntds(struct ldb_module *module, TALLOC_CTX *m rid_set_dn = ldb_dn_copy(tmp_ctx, machine_dn); if (rid_set_dn == NULL) { - ldb_module_oom(module); talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } if (! ldb_dn_add_child_fmt(rid_set_dn, "CN=RID Set")) { - ldb_module_oom(module); talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } /* grab a pool from the RID Manager object */ @@ -345,9 +342,8 @@ static int ridalloc_refresh_rid_set_ntds(struct ldb_module *module, server_dn = ldb_dn_get_parent(tmp_ctx, ntds_dn); if (!server_dn) { - ldb_module_oom(module); talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } ret = dsdb_module_reference_dn(module, tmp_ctx, server_dn, "serverReference", &machine_dn); @@ -587,9 +583,8 @@ int ridalloc_allocate_rid_pool_fsmo(struct ldb_module *module, struct dsdb_fsmo_ server_dn = ldb_dn_get_parent(tmp_ctx, ntds_dn); if (!server_dn) { - ldb_module_oom(module); talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } ret = dsdb_module_reference_dn(module, tmp_ctx, server_dn, "serverReference", &machine_dn); diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c index 2219f59ef1..3e5a94673f 100644 --- a/source4/dsdb/samdb/ldb_modules/rootdse.c +++ b/source4/dsdb/samdb/ldb_modules/rootdse.c @@ -89,19 +89,19 @@ static int expand_dn_in_message(struct ldb_module *module, struct ldb_message *m dn_string = talloc_strndup(tmp_ctx, (const char *)v->data, v->length); if (dn_string == NULL) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } res = talloc_zero(tmp_ctx, struct ldb_result); if (res == NULL) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } dn = ldb_dn_new(tmp_ctx, ldb, dn_string); if (!ldb_dn_validate(dn)) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = ldb_build_search_req(&req2, ldb, tmp_ctx, @@ -137,7 +137,7 @@ static int expand_dn_in_message(struct ldb_module *module, struct ldb_message *m if (!res || res->count != 1) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } dn2 = res->msgs[0]->dn; @@ -147,7 +147,7 @@ static int expand_dn_in_message(struct ldb_module *module, struct ldb_message *m if (v->data == NULL) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } talloc_free(tmp_ctx); @@ -404,7 +404,7 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms return LDB_SUCCESS; failed: - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* @@ -506,7 +506,7 @@ static int rootdse_search(struct ldb_module *module, struct ldb_request *req) ac = rootdse_init_context(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* in our db we store the rootDSE with a DN of @ROOTDSE */ @@ -532,12 +532,12 @@ static int rootdse_register_control(struct ldb_module *module, struct ldb_reques list = talloc_realloc(priv, priv->controls, char *, priv->num_controls + 1); if (!list) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } list[priv->num_controls] = talloc_strdup(list, req->op.reg_control.oid); if (!list[priv->num_controls]) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } priv->num_controls += 1; @@ -553,12 +553,12 @@ static int rootdse_register_partition(struct ldb_module *module, struct ldb_requ list = talloc_realloc(priv, priv->partitions, struct ldb_dn *, priv->num_partitions + 1); if (!list) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } list[priv->num_partitions] = ldb_dn_copy(list, req->op.reg_partition.dn); if (!list[priv->num_partitions]) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } priv->num_partitions += 1; @@ -597,8 +597,7 @@ static int rootdse_init(struct ldb_module *module) data = talloc_zero(module, struct private_data); if (data == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } data->num_controls = 0; @@ -617,8 +616,7 @@ static int rootdse_init(struct ldb_module *module) mem_ctx = talloc_new(data); if (!mem_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* Now that the partitions are set up, do a search for: @@ -638,9 +636,8 @@ static int rootdse_init(struct ldb_module *module) if (domain_behaviour_version != -1) { int *val = talloc(ldb, int); if (!val) { - ldb_oom(ldb); talloc_free(mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } *val = domain_behaviour_version; ret = ldb_set_opaque(ldb, "domainFunctionality", val); @@ -661,9 +658,8 @@ static int rootdse_init(struct ldb_module *module) if (forest_behaviour_version != -1) { int *val = talloc(ldb, int); if (!val) { - ldb_oom(ldb); talloc_free(mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } *val = forest_behaviour_version; ret = ldb_set_opaque(ldb, "forestFunctionality", val); @@ -691,9 +687,8 @@ static int rootdse_init(struct ldb_module *module) if (domain_controller_behaviour_version != -1) { int *val = talloc(ldb, int); if (!val) { - ldb_oom(ldb); talloc_free(mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } *val = domain_controller_behaviour_version; ret = ldb_set_opaque(ldb, @@ -954,7 +949,7 @@ static int rootdse_schemaupdatenow(struct ldb_module *module, struct ldb_request ret = ldb_extended(ldb, DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID, schema_dn, &ext_res); if (ret != LDB_SUCCESS) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } talloc_free(ext_res); diff --git a/source4/dsdb/samdb/ldb_modules/samba3sid.c b/source4/dsdb/samdb/ldb_modules/samba3sid.c index b4dbd4af02..6c21382cd3 100644 --- a/source4/dsdb/samdb/ldb_modules/samba3sid.c +++ b/source4/dsdb/samdb/ldb_modules/samba3sid.c @@ -112,9 +112,8 @@ static int samba3sid_next_sid(struct ldb_module *module, (*sid) = talloc_asprintf(tmp_ctx, "%s-%d", sambaSID, rid); if (!*sid) { - ldb_module_oom(module); talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } ret = dsdb_module_constrainted_update_integer(module, msg->dn, @@ -166,8 +165,7 @@ static int samba3sid_add(struct ldb_module *module, struct ldb_request *req) new_msg = ldb_msg_copy_shallow(req, req->op.add.message); if (!new_msg) { - ldb_module_oom(module); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } ret = samba3sid_next_sid(module, new_msg, &sid); diff --git a/source4/dsdb/samdb/ldb_modules/samba_dsdb.c b/source4/dsdb/samdb/ldb_modules/samba_dsdb.c index b12d25a720..09990b06fb 100644 --- a/source4/dsdb/samdb/ldb_modules/samba_dsdb.c +++ b/source4/dsdb/samdb/ldb_modules/samba_dsdb.c @@ -49,15 +49,13 @@ static int read_at_rootdse_record(struct ldb_context *ldb, struct ldb_module *mo struct ldb_dn *rootdse_dn; TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); if (!tmp_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } rootdse_dn = ldb_dn_new(tmp_ctx, ldb, "@ROOTDSE"); if (!rootdse_dn) { talloc_free(tmp_ctx); - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = dsdb_module_search_dn(module, tmp_ctx, &rootdse_res, rootdse_dn, rootdse_attrs, 0); @@ -87,8 +85,7 @@ static int prepare_modules_line(struct ldb_context *ldb, char *full_string; TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); if (!tmp_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } if (backend_attr) { @@ -112,22 +109,19 @@ static int prepare_modules_line(struct ldb_context *ldb, } if (!backend_full_list) { talloc_free(tmp_ctx); - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } backend_full_list = str_list_append_const(backend_full_list, backend_mod_list); if (!backend_full_list) { talloc_free(tmp_ctx); - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } mod_list_string = str_list_join(tmp_ctx, backend_full_list, ','); if (!mod_list_string) { talloc_free(tmp_ctx); - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } full_string = talloc_asprintf(tmp_ctx, "%s:%s", backend_dn, mod_list_string); @@ -222,15 +216,13 @@ static int samba_dsdb_init(struct ldb_module *module) const char *backendType, *serverRole; if (!tmp_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } samba_dsdb_dn = ldb_dn_new(tmp_ctx, ldb, "@SAMBA_DSDB"); if (!samba_dsdb_dn) { talloc_free(tmp_ctx); - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } #define CHECK_LDB_RET(check_ret) \ @@ -273,8 +265,7 @@ static int samba_dsdb_init(struct ldb_module *module) do { \ if (!final_module_list) { \ talloc_free(tmp_ctx); \ - ldb_oom(ldb); \ - return LDB_ERR_OPERATIONS_ERROR; \ + return ldb_oom(ldb); \ } \ } while (0) @@ -332,8 +323,7 @@ static int samba_dsdb_init(struct ldb_module *module) reverse_module_list = talloc_array(tmp_ctx, const char *, len+1); if (!reverse_module_list) { talloc_free(tmp_ctx); - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } for (i=0; i < len; i++) { reverse_module_list[i] = final_module_list[(len - 1) - i]; diff --git a/source4/dsdb/samdb/ldb_modules/samba_secrets.c b/source4/dsdb/samdb/ldb_modules/samba_secrets.c index dbf4d11f76..d64220fb24 100644 --- a/source4/dsdb/samdb/ldb_modules/samba_secrets.c +++ b/source4/dsdb/samdb/ldb_modules/samba_secrets.c @@ -59,8 +59,7 @@ static int samba_secrets_init(struct ldb_module *module) NULL }; if (!tmp_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* Now prepare the module chain. Oddly, we must give it to ldb_load_modules_list in REVERSE */ @@ -69,8 +68,7 @@ static int samba_secrets_init(struct ldb_module *module) reverse_module_list = talloc_array(tmp_ctx, const char *, len+1); if (!reverse_module_list) { talloc_free(tmp_ctx); - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } for (i=0; i < len; i++) { reverse_module_list[i] = modules_list[(len - 1) - i]; diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index 70a6fd22c1..b9a9720018 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -103,7 +103,7 @@ static int samldb_add_step(struct samldb_ctx *ac, samldb_step_fn_t fn) step = talloc_zero(ac, struct samldb_step); if (step == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(ac->module)); } step->fn = fn; @@ -113,7 +113,7 @@ static int samldb_add_step(struct samldb_ctx *ac, samldb_step_fn_t fn) ac->curstep = step; } else { if (ac->curstep == NULL) - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(ac->module)); for (stepper = ac->curstep; stepper->next != NULL; stepper = stepper->next); stepper->next = step; @@ -125,7 +125,7 @@ static int samldb_add_step(struct samldb_ctx *ac, samldb_step_fn_t fn) static int samldb_first_step(struct samldb_ctx *ac) { if (ac->steps == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(ac->module)); } ac->curstep = ac->steps; @@ -149,7 +149,7 @@ static int samldb_next_step(struct samldb_ctx *ac) } } -static int samldb_generate_samAccountName(struct ldb_message *msg) +static int samldb_generate_samAccountName(struct ldb_context *ldb, struct ldb_message *msg) { char *name; @@ -160,7 +160,7 @@ static int samldb_generate_samAccountName(struct ldb_message *msg) (unsigned int)generate_random(), (unsigned int)generate_random()); if (name == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } return ldb_msg_add_steal_string(msg, "samAccountName", name); } @@ -220,7 +220,7 @@ static int samldb_check_samAccountName(struct samldb_ctx *ac) ldb = ldb_module_get_ctx(ac->module); if (ldb_msg_find_element(ac->msg, "samAccountName") == NULL) { - ret = samldb_generate_samAccountName(ac->msg); + ret = samldb_generate_samAccountName(ldb, ac->msg); if (ret != LDB_SUCCESS) { return ret; } @@ -228,12 +228,12 @@ static int samldb_check_samAccountName(struct samldb_ctx *ac) name = ldb_msg_find_attr_as_string(ac->msg, "samAccountName", NULL); if (name == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } filter = talloc_asprintf(ac, "samAccountName=%s", ldb_binary_encode_string(ac, name)); if (filter == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = ldb_build_search_req(&req, ldb, ac, @@ -337,12 +337,11 @@ static int samldb_allocate_sid(struct samldb_ctx *ac) ac->sid = dom_sid_add_rid(ac, samdb_domain_sid(ldb), rid); if (ac->sid == NULL) { - ldb_module_oom(ac->module); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(ac->module); } if ( ! samldb_msg_add_sid(ac->msg, "objectSid", ac->sid)) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } return samldb_next_step(ac); @@ -424,12 +423,12 @@ static int samldb_dn_from_sid(struct samldb_ctx *ac) ldb = ldb_module_get_ctx(ac->module); if (ac->sid == NULL) - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); filter = talloc_asprintf(ac, "(objectSid=%s)", ldap_encode_ndr_dom_sid(ac, ac->sid)); if (filter == NULL) - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); ret = ldb_build_search_req(&req, ldb, ac, ldb_get_default_basedn(ldb), @@ -455,7 +454,7 @@ static int samldb_check_primaryGroupID_1(struct samldb_ctx *ac) rid = samdb_result_uint(ac->msg, "primaryGroupID", ~0); ac->sid = dom_sid_add_rid(ac, samdb_domain_sid(ldb), rid); if (ac->sid == NULL) - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); ac->res_dn = NULL; return samldb_next_step(ac); @@ -643,7 +642,7 @@ static int samldb_add_handle_msDS_IntId(struct samldb_ctx *ac) __location__": Searching for msDS-IntId=%d failed - %s\n", msds_intid, ldb_errstring(ldb)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } id_exists = (ldb_res->count > 0); @@ -985,7 +984,7 @@ static int samldb_fill_foreignSecurityPrincipal_object(struct samldb_ctx *ac) } if ( ! samldb_msg_add_sid(ac->msg, "objectSid", ac->sid)) { talloc_free(ac); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } } @@ -1018,7 +1017,7 @@ static int samldb_schema_info_update(struct samldb_ctx *ac) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "samldb_schema_info_update: no dsdb_schema loaded"); DEBUG(0,(__location__ ": %s\n", ldb_errstring(ldb))); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } werr = dsdb_module_schema_info_update(ac->module, schema, DSDB_FLAG_NEXT_MODULE); @@ -1028,7 +1027,7 @@ static int samldb_schema_info_update(struct samldb_ctx *ac) "dsdb_module_schema_info_update failed with %s", win_errstr(werr)); DEBUG(0,(__location__ ": %s\n", ldb_errstring(ldb))); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } return LDB_SUCCESS; @@ -1069,13 +1068,13 @@ static int samldb_prim_group_change(struct samldb_ctx *ac) sid = dom_sid_add_rid(ac, samdb_domain_sid(ldb), rid); if (sid == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } prev_prim_group_dn = samdb_search_dn(ldb, ac, NULL, "(objectSID=%s)", dom_sid_string(ac, sid)); if (prev_prim_group_dn == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* Finds out the DN of the new primary group */ @@ -1088,7 +1087,7 @@ static int samldb_prim_group_change(struct samldb_ctx *ac) sid = dom_sid_add_rid(ac, samdb_domain_sid(ldb), rid); if (sid == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } new_prim_group_dn = samdb_search_dn(ldb, ac, NULL, "(objectSID=%s)", @@ -1166,7 +1165,7 @@ static int samldb_member_check(struct samldb_ctx *ac) * for them */ member_dn = ldb_dn_from_ldb_val(ac, ldb, &el->values[i]); if (!ldb_dn_validate(member_dn)) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } prim_group_rid = samdb_search_uint(ldb, ac, (uint32_t) -1, @@ -1181,13 +1180,13 @@ static int samldb_member_check(struct samldb_ctx *ac) sid = dom_sid_add_rid(ac, samdb_domain_sid(ldb), prim_group_rid); if (sid == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } group_dn = samdb_search_dn(ldb, ac, NULL, "(objectSID=%s)", dom_sid_string(ac, sid)); if (group_dn == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } if (ldb_dn_compare(group_dn, ac->msg->dn) == 0) { @@ -1218,7 +1217,7 @@ static int samldb_prim_group_users_check(struct samldb_ctx *ac) } status = dom_sid_split_rid(ac, sid, NULL, &rid); if (!NT_STATUS_IS_OK(status)) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } if (rid == 0) { /* Special object (security principal?) */ @@ -1230,7 +1229,7 @@ static int samldb_prim_group_users_check(struct samldb_ctx *ac) "(&(primaryGroupID=%u)(objectClass=user))", rid); if (count < 0) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } if (count > 0) { return LDB_ERR_ENTRY_ALREADY_EXISTS; @@ -1257,7 +1256,7 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) ac = samldb_ctx_init(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* build the new msg */ @@ -1266,7 +1265,7 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) talloc_free(ac); ldb_debug(ldb, LDB_DEBUG_FATAL, "samldb_add: ldb_msg_copy failed!\n"); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } if (samdb_find_attribute(ldb, ac->msg, @@ -1347,7 +1346,7 @@ static int samldb_modify(struct ldb_module *module, struct ldb_request *req) ac = samldb_ctx_init(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* TODO: do not modify original request, create a new one */ @@ -1459,7 +1458,7 @@ static int samldb_delete(struct ldb_module *module, struct ldb_request *req) ac = samldb_ctx_init(module, req); if (ac == NULL) - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); ret = samldb_prim_group_users_check(ac); if (ret != LDB_SUCCESS) { diff --git a/source4/dsdb/samdb/ldb_modules/schema_data.c b/source4/dsdb/samdb/ldb_modules/schema_data.c index a6487441c1..ec7e7b74b6 100644 --- a/source4/dsdb/samdb/ldb_modules/schema_data.c +++ b/source4/dsdb/samdb/ldb_modules/schema_data.c @@ -115,8 +115,7 @@ static int schema_data_init(struct ldb_module *module) data = talloc(module, struct schema_data_private_data); if (data == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } data->schema_dn = schema_dn; @@ -186,8 +185,7 @@ static int schema_data_add(struct ldb_module *module, struct ldb_request *req) } if (!oid) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } status = dsdb_schema_pfm_find_oid(schema->prefixmap, oid, NULL); @@ -252,8 +250,7 @@ static int generate_dITContentRules(struct ldb_context *ldb, struct ldb_message if (sclass->auxiliaryClass || sclass->systemAuxiliaryClass) { char *ditcontentrule = schema_class_to_dITContentRule(msg, sclass, schema); if (!ditcontentrule) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = ldb_msg_add_steal_string(msg, "dITContentRules", ditcontentrule); if (ret != LDB_SUCCESS) { @@ -274,8 +271,7 @@ static int generate_extendedAttributeInfo(struct ldb_context *ldb, for (attribute = schema->attributes; attribute; attribute = attribute->next) { char *val = schema_attribute_to_extendedInfo(msg, attribute); if (!val) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = ldb_msg_add_string(msg, "extendedAttributeInfo", val); @@ -297,8 +293,7 @@ static int generate_extendedClassInfo(struct ldb_context *ldb, for (sclass = schema->classes; sclass; sclass = sclass->next) { char *val = schema_class_to_extendedInfo(msg, sclass); if (!val) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = ldb_msg_add_string(msg, "extendedClassInfo", val); @@ -454,16 +449,14 @@ static int schema_data_search(struct ldb_module *module, struct ldb_request *req search_context = talloc(req, struct schema_data_search_data); if (!search_context) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } search_context->module = module; search_context->req = req; search_context->schema = talloc_reference(search_context, schema); if (!search_context->schema) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = ldb_build_search_req_ex(&down_req, ldb, search_context, @@ -475,7 +468,7 @@ static int schema_data_search(struct ldb_module *module, struct ldb_request *req search_context, schema_data_search_callback, req); if (ret != LDB_SUCCESS) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } return ldb_next_request(module, down_req); diff --git a/source4/dsdb/samdb/ldb_modules/schema_load.c b/source4/dsdb/samdb/ldb_modules/schema_load.c index 30aafdb65e..dc3b0604e9 100644 --- a/source4/dsdb/samdb/ldb_modules/schema_load.c +++ b/source4/dsdb/samdb/ldb_modules/schema_load.c @@ -161,8 +161,7 @@ static int dsdb_schema_from_db(struct ldb_module *module, struct ldb_dn *schema_ tmp_ctx = talloc_new(module); if (!tmp_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } /* we don't want to trace the schema load */ @@ -270,8 +269,7 @@ static int schema_load_init(struct ldb_module *module) private_data = talloc_zero(module, struct schema_load_private_data); if (private_data == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ldb_module_set_private(module, private_data); diff --git a/source4/dsdb/samdb/ldb_modules/show_deleted.c b/source4/dsdb/samdb/ldb_modules/show_deleted.c index 93463ae95f..c189115599 100644 --- a/source4/dsdb/samdb/ldb_modules/show_deleted.c +++ b/source4/dsdb/samdb/ldb_modules/show_deleted.c @@ -53,23 +53,20 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re in-situ */ new_tree = talloc(req, struct ldb_parse_tree); if (!new_tree) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } new_tree->operation = LDB_OP_AND; new_tree->u.list.num_elements = 2; new_tree->u.list.elements = talloc_array(new_tree, struct ldb_parse_tree *, 2); if (!new_tree->u.list.elements) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } new_tree->u.list.elements[0] = talloc(new_tree->u.list.elements, struct ldb_parse_tree); new_tree->u.list.elements[0]->operation = LDB_OP_NOT; new_tree->u.list.elements[0]->u.isnot.child = talloc(new_tree->u.list.elements, struct ldb_parse_tree); if (!new_tree->u.list.elements[0]->u.isnot.child) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } new_tree->u.list.elements[0]->u.isnot.child->operation = LDB_OP_EQUALITY; new_tree->u.list.elements[0]->u.isnot.child->u.equality.attr = "isDeleted"; @@ -109,7 +106,7 @@ static int show_deleted_init(struct ldb_module *module) if (ret != LDB_SUCCESS) { ldb_debug(ldb, LDB_DEBUG_ERROR, "show_deleted: Unable to register control with rootdse!\n"); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } return ldb_next_init(module); diff --git a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c index 1bf72d9710..4ba1b76fb8 100644 --- a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c +++ b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c @@ -878,12 +878,12 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque ext = talloc_zero(req, struct ldb_extended); if (!ext) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } seqr = talloc_zero(req, struct ldb_seqnum_result); if (seqr == NULL) { talloc_free(ext); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ext->oid = LDB_EXTENDED_SEQUENCE_NUMBER; ext->data = seqr; diff --git a/source4/dsdb/samdb/ldb_modules/subtree_delete.c b/source4/dsdb/samdb/ldb_modules/subtree_delete.c index b677c29ddd..9177744fe9 100644 --- a/source4/dsdb/samdb/ldb_modules/subtree_delete.c +++ b/source4/dsdb/samdb/ldb_modules/subtree_delete.c @@ -101,7 +101,7 @@ static int subtree_delete_init(struct ldb_module *module) if (ret != LDB_SUCCESS) { ldb_debug(ldb, LDB_DEBUG_ERROR, "subtree_delete: Unable to register control with rootdse!\n"); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } return ldb_next_init(module); diff --git a/source4/dsdb/samdb/ldb_modules/subtree_rename.c b/source4/dsdb/samdb/ldb_modules/subtree_rename.c index ed2b024754..6d79db1fb0 100644 --- a/source4/dsdb/samdb/ldb_modules/subtree_rename.c +++ b/source4/dsdb/samdb/ldb_modules/subtree_rename.c @@ -122,7 +122,7 @@ static int subtree_rename_next_request(struct subtree_rename_context *ac) ldb = ldb_module_get_ctx(ac->module); if (ac->current == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ret = ldb_build_rename_req(&req, ldb, ac->current, @@ -241,13 +241,13 @@ static int subtree_rename(struct ldb_module *module, struct ldb_request *req) ac = subren_ctx_init(module, req); if (!ac) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } /* add this entry as the first to do */ ac->current = talloc_zero(ac, struct subren_msg_store); if (ac->current == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ac->current->olddn = req->op.rename.olddn; ac->current->newdn = req->op.rename.newdn; diff --git a/source4/dsdb/samdb/ldb_modules/update_keytab.c b/source4/dsdb/samdb/ldb_modules/update_keytab.c index 620c047cd1..071974f5e4 100644 --- a/source4/dsdb/samdb/ldb_modules/update_keytab.c +++ b/source4/dsdb/samdb/ldb_modules/update_keytab.c @@ -90,8 +90,7 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool do_de filter = talloc_asprintf(data, "(&(dn=%s)(&(objectClass=kerberosSecret)(privateKeytab=*)))", ldb_dn_get_linearized(dn)); if (!filter) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = ldb_search(ldb, data, &res, @@ -112,16 +111,14 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool do_de item = talloc(data->changed_dns? (void *)data->changed_dns: (void *)data, struct dn_list); if (!item) { talloc_free(filter); - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } item->creds = cli_credentials_init(item); if (!item->creds) { DEBUG(1, ("cli_credentials_init failed!")); talloc_free(filter); - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } cli_credentials_set_conf(item->creds, ldb_get_opaque(ldb, "loadparm")); @@ -287,7 +284,7 @@ static int update_kt_add(struct ldb_module *module, struct ldb_request *req) ac = update_kt_ctx_init(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ac->dn = req->op.add.message->dn; @@ -316,7 +313,7 @@ static int update_kt_modify(struct ldb_module *module, struct ldb_request *req) ac = update_kt_ctx_init(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ac->dn = req->op.mod.message->dn; @@ -340,7 +337,7 @@ static int update_kt_delete(struct ldb_module *module, struct ldb_request *req) ac = update_kt_ctx_init(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } ac->dn = req->op.del.dn; @@ -361,7 +358,7 @@ static int update_kt_rename(struct ldb_module *module, struct ldb_request *req) ac = update_kt_ctx_init(module, req); if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ac->dn = req->op.rename.newdn; @@ -425,8 +422,7 @@ static int update_kt_init(struct ldb_module *module) data = talloc(module, struct update_kt_private); if (data == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } data->changed_dns = NULL; diff --git a/source4/dsdb/samdb/ldb_modules/util.c b/source4/dsdb/samdb/ldb_modules/util.c index 48e195bc21..639b0dfae7 100644 --- a/source4/dsdb/samdb/ldb_modules/util.c +++ b/source4/dsdb/samdb/ldb_modules/util.c @@ -48,7 +48,7 @@ int dsdb_module_search_dn(struct ldb_module *module, res = talloc_zero(tmp_ctx, struct ldb_result); if (!res) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } ret = ldb_build_search_req(&req, ldb_module_get_ctx(module), tmp_ctx, @@ -121,7 +121,7 @@ int dsdb_module_search(struct ldb_module *module, if (!expression) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } } else { expression = NULL; @@ -130,7 +130,7 @@ int dsdb_module_search(struct ldb_module *module, res = talloc_zero(tmp_ctx, struct ldb_result); if (!res) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } ret = ldb_build_search_req(&req, ldb_module_get_ctx(module), tmp_ctx, @@ -237,7 +237,7 @@ int dsdb_module_guid_by_dn(struct ldb_module *module, struct ldb_dn *dn, struct status = dsdb_get_extended_dn_guid(res->msgs[0]->dn, guid, "GUID"); if (!NT_STATUS_IS_OK(status)) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } talloc_free(tmp_ctx); @@ -261,7 +261,7 @@ int dsdb_module_modify(struct ldb_module *module, res = talloc_zero(tmp_ctx, struct ldb_result); if (!res) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } ret = ldb_build_mod_req(&mod_req, ldb, tmp_ctx, @@ -318,7 +318,7 @@ int dsdb_module_rename(struct ldb_module *module, res = talloc_zero(tmp_ctx, struct ldb_result); if (!res) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } ret = ldb_build_rename_req(&req, ldb, tmp_ctx, @@ -374,7 +374,7 @@ int dsdb_module_add(struct ldb_module *module, res = talloc_zero(tmp_ctx, struct ldb_result); if (!res) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb_module_get_ctx(module)); } ret = ldb_build_add_req(&req, ldb, tmp_ctx, @@ -429,7 +429,7 @@ int dsdb_module_del(struct ldb_module *module, res = talloc_zero(tmp_ctx, struct ldb_result); if (!res) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = ldb_build_del_req(&req, ldb, tmp_ctx, @@ -648,9 +648,8 @@ int dsdb_module_constrainted_update_integer(struct ldb_module *module, struct ld el->values = &v1; vstring = talloc_asprintf(msg, "%llu", (unsigned long long)old_val); if (!vstring) { - ldb_module_oom(module); talloc_free(msg); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } v1 = data_blob_string_const(vstring); @@ -663,9 +662,8 @@ int dsdb_module_constrainted_update_integer(struct ldb_module *module, struct ld el->values = &v2; vstring = talloc_asprintf(msg, "%llu", (unsigned long long)new_val); if (!vstring) { - ldb_module_oom(module); talloc_free(msg); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } v2 = data_blob_string_const(vstring); @@ -727,7 +725,7 @@ int dsdb_module_load_partition_usn(struct ldb_module *module, struct ldb_dn *dn, res = talloc_zero(tmp_ctx, struct ldb_result); if (!res) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } ret = ldb_build_search_req(&req, ldb, tmp_ctx, @@ -745,7 +743,7 @@ int dsdb_module_load_partition_usn(struct ldb_module *module, struct ldb_dn *dn, p_ctrl = talloc(req, struct dsdb_control_current_partition); if (p_ctrl == NULL) { talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } p_ctrl->version = DSDB_CONTROL_CURRENT_PARTITION_VERSION; p_ctrl->dn = dn; @@ -812,19 +810,19 @@ int dsdb_module_save_partition_usn(struct ldb_module *module, struct ldb_dn *dn, msg = ldb_msg_new(module); if (msg == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } msg->dn = ldb_dn_new(msg, ldb, "@REPLCHANGED"); if (msg->dn == NULL) { talloc_free(msg); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb_module_get_ctx(module)); } res = talloc_zero(msg, struct ldb_result); if (!res) { talloc_free(msg); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } ret = ldb_msg_add_fmt(msg, "uSNHighest", "%llu", (unsigned long long)uSN); @@ -848,7 +846,7 @@ int dsdb_module_save_partition_usn(struct ldb_module *module, struct ldb_dn *dn, p_ctrl = talloc(msg, struct dsdb_control_current_partition); if (p_ctrl == NULL) { talloc_free(msg); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } p_ctrl->version = DSDB_CONTROL_CURRENT_PARTITION_VERSION; p_ctrl->dn = dn; diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index bb22df18bb..7bcdf858dd 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -426,13 +426,12 @@ static int dsdb_schema_setup_ldb_schema_attribute(struct ldb_context *ldb, } if (s == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } attr->ldb_schema_attribute = a = talloc(attr, struct ldb_schema_attribute); if (attr->ldb_schema_attribute == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } a->name = attr->lDAPDisplayName; @@ -731,7 +730,7 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, schema = dsdb_new_schema(mem_ctx); if (!schema) { dsdb_oom(error_string, mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } schema->base_dn = talloc_steal(schema, schema_res->msgs[0]->dn); @@ -751,7 +750,7 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, "schema_fsmo_init: dsdb_schema_info_blob_new() failed - %s", win_errstr(status)); DEBUG(0,(__location__ ": %s\n", *error_string)); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } info_val = &info_val_default; } diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index 1dcb4f89d5..5d63670621 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -65,7 +65,7 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem mem_ctx = talloc_new(ldb); if (!mem_ctx) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } msg = ldb_msg_new(mem_ctx); @@ -182,7 +182,7 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem op_error: talloc_free(mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } static int uint32_cmp(uint32_t c1, uint32_t c2) @@ -339,8 +339,7 @@ static int dsdb_setup_sorted_accessors(struct ldb_context *ldb, failed: dsdb_sorted_accessors_free(schema); - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } int dsdb_setup_schema_inversion(struct ldb_context *ldb, struct dsdb_schema *schema) @@ -433,7 +432,7 @@ int dsdb_reference_schema(struct ldb_context *ldb, struct dsdb_schema *schema, talloc_unlink(ldb, old_schema); if (talloc_reference(ldb, schema) == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } ret = dsdb_schema_set_attributes(ldb, schema, write_attributes); @@ -464,7 +463,7 @@ int dsdb_set_global_schema(struct ldb_context *ldb) if (ret == LDB_SUCCESS) { /* Keep a reference to this schema, just incase the original copy is replaced */ if (talloc_reference(ldb, global_schema) == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_oom(ldb); } } @@ -580,7 +579,7 @@ int dsdb_schema_fill_extended_dn(struct ldb_context *ldb, struct dsdb_schema *sc status = GUID_to_ndr_blob(&target_class->objectGUID, dn, &guid); if (!NT_STATUS_IS_OK(status)) { talloc_free(dn); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_operr(ldb); } ldb_dn_set_extended_component(dn, "GUID", &guid); |