summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-08-14 02:50:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:15:33 -0500
commita993f53d525799df410bab1061fdb28f52379b3c (patch)
tree3e5f6d8419301e7880975ac604676216a3f048ad
parent0cc8a1780df94cdec90942b1cbf5d4059627bf8e (diff)
downloadsamba-a993f53d525799df410bab1061fdb28f52379b3c.tar.gz
samba-a993f53d525799df410bab1061fdb28f52379b3c.tar.bz2
samba-a993f53d525799df410bab1061fdb28f52379b3c.zip
r17529: Simo doesn't like the use of the internal ldb_errstring in functions
not used purely as ldb module helper functions. This now passes these strings back as explicit parameters. Andrew Bartlett (This used to be commit 9c1cd9c2c6bcd9d056a7c9caafacdd573562ebbc)
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c36
-rw-r--r--source4/dsdb/samdb/samdb.c14
-rw-r--r--source4/rpc_server/lsa/dcesrv_lsa.c7
3 files changed, 41 insertions, 16 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index 67724d56b5..e9ddb7cad7 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -435,6 +435,7 @@ static int samldb_fill_group_object(struct ldb_module *module, const struct ldb_
struct ldb_message *msg2;
struct ldb_dn_component *rdn;
TALLOC_CTX *mem_ctx = talloc_new(msg);
+ char *errstr;
if (!mem_ctx) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -447,8 +448,11 @@ static int samldb_fill_group_object(struct ldb_module *module, const struct ldb_
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = samdb_copy_template(module->ldb, msg2, "(&(CN=TemplateGroup)(objectclass=groupTemplate))");
+ ret = samdb_copy_template(module->ldb, msg2,
+ "(&(CN=TemplateGroup)(objectclass=groupTemplate))",
+ &errstr);
if (ret != 0) {
+
talloc_free(mem_ctx);
return ret;
}
@@ -494,6 +498,7 @@ static int samldb_fill_user_or_computer_object(struct ldb_module *module, const
struct ldb_message *msg2;
struct ldb_dn_component *rdn;
TALLOC_CTX *mem_ctx = talloc_new(msg);
+ char *errstr;
if (!mem_ctx) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -508,9 +513,14 @@ static int samldb_fill_user_or_computer_object(struct ldb_module *module, const
if (samdb_find_attribute(module->ldb, msg, "objectclass", "computer") != NULL) {
- ret = samdb_copy_template(module->ldb, msg2, "(&(CN=TemplateComputer)(objectclass=userTemplate))");
+ ret = samdb_copy_template(module->ldb, msg2,
+ "(&(CN=TemplateComputer)(objectclass=userTemplate))",
+ &errstr);
if (ret) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "samldb_fill_user_or_computer_object: Error copying computer template!\n");
+ ldb_asprintf_errstring(module->ldb,
+ "samldb_fill_user_or_computer_object: "
+ "Error copying computer template: %s",
+ errstr);
talloc_free(mem_ctx);
return ret;
}
@@ -528,9 +538,13 @@ static int samldb_fill_user_or_computer_object(struct ldb_module *module, const
}
} else {
- ret = samdb_copy_template(module->ldb, msg2, "(&(CN=TemplateUser)(objectclass=userTemplate))");
+ ret = samdb_copy_template(module->ldb, msg2,
+ "(&(CN=TemplateUser)(objectclass=userTemplate))",
+ &errstr);
if (ret) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "samldb_fill_user_or_computer_object: Error copying user template!\n");
+ ldb_asprintf_errstring(module->ldb,
+ "samldb_fill_user_or_computer_object: Error copying user template: %s\n",
+ errstr);
talloc_free(mem_ctx);
return ret;
}
@@ -581,7 +595,7 @@ static int samldb_fill_user_or_computer_object(struct ldb_module *module, const
}
static int samldb_fill_foreignSecurityPrincipal_object(struct ldb_module *module, const struct ldb_message *msg,
- struct ldb_message **ret_msg)
+ struct ldb_message **ret_msg)
{
struct ldb_message *msg2;
struct ldb_dn_component *rdn;
@@ -589,6 +603,7 @@ static int samldb_fill_foreignSecurityPrincipal_object(struct ldb_module *module
struct dom_sid *sid;
const char *dom_attrs[] = { "name", NULL };
struct ldb_message **dom_msgs;
+ char *errstr;
int ret;
TALLOC_CTX *mem_ctx = talloc_new(msg);
@@ -604,9 +619,14 @@ static int samldb_fill_foreignSecurityPrincipal_object(struct ldb_module *module
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = samdb_copy_template(module->ldb, msg2, "(&(CN=TemplateForeignSecurityPrincipal)(objectclass=foreignSecurityPrincipalTemplate))");
+ ret = samdb_copy_template(module->ldb, msg2,
+ "(&(CN=TemplateForeignSecurityPrincipal)(objectclass=foreignSecurityPrincipalTemplate))",
+ &errstr);
if (ret != 0) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "samldb_fill_foreignSecurityPrincipal_object: Error copying template!\n");
+ ldb_asprintf_errstring(module->ldb,
+ "samldb_fill_foreignSecurityPrincipal_object: "
+ "Error copying template: %s",
+ errstr);
talloc_free(mem_ctx);
return ret;
}
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c
index a659c66725..81b5afb2ee 100644
--- a/source4/dsdb/samdb/samdb.c
+++ b/source4/dsdb/samdb/samdb.c
@@ -674,11 +674,14 @@ int samdb_find_or_add_attribute(struct ldb_context *ldb, struct ldb_message *msg
copy from a template record to a message
*/
int samdb_copy_template(struct ldb_context *ldb,
- struct ldb_message *msg, const char *filter)
+ struct ldb_message *msg, const char *filter,
+ char **errstring)
{
struct ldb_result *res;
struct ldb_message *t;
int ret, i, j;
+
+ *errstring = NULL;
struct ldb_dn *basedn = ldb_dn_explode(ldb, "cn=Templates");
@@ -686,11 +689,12 @@ int samdb_copy_template(struct ldb_context *ldb,
ret = ldb_search(ldb, basedn, LDB_SCOPE_SUBTREE, filter, NULL, &res);
talloc_free(basedn);
if (ret != LDB_SUCCESS) {
+ *errstring = talloc_steal(msg, ldb_errstring(ldb));
return ret;
}
if (res->count != 1) {
- DEBUG(1, ("samdb_copy_template: ERROR: template '%s' matched %d records, expected 1\n", filter,
- res->count));
+ *errstring = talloc_asprintf(msg, "samdb_copy_template: ERROR: template '%s' matched %d records, expected 1\n", filter,
+ res->count);
talloc_free(res);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -719,7 +723,7 @@ int samdb_copy_template(struct ldb_context *ldb,
ret = samdb_find_or_add_value(ldb, msg, el->name,
(char *)el->values[j].data);
if (ret) {
- DEBUG(1, ( "Adding objectClass %s failed.\n", el->values[j].data));
+ *errstring = talloc_asprintf(msg, "Adding objectClass %s failed.\n", el->values[j].data);
talloc_free(res);
return ret;
}
@@ -727,7 +731,7 @@ int samdb_copy_template(struct ldb_context *ldb,
ret = samdb_find_or_add_attribute(ldb, msg, el->name,
(char *)el->values[j].data);
if (ret) {
- DEBUG(1, ("Adding attribute %s failed.\n", el->name));
+ *errstring = talloc_asprintf(msg, "Adding attribute %s failed.\n", el->name);
talloc_free(res);
return ret;
}
diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c
index 000f4fd810..fd394b2f05 100644
--- a/source4/rpc_server/lsa/dcesrv_lsa.c
+++ b/source4/rpc_server/lsa/dcesrv_lsa.c
@@ -1769,6 +1769,7 @@ static NTSTATUS lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX
struct lsa_secret_state *secret_state;
struct dcesrv_handle *handle;
struct ldb_message **msgs, *msg;
+ char *errstr;
const char *attrs[] = {
NULL
};
@@ -1861,10 +1862,10 @@ static NTSTATUS lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX
/* pull in all the template attributes. Note this is always from the global samdb */
ret = samdb_copy_template(secret_state->policy->sam_ldb, msg,
- "(&(cn=TemplateSecret)(objectclass=secretTemplate))");
+ "(&(cn=TemplateSecret)(objectclass=secretTemplate))", &errstr);
if (ret != 0) {
- DEBUG(0,("Failed to load TemplateSecret from samdb: %s\n",
- ldb_errstring(secret_state->policy->sam_ldb)));
+ DEBUG(0,("Failed to load TemplateSecret from samdb: %s\n",
+ errstr));
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}