summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-04-08 08:27:07 +0300
committerKamen Mazdrashki <kamenim@samba.org>2010-04-09 12:21:33 +0300
commitfbef33fb7369f57e6851d3766f87c953ca2d26bd (patch)
tree1b4e78bad78e959f96919c48b428172b5f1c3fbc
parent2763a4ac4e8c93701e00a3baa9fb2dfa24b776f4 (diff)
downloadsamba-fbef33fb7369f57e6851d3766f87c953ca2d26bd.tar.gz
samba-fbef33fb7369f57e6851d3766f87c953ca2d26bd.tar.bz2
samba-fbef33fb7369f57e6851d3766f87c953ca2d26bd.zip
s4/dsdb: Let caller to control if valid invocationId is critical or zero-guid is acceptable
-rw-r--r--source4/dsdb/schema/schema_info_attr.c7
-rw-r--r--source4/dsdb/schema/schema_init.c2
-rw-r--r--source4/dsdb/schema/schema_set.c2
-rw-r--r--source4/torture/drs/unit/schemainfo_tests.c2
4 files changed, 9 insertions, 4 deletions
diff --git a/source4/dsdb/schema/schema_info_attr.c b/source4/dsdb/schema/schema_info_attr.c
index 2d3dfc827c..21ffb1d79f 100644
--- a/source4/dsdb/schema/schema_info_attr.c
+++ b/source4/dsdb/schema/schema_info_attr.c
@@ -297,14 +297,19 @@ static WERROR dsdb_module_schema_info_write(struct ldb_module *ldb_module,
/**
* Creates new dsdb_schema_info object using
* invocationId from supplied ldb
+ * @param check_invocation_id Error out if invocationId is not yet set
*/
-WERROR dsdb_schema_info_create(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct dsdb_schema_info **_schema_info)
+WERROR dsdb_schema_info_create(struct ldb_context *ldb, bool check_invocation_id,
+ TALLOC_CTX *mem_ctx, struct dsdb_schema_info **_schema_info)
{
const struct GUID *invocation_id;
struct dsdb_schema_info *schema_info;
/* try to determine invocationId from ldb */
invocation_id = samdb_ntds_invocation_id(ldb);
+ if (check_invocation_id && !invocation_id) {
+ return WERR_INTERNAL_DB_CORRUPTION;
+ }
schema_info = talloc(mem_ctx, struct dsdb_schema_info);
if (!schema_info) {
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index 1f2b1b8e17..eb3400cedc 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -736,7 +736,7 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
if (!info_val) {
struct dsdb_schema_info *schema_info;
- status = dsdb_schema_info_create(ldb, mem_ctx, &schema_info);
+ status = dsdb_schema_info_create(ldb, false, mem_ctx, &schema_info);
if (!W_ERROR_IS_OK(status)) {
*error_string = talloc_asprintf(mem_ctx,
"schema_fsmo_init: dsdb_schema_info_create() failed - %s",
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c
index 9dcf2b8d42..f0c3c068cd 100644
--- a/source4/dsdb/schema/schema_set.c
+++ b/source4/dsdb/schema/schema_set.c
@@ -623,7 +623,7 @@ WERROR dsdb_set_schema_from_ldif(struct ldb_context *ldb, const char *pf, const
info_val = ldb_msg_find_ldb_val(msg, "schemaInfo");
if (!info_val) {
- status = dsdb_schema_info_create(ldb, mem_ctx, &schema_info);
+ status = dsdb_schema_info_create(ldb, false, mem_ctx, &schema_info);
W_ERROR_NOT_OK_GOTO(status, failed);
status = dsdb_blob_from_schema_info(schema_info, mem_ctx, &info_val_default);
W_ERROR_NOT_OK_GOTO(status, failed);
diff --git a/source4/torture/drs/unit/schemainfo_tests.c b/source4/torture/drs/unit/schemainfo_tests.c
index ab9de87f22..7928855fb3 100644
--- a/source4/torture/drs/unit/schemainfo_tests.c
+++ b/source4/torture/drs/unit/schemainfo_tests.c
@@ -348,7 +348,7 @@ static bool test_dsdb_schema_info_create(struct torture_context *tctx,
WERROR werr;
struct dsdb_schema_info *schema_info = NULL;
- werr = dsdb_schema_info_create(priv->ldb, priv, &schema_info);
+ werr = dsdb_schema_info_create(priv->ldb, true, priv, &schema_info);
torture_assert_werr_ok(tctx, werr, "dsdb_schema_info_create() failed");
torture_assert(tctx, schema_info, "schema_info is NULL after dsdb_schema_info_create()");