Merge commit 'origin/v4-0-test' into 4-0-local
authorAndrew Bartlett <abartlet@samba.org>
Fri, 18 Jan 2008 06:05:17 +0000 (17:05 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 18 Jan 2008 06:05:17 +0000 (17:05 +1100)
(This used to be commit 51422414bed28f425197519298c6b04a9f4e2c4e)

32 files changed:
source4/dsdb/samdb/ldb_modules/simple_ldap_map.c
source4/lib/registry/dir.c
source4/lib/registry/hive.c
source4/lib/registry/ldb.c
source4/lib/registry/local.c
source4/lib/registry/patchfile.c
source4/lib/registry/regf.c
source4/lib/registry/samba.c
source4/lib/registry/tests/hive.c
source4/lib/registry/tests/registry.c
source4/lib/tdb/common/freelist.c
source4/lib/tdb/common/open.c
source4/lib/tdb/common/tdb.c
source4/lib/tdb/common/tdb_private.h
source4/lib/tdb/common/transaction.c
source4/lib/tdb/common/traverse.c
source4/lib/tdb/docs/README
source4/lib/tdb/include/tdb.h
source4/lib/tdb/tools/tdbtool.c
source4/scripting/python/samba/provision.py
source4/setup/display_specifiers.ldif
source4/setup/provision.ldif
source4/setup/provision.py
source4/setup/provision_computers_modify.ldif
source4/setup/provision_configuration.ldif
source4/setup/provision_configuration_basedn_modify.ldif
source4/setup/provision_schema_basedn_modify.ldif
source4/setup/provision_self_join.ldif
source4/setup/provision_templates.ldif
source4/setup/provision_users.ldif
source4/setup/provision_users_modify.ldif
source4/setup/slapd.conf

index 6e66d0783a76d7fd92e1455a8b663ffb35e44a7f..acf2fd622cc29ddb04134ec055d5dba6e5d53b99 100644 (file)
@@ -448,6 +448,7 @@ static const char * const entryuuid_wildcard_attributes[] = {
        "whenChanged",
        "usnCreated",
        "usnChanged",
+       "memberOf",
        NULL
 };
 
index a13e3753b7f0bac4010c0f351d6b76efdccd7a83..27cae8c49062ed9ba1ba670f47f3bc594b422763 100644 (file)
@@ -64,7 +64,7 @@ static WERROR reg_dir_del_key(const struct hive_key *k, const char *name)
        if (rmdir(child) == 0)
                ret = WERR_OK;
        else if (errno == ENOENT)
-               ret = WERR_NOT_FOUND;
+               ret = WERR_BADFILE;
        else
                ret = WERR_GENERAL_FAILURE;
 
@@ -282,7 +282,7 @@ static WERROR reg_dir_get_value(TALLOC_CTX *mem_ctx,
        contents = file_load(path, &size, mem_ctx);
        talloc_free(path);
        if (contents == NULL)
-               return WERR_NOT_FOUND;
+               return WERR_BADFILE;
 
        if (type != NULL)
                *type = 4; /* FIXME */
@@ -339,7 +339,7 @@ static WERROR reg_dir_del_value (struct hive_key *key, const char *name)
        if (unlink(path) < 0) {
                talloc_free(path);
                if (errno == ENOENT)
-                       return WERR_NOT_FOUND;
+                       return WERR_BADFILE;
                return WERR_GENERAL_FAILURE;
        }
        talloc_free(path);
index bbe510772cc9a714e90b631ef81229f261fc5ce7..5d56a30b3e14edaacfcaf4c80801cae9adaca9df 100644 (file)
@@ -41,7 +41,7 @@ _PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
        fd = open(location, O_RDWR);
        if (fd == -1) {
                if (errno == ENOENT)
-                       return WERR_NOT_FOUND;
+                       return WERR_BADFILE;
                return WERR_BADFILE;
        }
 
index 259315cc3955d93f87e776b9b8433084642c0af6..262859f64b4302395d04cf41f0d0e47b27a4cde1 100644 (file)
@@ -111,6 +111,15 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
        return msg;
 }
 
+static char *reg_ldb_escape(TALLOC_CTX *mem_ctx, const char *value)
+{
+       struct ldb_val val;
+
+       val.data = discard_const_p(uint8_t, value);
+       val.length = strlen(value);
+
+       return ldb_dn_escape_value(mem_ctx, val);
+}
 
 static int reg_close_ldb_key(struct ldb_key_data *key)
 {
@@ -159,7 +168,13 @@ static struct ldb_dn *reg_path_to_ldb(TALLOC_CTX *mem_ctx,
                else keyname = mypath;
 
                if(strlen(keyname)) {
-                       ldb_dn_add_base_fmt(ret, "key=%s", keyname);
+                       if (!ldb_dn_add_base_fmt(ret, "key=%s",
+                                                reg_ldb_escape(local_ctx,
+                                                               keyname)))
+                       {
+                               talloc_free(local_ctx);
+                               return NULL;
+                       }
                }
 
                if(begin) {
@@ -293,7 +308,7 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
        }
 
        if (res->count == 0)
-               return WERR_NOT_FOUND;
+               return WERR_BADFILE;
 
        reg_ldb_unpack_value(mem_ctx, res->msgs[0], NULL, data_type, data);
 
@@ -322,7 +337,7 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
                DEBUG(3, ("Key '%s' not found\n",
                        ldb_dn_get_linearized(ldap_path)));
                talloc_free(res);
-               return WERR_NOT_FOUND;
+               return WERR_BADFILE;
        }
 
        newkd = talloc_zero(mem_ctx, struct ldb_key_data);
@@ -385,7 +400,7 @@ static WERROR ldb_add_key(TALLOC_CTX *mem_ctx, const struct hive_key *parent,
                          struct security_descriptor *sd,
                          struct hive_key **newkey)
 {
-       const struct ldb_key_data *parentkd = (const struct ldb_key_data *)parent;
+       struct ldb_key_data *parentkd = (const struct ldb_key_data *)parent;
        struct ldb_message *msg;
        struct ldb_key_data *newkd;
        int ret;
@@ -400,8 +415,12 @@ static WERROR ldb_add_key(TALLOC_CTX *mem_ctx, const struct hive_key *parent,
                                   talloc_strdup(mem_ctx, classname));
 
        ret = ldb_add(parentkd->ldb, msg);
-       if (ret < 0) {
-               DEBUG(1, ("ldb_msg_add: %s\n", ldb_errstring(parentkd->ldb)));
+       if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) {
+               return WERR_ALREADY_EXISTS;
+       }
+
+       if (ret != LDB_SUCCESS) {
+               DEBUG(1, ("ldb_add: %s\n", ldb_errstring(parentkd->ldb)));
                return WERR_FOOBAR;
        }
 
@@ -414,29 +433,37 @@ static WERROR ldb_add_key(TALLOC_CTX *mem_ctx, const struct hive_key *parent,
 
        *newkey = (struct hive_key *)newkd;
 
+       /* reset cache */
+       talloc_free(parentkd->subkeys);
+       parentkd->subkeys = NULL;
+
        return WERR_OK;
 }
 
-static WERROR ldb_del_key(const struct hive_key *key, const char *child)
+static WERROR ldb_del_key(const struct hive_key *key, const char *name)
 {
        int ret;
        struct ldb_key_data *parentkd = talloc_get_type(key, struct ldb_key_data);
-       struct ldb_dn *childdn;
+       struct ldb_dn *ldap_path;
+       TALLOC_CTX *mem_ctx = talloc_init("ldb_del_key");
 
-       childdn = ldb_dn_copy(parentkd->ldb, parentkd->dn);
-       ldb_dn_add_child_fmt(childdn, "key=%s", child);
+       ldap_path = reg_path_to_ldb(mem_ctx, key, name, NULL);
 
-       ret = ldb_delete(parentkd->ldb, childdn);
+       ret = ldb_delete(parentkd->ldb, ldap_path);
 
-       talloc_free(childdn);
+       talloc_free(mem_ctx);
 
        if (ret == LDB_ERR_NO_SUCH_OBJECT) {
-               return WERR_NOT_FOUND;
-       } else if (ret < 0) {
+               return WERR_BADFILE;
+       } else if (ret != LDB_SUCCESS) {
                DEBUG(1, ("ldb_del_key: %s\n", ldb_errstring(parentkd->ldb)));
                return WERR_FOOBAR;
        }
 
+       /* reset cache */
+       talloc_free(parentkd->subkeys);
+       parentkd->subkeys = NULL;
+
        return WERR_OK;
 }
 
@@ -447,19 +474,28 @@ static WERROR ldb_del_value (struct hive_key *key, const char *child)
        struct ldb_dn *childdn;
 
        childdn = ldb_dn_copy(kd->ldb, kd->dn);
-       ldb_dn_add_child_fmt(childdn, "value=%s", child);
+       if (!ldb_dn_add_child_fmt(childdn, "value=%s",
+                                 reg_ldb_escape(childdn, child)))
+       {
+               talloc_free(childdn);
+               return WERR_FOOBAR;
+       }
 
        ret = ldb_delete(kd->ldb, childdn);
 
        talloc_free(childdn);
 
        if (ret == LDB_ERR_NO_SUCH_OBJECT) {
-               return WERR_NOT_FOUND;
-       } else if (ret < 0) {
+               return WERR_BADFILE;
+       } else if (ret != LDB_SUCCESS) {
                DEBUG(1, ("ldb_del_value: %s\n", ldb_errstring(kd->ldb)));
                return WERR_FOOBAR;
        }
 
+       /* reset cache */
+       talloc_free(kd->values);
+       kd->values = NULL;
+
        return WERR_OK;
 }
 
@@ -475,18 +511,32 @@ static WERROR ldb_set_value(struct hive_key *parent,
        msg = reg_ldb_pack_value(kd->ldb, mem_ctx, name, type, data);
 
        msg->dn = ldb_dn_copy(msg, kd->dn);
-       ldb_dn_add_child_fmt(msg->dn, "value=%s", name);
+       if (!ldb_dn_add_child_fmt(msg->dn, "value=%s",
+                                 reg_ldb_escape(mem_ctx, name)))
+       {
+               talloc_free(mem_ctx);
+               return WERR_FOOBAR;
+       }
 
        ret = ldb_add(kd->ldb, msg);
-       if (ret < 0) {
-               ret = ldb_modify(kd->ldb, msg);
-               if (ret < 0) {
-                       DEBUG(1, ("ldb_msg_add: %s\n", ldb_errstring(kd->ldb)));
-                       talloc_free(mem_ctx);
-                       return WERR_FOOBAR;
+       if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) {
+               int i;
+               for (i = 0; i < msg->num_elements; i++) {
+                       msg->elements[i].flags = LDB_FLAG_MOD_REPLACE;
                }
+               ret = ldb_modify(kd->ldb, msg);
+       }
+
+       if (ret != LDB_SUCCESS) {
+               DEBUG(1, ("ldb_msg_add: %s\n", ldb_errstring(kd->ldb)));
+               talloc_free(mem_ctx);
+               return WERR_FOOBAR;
        }
 
+       /* reset cache */
+       talloc_free(kd->values);
+       kd->values = NULL;
+
        talloc_free(mem_ctx);
        return WERR_OK;
 }
@@ -503,17 +553,23 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
 {
        struct ldb_key_data *kd = talloc_get_type(key, struct ldb_key_data);
 
+       if (kd->subkeys == NULL) {
+               W_ERROR_NOT_OK_RETURN(cache_subkeys(kd));
+       }
+
+       if (kd->values == NULL) {
+               W_ERROR_NOT_OK_RETURN(cache_values(kd));
+       }
+
        /* FIXME */
        if (classname != NULL)
                *classname = NULL;
 
        if (num_subkeys != NULL) {
-               W_ERROR_NOT_OK_RETURN(cache_subkeys(kd));
                *num_subkeys = kd->subkey_count;
        }
 
        if (num_values != NULL) {
-               W_ERROR_NOT_OK_RETURN(cache_values(kd));
                *num_values = kd->value_count;
        }
 
@@ -523,7 +579,6 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
        if (max_subkeynamelen != NULL) {
                int i;
                struct ldb_message_element *el;
-               W_ERROR_NOT_OK_RETURN(cache_subkeys(kd));
 
                *max_subkeynamelen = 0;
 
index fa59f255966c0154fd870f2f0499efd0dc9d86e6..3e463100c9cb80380f02066cfd3b6a45010f8c91 100644 (file)
@@ -140,7 +140,7 @@ WERROR local_get_predefined_key(struct registry_context *ctx,
        }
 
        if (mp == NULL)
-               return WERR_NOT_FOUND;
+               return WERR_BADFILE;
 
        *key = reg_import_hive_key(ctx, mp->key,
                                   mp->path.predefined_key,
index b6ad7dfb1099c72eed4ccdbcd20f8ee80547e7f4..fa1367bbd2cd38f37a8c359e254ec6e84d747269 100644 (file)
@@ -82,11 +82,11 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
                        if (W_ERROR_IS_OK(error2))
                                continue;
                } else {
-                       error2 = WERR_DEST_NOT_FOUND;
+                       error2 = WERR_BADFILE;
                        t2 = NULL;
                }
 
-               if (!W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) {
+               if (!W_ERROR_EQUAL(error2, WERR_BADFILE)) {
                        DEBUG(0, ("Error occured while getting subkey by name: %s\n",
                                win_errstr(error2)));
                        talloc_free(mem_ctx);
@@ -132,10 +132,10 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
                                continue;
                } else {
                        t1 = NULL;
-                       error2 = WERR_DEST_NOT_FOUND;
+                       error2 = WERR_BADFILE;
                }
 
-               if (!W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) {
+               if (!W_ERROR_EQUAL(error2, WERR_BADFILE)) {
                        DEBUG(0, ("Error occured while getting subkey by name: %s\n",
                                win_errstr(error2)));
                        talloc_free(mem_ctx);
@@ -174,10 +174,10 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
                                                           name, &type2,
                                                           &contents2);
                } else
-                       error2 = WERR_DEST_NOT_FOUND;
+                       error2 = WERR_BADFILE;
 
                if(!W_ERROR_IS_OK(error2) &&
-                  !W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) {
+                  !W_ERROR_EQUAL(error2, WERR_BADFILE)) {
                        DEBUG(0, ("Error occured while getting value by name: %s\n",
                                win_errstr(error2)));
                        talloc_free(mem_ctx);
@@ -210,7 +210,7 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
                if (W_ERROR_IS_OK(error2))
                        continue;
 
-               if (!W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) {
+               if (!W_ERROR_EQUAL(error2, WERR_BADFILE)) {
                        DEBUG(0, ("Error occured while getting value by name: %s\n",
                                win_errstr(error2)));
                        return error2;
@@ -238,14 +238,14 @@ _PUBLIC_ WERROR reg_generate_diff(struct registry_context *ctx1,
                struct registry_key *r1 = NULL, *r2 = NULL;
                error = reg_get_predefined_key(ctx1, i, &r1);
                if (!W_ERROR_IS_OK(error) &&
-                   !W_ERROR_EQUAL(error, WERR_NOT_FOUND)) {
+                   !W_ERROR_EQUAL(error, WERR_BADFILE)) {
                        DEBUG(0, ("Unable to open hive %s for backend 1\n",
                                reg_get_predef_name(i)));
                }
 
                error = reg_get_predefined_key(ctx2, i, &r2);
                if (!W_ERROR_IS_OK(error) &&
-                   !W_ERROR_EQUAL(error, WERR_NOT_FOUND)) {
+                   !W_ERROR_EQUAL(error, WERR_BADFILE)) {
                        DEBUG(0, ("Unable to open hive %s for backend 2\n",
                                reg_get_predef_name(i)));
                }
@@ -356,7 +356,7 @@ static WERROR reg_diff_apply_set_value(void *_ctx, const char *path,
        /* Open key */
        error = reg_open_key_abs(ctx, ctx, path, &tmp);
 
-       if (W_ERROR_EQUAL(error, WERR_DEST_NOT_FOUND)) {
+       if (W_ERROR_EQUAL(error, WERR_BADFILE)) {
                DEBUG(0, ("Error opening key '%s'\n", path));
                return error;
        }
index 9b126cc8084fe4d08748c6ce000ee5138dd3e224..15b60745f05612dea2b5d9ebdd06b6d161743d03 100644 (file)
@@ -575,7 +575,7 @@ static WERROR regf_get_value_by_name(TALLOC_CTX *mem_ctx,
        }
 
        if (W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS))
-               return WERR_NOT_FOUND;
+               return WERR_BADFILE;
 
        return error;
 }
@@ -870,7 +870,7 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
                                break;
                }
                if (key_off == 0)
-                       return WERR_NOT_FOUND;
+                       return WERR_BADFILE;
        } else if (!strncmp((char *)data.data, "lf", 2)) {
                struct lf_block lf;
                struct tdr_pull *pull = tdr_pull_init(ctx, private_data->hive->iconv_convenience);
@@ -905,7 +905,7 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
                                break;
                }
                if (key_off == 0)
-                       return WERR_NOT_FOUND;
+                       return WERR_BADFILE;
        } else if (!strncmp((char *)data.data, "lh", 2)) {
                struct lh_block lh;
                struct tdr_pull *pull = tdr_pull_init(ctx, private_data->hive->iconv_convenience);
@@ -942,7 +942,7 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
                                break;
                }
                if (key_off == 0)
-                       return WERR_NOT_FOUND;
+                       return WERR_BADFILE;
        } else if (!strncmp((char *)data.data, "ri", 2)) {
                struct ri_block ri;
                struct tdr_pull *pull = tdr_pull_init(ctx, private_data->hive->iconv_convenience);
@@ -1022,7 +1022,7 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
                }
                talloc_free(pull);
                if (!key_off)
-                       return WERR_NOT_FOUND;
+                       return WERR_BADFILE;
        } else {
                DEBUG(0, ("Unknown subkey list type.\n"));
                return WERR_GENERAL_FAILURE;
@@ -1419,7 +1419,7 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
                }
                if (!found_offset) {
                        DEBUG(2, ("Subkey not found\n"));
-                       return WERR_NOT_FOUND;
+                       return WERR_BADFILE;
                }
                li.key_count--;
 
@@ -1464,7 +1464,7 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
                }
                if (!found_offset) {
                        DEBUG(2, ("Subkey not found\n"));
-                       return WERR_NOT_FOUND;
+                       return WERR_BADFILE;
                }
                lf.key_count--;
 
@@ -1510,7 +1510,7 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
                }
                if (!found_offset) {
                        DEBUG(0, ("Subkey not found\n"));
-                       return WERR_NOT_FOUND;
+                       return WERR_BADFILE;
                }
                lh.key_count--;
 
@@ -1548,7 +1548,7 @@ static WERROR regf_del_value (struct hive_key *key, const char *name)
        uint32_t i;
 
        if (nk->values_offset == -1) {
-               return WERR_NOT_FOUND;
+               return WERR_BADFILE;
        }
 
        values = hbin_get(regf, nk->values_offset);
@@ -1572,7 +1572,7 @@ static WERROR regf_del_value (struct hive_key *key, const char *name)
                }
        }
        if (!found_offset) {
-               return WERR_NOT_FOUND;
+               return WERR_BADFILE;
        } else {
                nk->num_values--;
                values.length = (nk->num_values)*4;
@@ -1608,14 +1608,14 @@ static WERROR regf_del_key(const struct hive_key *parent, const char *name)
 
        if (parent_nk->subkeys_offset == -1) {
                DEBUG(4, ("Subkey list is empty, this key cannot contain subkeys.\n"));
-               return WERR_NOT_FOUND;
+               return WERR_BADFILE;
        }
 
        /* Find the key */
        if (!W_ERROR_IS_OK(regf_get_subkey_by_name(parent_nk, parent, name,
                                                   (struct hive_key **)&key))) {
                DEBUG(2, ("Key '%s' not found\n", name));
-               return WERR_NOT_FOUND;
+               return WERR_BADFILE;
        }
 
        if (key->nk->subkeys_offset != -1 ||
index 02f3363bab97366e806eaf393425c5e1854cb7bf..599385e73c210819a59d539aae946966fe4421ed 100644 (file)
@@ -42,7 +42,7 @@ static WERROR mount_samba_hive(struct registry_context *ctx,
 
        error = reg_open_hive(ctx, location, auth_info, creds, lp_ctx, &hive);
 
-       if (W_ERROR_EQUAL(error, WERR_NOT_FOUND))
+       if (W_ERROR_EQUAL(error, WERR_BADFILE))
                error = reg_open_ldb_file(ctx, location, auth_info,
                                          creds, lp_ctx, &hive);
 
index 22b4785222567f0b71238e32a4204f12e4930bfb..4d27e83a74747375a245906f48b7e369318f5ad4 100644 (file)
@@ -31,7 +31,7 @@ static bool test_del_nonexistant_key(struct torture_context *tctx,
 {
        const struct hive_key *root = (const struct hive_key *)test_data;
        WERROR error = hive_key_del(root, "bla");
-       torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND,
+       torture_assert_werr_equal(tctx, error, WERR_BADFILE,
                                  "invalid return code");
 
        return true;
@@ -134,7 +134,7 @@ static bool test_del_key(struct torture_context *tctx, const void *test_data)
        torture_assert_werr_ok(tctx, error, "reg_key_del");
 
        error = hive_key_del(root, "Nested Key");
-       torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, "reg_key_del");
+       torture_assert_werr_equal(tctx, error, WERR_BADFILE, "reg_key_del");
 
        return true;
 }
@@ -174,7 +174,7 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data)
        torture_assert_werr_ok(tctx, error, "hive_key_add_name");
 
        error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value);
-       torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND,
+       torture_assert_werr_equal(tctx, error, WERR_BADFILE,
                                  "getting missing value");
 
        error = hive_key_set_value(subkey, "Answer", REG_DWORD,
@@ -215,10 +215,10 @@ static bool test_del_value(struct torture_context *tctx, const void *test_data)
        torture_assert_werr_ok(tctx, error, "deleting value");
 
        error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value);
-       torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND, "getting value");
+       torture_assert_werr_equal(tctx, error, WERR_BADFILE, "getting value");
 
        error = hive_key_del_value(subkey, "Answer");
-       torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND,
+       torture_assert_werr_equal(tctx, error, WERR_BADFILE,
                                  "deleting value");
 
        return true;
index 75fbe1cbea8bca48d2815d97b84e5387d132ac17..7d14b3a4121d4c5d5246ed98daf094d537960d2b 100644 (file)
@@ -53,7 +53,7 @@ static bool test_get_predefined_unknown(struct torture_context *tctx,
        WERROR error;
 
        error = reg_get_predefined_key(rctx, 1337, &root);
-       torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND,
+       torture_assert_werr_equal(tctx, error, WERR_BADFILE,
                                  "getting predefined key failed");
        return true;
 }
@@ -195,16 +195,16 @@ static bool test_del_key(struct torture_context *tctx, void *_data)
        torture_assert_werr_ok(tctx, error,
                               "getting predefined key failed");
 
-       error = reg_key_add_name(rctx, root, "Hamburg", NULL, NULL, &newkey);
+       error = reg_key_add_name(rctx, root, "Polen", NULL, NULL, &newkey);
 
        torture_assert_werr_ok(tctx, error, "Creating key return code");
        torture_assert(tctx, newkey != NULL, "Creating new key");
 
-       error = reg_key_del(root, "Hamburg");
+       error = reg_key_del(root, "Polen");
        torture_assert_werr_ok(tctx, error, "Delete key");
 
-       error = reg_key_del(root, "Hamburg");
-       torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND,
+       error = reg_key_del(root, "Polen");
+       torture_assert_werr_equal(tctx, error, WERR_BADFILE,
                                  "Delete missing key");
 
        return true;
@@ -239,7 +239,7 @@ static bool test_flush_key(struct torture_context *tctx, void *_data)
        struct registry_key *root, *subkey;
        WERROR error;
 
-       if (!create_test_key(tctx, rctx, "Munchen", &root, &subkey))
+       if (!create_test_key(tctx, rctx, "Bremen", &root, &subkey))
                return false;
 
        error = reg_key_flush(subkey);
@@ -416,7 +416,7 @@ static bool test_get_value(struct torture_context *tctx, void *_data)
 
        error = reg_key_get_value_by_name(tctx, subkey, __FUNCTION__, &type,
                                          &data);
-       torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND,
+       torture_assert_werr_equal(tctx, error, WERR_BADFILE,
                                  "getting missing value");
 
        error = reg_val_set(subkey, __FUNCTION__, REG_DWORD,
@@ -447,12 +447,12 @@ static bool test_del_value(struct torture_context *tctx, void *_data)
        uint32_t value = 42;
        uint32_t type;
 
-       if (!create_test_key(tctx, rctx, "Duisburg", &root, &subkey))
+       if (!create_test_key(tctx, rctx, "Warschau", &root, &subkey))
                return false;
 
        error = reg_key_get_value_by_name(tctx, subkey, __FUNCTION__, &type,
                                          &data);
-       torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND,
+       torture_assert_werr_equal(tctx, error, WERR_BADFILE,
                                  "getting missing value");
 
        error = reg_val_set(subkey, __FUNCTION__, REG_DWORD,
@@ -464,7 +464,7 @@ static bool test_del_value(struct torture_context *tctx, void *_data)
 
        error = reg_key_get_value_by_name(tctx, subkey, __FUNCTION__,
                                          &type, &data);
-       torture_assert_werr_equal(tctx, error, WERR_NOT_FOUND,
+       torture_assert_werr_equal(tctx, error, WERR_BADFILE,
                                  "getting missing value");
 
        return true;
index c086c151fa686ceafd421c563313a734bf6d279f..2f2a4c379b0690399a9f4065b15960e667300bf0 100644 (file)
@@ -208,62 +208,61 @@ update:
 }
 
 
+
 /* 
    the core of tdb_allocate - called when we have decided which
    free list entry to use
+
+   Note that we try to allocate by grabbing data from the end of an existing record,
+   not the beginning. This is so the left merge in a free is more likely to be
+   able to free up the record without fragmentation
  */
-static tdb_off_t tdb_allocate_ofs(struct tdb_context *tdb, tdb_len_t length, tdb_off_t rec_ptr,
-                               struct list_struct *rec, tdb_off_t last_ptr)
+static tdb_off_t tdb_allocate_ofs(struct tdb_context *tdb, 
+                                 tdb_len_t length, tdb_off_t rec_ptr,
+                                 struct list_struct *rec, tdb_off_t last_ptr)
 {
-       struct list_struct newrec;
-       tdb_off_t newrec_ptr;
+#define MIN_REC_SIZE (sizeof(struct list_struct) + sizeof(tdb_off_t) + 8)
 
-       memset(&newrec, '\0', sizeof(newrec));
+       if (rec->rec_len < length + MIN_REC_SIZE) {
+               /* we have to grab the whole record */
 
-       /* found it - now possibly split it up  */
-       if (rec->rec_len > length + MIN_REC_SIZE) {
-               /* Length of left piece */
-               length = TDB_ALIGN(length, TDB_ALIGNMENT);
-               
-               /* Right piece to go on free list */
-               newrec.rec_len = rec->rec_len - (sizeof(*rec) + length);
-               newrec_ptr = rec_ptr + sizeof(*rec) + length;
-               
-               /* And left record is shortened */
-               rec->rec_len = length;
-       } else {
-               newrec_ptr = 0;
+               /* unlink it from the previous record */
+               if (tdb_ofs_write(tdb, last_ptr, &rec->next) == -1) {
+                       return 0;
+               }
+
+               /* mark it not free */
+               rec->magic = TDB_MAGIC;
+               if (tdb_rec_write(tdb, rec_ptr, rec) == -1) {
+                       return 0;
+               }
+               return rec_ptr;
+       }
+
+       /* we're going to just shorten the existing record */
+       rec->rec_len -= (length + sizeof(*rec));
+       if (tdb_rec_write(tdb, rec_ptr, rec) == -1) {
+               return 0;
        }
-       
-       /* Remove allocated record from the free list */
-       if (tdb_ofs_write(tdb, last_ptr, &rec->next) == -1) {
+       if (update_tailer(tdb, rec_ptr, rec) == -1) {
                return 0;
        }
-       
-       /* Update header: do this before we drop alloc
-          lock, otherwise tdb_free() might try to
-          merge with us, thinking we're free.
-          (Thanks Jeremy Allison). */
+
+       /* and setup the new record */
+       rec_ptr += sizeof(*rec) + rec->rec_len; 
+
+       memset(rec, '\0', sizeof(*rec));
+       rec->rec_len = length;
        rec->magic = TDB_MAGIC;
+
        if (tdb_rec_write(tdb, rec_ptr, rec) == -1) {
                return 0;
        }
-       
-       /* Did we create new block? */
-       if (newrec_ptr) {
-               /* Update allocated record tailer (we
-                  shortened it). */
-               if (update_tailer(tdb, rec_ptr, rec) == -1) {
-                       return 0;
-               }
-               
-               /* Free new record */
-               if (tdb_free(tdb, newrec_ptr, &newrec) == -1) {
-                       return 0;
-               }
+
+       if (update_tailer(tdb, rec_ptr, rec) == -1) {
+               return 0;
        }
-       
-       /* all done - return the new record offset */
+
        return rec_ptr;
 }
 
@@ -287,6 +286,7 @@ tdb_off_t tdb_allocate(struct tdb_context *tdb, tdb_len_t length, struct list_st
 
        /* Extra bytes required for tailer */
        length += sizeof(tdb_off_t);
+       length = TDB_ALIGN(length, TDB_ALIGNMENT);
 
  again:
        last_ptr = FREELIST_TOP;
@@ -343,7 +343,8 @@ tdb_off_t tdb_allocate(struct tdb_context *tdb, tdb_len_t length, struct list_st
                        goto fail;
                }
 
-               newrec_ptr = tdb_allocate_ofs(tdb, length, bestfit.rec_ptr, rec, bestfit.last_ptr);
+               newrec_ptr = tdb_allocate_ofs(tdb, length, bestfit.rec_ptr, 
+                                             rec, bestfit.last_ptr);
                tdb_unlock(tdb, -1, F_WRLCK);
                return newrec_ptr;
        }
index 6bd8fda2bf1a4a5212578bfcc60edcf74bd76f93..b19e4cea293df769a588db89c71df25529d677ec 100644 (file)
@@ -179,9 +179,7 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
                tdb->page_size = 0x2000;
        }
 
-       if (open_flags & TDB_VOLATILE) {
-               tdb->max_dead_records = 5;
-       }
+       tdb->max_dead_records = (tdb_flags & TDB_VOLATILE) ? 5 : 0;
 
        if ((open_flags & O_ACCMODE) == O_WRONLY) {
                TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: can't open tdb %s write-only\n",
@@ -229,6 +227,7 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
 
        /* we need to zero database if we are the only one with it open */
        if ((tdb_flags & TDB_CLEAR_IF_FIRST) &&
+           (!tdb->read_only) &&
            (locked = (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_WRLCK, F_SETLK, 0, 1) == 0))) {
                open_flags |= O_CREAT;
                if (ftruncate(tdb->fd, 0) == -1) {
@@ -288,7 +287,6 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
        tdb->map_size = st.st_size;
        tdb->device = st.st_dev;
        tdb->inode = st.st_ino;
-       tdb->max_dead_records = 0;
        tdb_mmap(tdb);
        if (locked) {
                if (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_UNLCK, F_SETLK, 0, 1) == -1) {
index fd4e1cc8af2d36f6c09c4e9f71a54edd980b37a9..ea5d9ccc6014ff9cd205e42579b48ed1c3390093 100644 (file)
@@ -743,45 +743,3 @@ failed:
        tdb_unlockall(tdb);
        return -1;
 }
-
-
-/* 
-   validate the integrity of all tdb hash chains. Useful when debugging
- */
-int tdb_validate(struct tdb_context *tdb)
-{
-       int h;
-       for (h=-1;h<(int)tdb->header.hash_size;h++) {
-               tdb_off_t rec_ptr;
-               uint32_t count = 0;
-               if (tdb_ofs_read(tdb, TDB_HASH_TOP(h), &rec_ptr) == -1) {
-                       TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_validate: failed ofs_read at top of hash %d\n", h));
-                       return -1;
-               }
-               while (rec_ptr) {
-                       struct list_struct r;
-                       tdb_off_t size;
-
-                       if (tdb_rec_read(tdb, rec_ptr, &r) == -1) {
-                               TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_validate: failed rec_read h=%d rec_ptr=%u count=%u\n",
-                                        h, rec_ptr, count));
-                               return -1;
-                       }
-                       if (tdb_ofs_read(tdb, rec_ptr + sizeof(r) + r.rec_len - sizeof(tdb_off_t), &size) == -1) {
-                               TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_validate: failed ofs_read h=%d rec_ptr=%u count=%u\n",
-                                        h, rec_ptr, count));
-                               return -1;
-                       }
-                       if (size != r.rec_len + sizeof(r)) {
-                               TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_validate: failed size check size=%u h=%d rec_ptr=%u count=%u\n",
-                                        size, h, rec_ptr, count));
-                               return -1;
-                       }
-                       rec_ptr = r.next;
-                       count++;
-               }               
-       }
-       return 0;
-}
-
-
index 63a6d04e72d00db22f8c87c6cf3222963f1d1562..ffac89ff0e315195b3defdebc35184ef7ab6a038 100644 (file)
@@ -49,7 +49,6 @@ typedef uint32_t tdb_off_t;
 #define TDB_DEAD_MAGIC (0xFEE1DEAD)
 #define TDB_RECOVERY_MAGIC (0xf53bc0e7U)
 #define TDB_ALIGNMENT 4
-#define MIN_REC_SIZE (2*sizeof(struct list_struct) + TDB_ALIGNMENT)
 #define DEFAULT_HASH_SIZE 131
 #define FREELIST_TOP (sizeof(struct tdb_header))
 #define TDB_ALIGN(x,a) (((x) + (a)-1) & ~((a)-1))
@@ -178,6 +177,7 @@ struct tdb_context {
 int tdb_munmap(struct tdb_context *tdb);
 void tdb_mmap(struct tdb_context *tdb);
 int tdb_lock(struct tdb_context *tdb, int list, int ltype);
+int tdb_lock_nonblock(struct tdb_context *tdb, int list, int ltype);
 int tdb_unlock(struct tdb_context *tdb, int list, int ltype);
 int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, int rw_type, int lck_type, int probe, size_t len);
 int tdb_transaction_lock(struct tdb_context *tdb, int ltype);
index 0ecfb9b7ff610f9665ba7e53ae6eef78f71c98a3..c3e7a4e2c065d55492fbc9ddb3c1ff6946bf7057 100644 (file)
@@ -219,9 +219,12 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off,
                uint8_t **new_blocks;
                /* expand the blocks array */
                if (tdb->transaction->blocks == NULL) {
-                       new_blocks = malloc((blk+1)*sizeof(uint8_t *));
+                       new_blocks = (uint8_t **)malloc(
+                               (blk+1)*sizeof(uint8_t *));
                } else {
-                       new_blocks = realloc(tdb->transaction->blocks, (blk+1)*sizeof(uint8_t *));
+                       new_blocks = (uint8_t **)realloc(
+                               tdb->transaction->blocks,
+                               (blk+1)*sizeof(uint8_t *));
                }
                if (new_blocks == NULL) {
                        tdb->ecode = TDB_ERR_OOM;
@@ -316,25 +319,15 @@ static int transaction_write_existing(struct tdb_context *tdb, tdb_off_t off,
                return 0;
        }
 
-       /* overwrite part of an existing block */
-       if (buf == NULL) {
-               memset(tdb->transaction->blocks[blk] + off, 0, len);
-       } else {
-               memcpy(tdb->transaction->blocks[blk] + off, buf, len);
-       }
-       if (blk == tdb->transaction->num_blocks-1) {
-               if (len + off > tdb->transaction->last_block_size) {
-                       tdb->transaction->last_block_size = len + off;
-               }
+       if (blk == tdb->transaction->num_blocks-1 &&
+           off + len > tdb->transaction->last_block_size) {
+               len = tdb->transaction->last_block_size - off;
        }
 
-       return 0;
+       /* overwrite part of an existing block */
+       memcpy(tdb->transaction->blocks[blk] + off, buf, len);
 
-fail:
-       TDB_LOG((tdb, TDB_DEBUG_FATAL, "transaction_write: failed at off=%d len=%d\n", 
-                (blk*tdb->transaction->block_size) + off, len));
-       tdb->transaction->transaction_error = 1;
-       return -1;
+       return 0;
 }
 
 
index 2bde1270a078f2df05ddf235fb14cd6fd5218df0..07b0c238587eb85fe3945b61b71dbd9dd0729d58 100644 (file)
@@ -223,6 +223,9 @@ int tdb_traverse_read(struct tdb_context *tdb,
 /*
   a write style traverse - needs to get the transaction lock to
   prevent deadlocks
+
+  WARNING: The data buffer given to the callback fn does NOT meet the
+  alignment restrictions malloc gives you.
 */
 int tdb_traverse(struct tdb_context *tdb, 
                 tdb_traverse_func fn, void *private_data)
index b31ce36ab149b7416043990de4f2eda528e66637..63fcf5e049b13ef01fc3cae78c7326be332287a8 100644 (file)
@@ -130,6 +130,9 @@ int tdb_traverse(TDB_CONTEXT *tdb, int (*fn)(TDB_CONTEXT *tdb,
    a non-zero return value from fn() indicates that the traversal
    should stop. Traversal callbacks may not start transactions.
 
+   WARNING: The data buffer given to the callback fn does NOT meet the
+   alignment restrictions malloc gives you.
+
 ----------------------------------------------------------------------
 int tdb_traverse_read(TDB_CONTEXT *tdb, int (*fn)(TDB_CONTEXT *tdb,
                      TDB_DATA key, TDB_DATA dbuf, void *state), void *state);
index 0058d55793efcd4ad83a1edea692882143be2709..0008085de540b525bb02fc1ff178d06bc898a02d 100644 (file)
@@ -32,9 +32,9 @@ extern "C" {
 
 
 /* flags to tdb_store() */
-#define TDB_REPLACE 1
-#define TDB_INSERT 2
-#define TDB_MODIFY 3
+#define TDB_REPLACE 1          /* Unused */
+#define TDB_INSERT 2           /* Don't overwrite an existing entry */
+#define TDB_MODIFY 3           /* Don't create an existing entry    */
 
 /* flags for tdb_open() */
 #define TDB_DEFAULT 0 /* just a readability place holder */
@@ -157,7 +157,6 @@ int tdb_printfreelist(struct tdb_context *tdb);
 int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries);
 int tdb_wipe_all(struct tdb_context *tdb);
 int tdb_freelist_size(struct tdb_context *tdb);
-int tdb_validate(struct tdb_context *tdb);
 
 extern TDB_DATA tdb_null;
 
index 79435a3571cf61f02233d088e7ce3f01354b19af..d104ccd7c44994e9d0f8ba138cbf4584343983dc 100644 (file)
@@ -135,7 +135,7 @@ static void print_data(const char *buf,int len)
        if (len<=0) return;
        printf("[%03X] ",i);
        for (i=0;i<len;) {
-               printf("%02X ",(int)buf[i]);
+               printf("%02X ",(int)((unsigned char)buf[i]));
                i++;
                if (i%8 == 0) printf(" ");
                if (i%16 == 0) {      
index 1607cb343bf6d3397e3ff5db587d7d98113e7b80..d59cea121e8b0e4c0467867bd1d4e4eed110c1f2 100644 (file)
@@ -180,12 +180,6 @@ def provision_paths_from_lp(lp, dnsdomain):
     paths.dns_keytab = os.path.join(private_dir, "dns.keytab")
     paths.dns = os.path.join(private_dir, dnsdomain + ".zone")
     paths.winsdb = os.path.join(private_dir, "wins.ldb")
-    paths.ldap_basedn_ldif = os.path.join(private_dir, 
-                                          dnsdomain + ".ldif")
-    paths.ldap_config_basedn_ldif = os.path.join(private_dir, 
-                                             dnsdomain + "-config.ldif")
-    paths.ldap_schema_basedn_ldif = os.path.join(private_dir, 
-                                              dnsdomain + "-schema.ldif")
     paths.s4_ldapi_path = os.path.join(private_dir, "ldapi")
     paths.phpldapadminconfig = os.path.join(private_dir, 
                                             "phpldapadmin-config.php")
@@ -465,7 +459,6 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
         setup_add_ldif(samdb, setup_path("provision_basedn.ldif"), {
             "DOMAINDN": domaindn,
             "ACI": aci,
-            "EXTENSIBLEOBJECT": "# no objectClass: extensibleObject for local ldb",
             "RDN_DC": rdn_dc,
             })
 
@@ -823,31 +816,6 @@ def create_zone_file(path, setup_path, samdb, dnsdomain, domaindn,
         })
 
 
-def provision_ldapbase(setup_dir, message, paths):
-    """Write out a DNS zone file, from the info in the current database."""
-    message("Setting up LDAP base entry: %s" % domaindn)
-    rdns = domaindn.split(",")
-
-    rdn_dc = rdns[0][len("DC="):]
-
-    def setup_path(file):
-        return os.path.join(setup_dir, file)
-
-    setup_file(setup_path("provision_basedn.ldif"), 
-           paths.ldap_basedn_ldif)
-
-    setup_file(setup_path("provision_configuration_basedn.ldif"), 
-           paths.ldap_config_basedn_ldif)
-
-    setup_file(setup_path("provision_schema_basedn.ldif"), 
-           paths.ldap_schema_basedn_ldif, {
-            "SCHEMADN": schemadn,
-            "ACI": "# no aci for local ldb",
-            "EXTENSIBLEOBJECT": "objectClass: extensibleObject"})
-
-    message("Please install the LDIF located in " + paths.ldap_basedn_ldif + ", " + paths.ldap_config_basedn_ldif + " and " + paths.ldap_schema_basedn_ldif + " into your LDAP server, and re-run with --ldap-backend=ldap://my.ldap.server")
-
-
 def load_schema(setup_path, samdb, schemadn, netbiosname, configdn):
     """Load schema.
     
index b76955a0cbeb45ff8eda65180c2c61575eba43df..574912b3e840d14bc15a30309cbabf56d585d752 100644 (file)
@@ -2,14 +2,12 @@ dn: CN=DisplaySpecifiers,${CONFIGDN}
 objectClass: top
 objectClass: container
 showInAdvancedViewOnly: TRUE
-instanceType: 4
 
 dn: CN=409,CN=DisplaySpecifiers,${CONFIGDN}
 objectClass: top
 objectClass: container
 cn: 409
 name: 409
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 
 dn: CN=user-Display,CN=409,CN=DisplaySpecifiers,${CONFIGDN}
index c6b07c5751eae60fdd01ed4a2414c792c3f2cb71..5e15bf347a70bab256106401f224a2482cd0ad65 100644 (file)
@@ -3,7 +3,6 @@ objectClass: top
 objectClass: organizationalUnit
 cn: Domain Controllers
 description: Default container for domain controllers
-instanceType: 4
 showInAdvancedViewOnly: FALSE
 systemFlags: 2348810240
 isCriticalSystemObject: TRUE
@@ -13,7 +12,6 @@ objectClass: top
 objectClass: container
 cn: ForeignSecurityPrincipals
 description: Default container for security identifiers (SIDs) associated with objects from external, trusted domains
-instanceType: 4
 showInAdvancedViewOnly: FALSE
 systemFlags: 2348810240
 isCriticalSystemObject: TRUE
@@ -23,7 +21,6 @@ objectClass: top
 objectClass: container
 cn: System
 description: Builtin system settings
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 systemFlags: 2348810240
 isCriticalSystemObject: TRUE
@@ -32,7 +29,6 @@ dn: CN=RID Manager$,CN=System,${DOMAINDN}
 objectclass: top
 objectclass: rIDManager
 cn: RID Manager$
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 systemFlags: 2348810240
 isCriticalSystemObject: TRUE
@@ -43,14 +39,12 @@ dn: CN=DomainUpdates,CN=System,${DOMAINDN}
 objectClass: top
 objectClass: container
 cn: DomainUpdates
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 
 dn: CN=Windows2003Update,CN=DomainUpdates,CN=System,${DOMAINDN}
 objectClass: top
 objectClass: container
 cn: Windows2003Update
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 revision: 8
 
@@ -58,7 +52,6 @@ dn: CN=Infrastructure,${DOMAINDN}
 objectclass: top
 objectclass: infrastructureUpdate
 cn: Infrastructure
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 systemFlags: 2348810240
 isCriticalSystemObject: TRUE
@@ -68,7 +61,6 @@ dn: CN=Builtin,${DOMAINDN}
 objectClass: top
 objectClass: builtinDomain
 cn: Builtin
-instanceType: 4
 showInAdvancedViewOnly: FALSE
 forceLogoff: 9223372036854775808
 lockoutDuration: -18000000000
index e166d5f3dd28fc76ba06cd7732b12d0b23ceb702..88015ce0a314f9ef0945a39b4f0bd59d27a462f6 100755 (executable)
@@ -34,7 +34,7 @@ from auth import system_session
 import samba.getopt as options
 import param
 from samba.provision import (provision,  
-                             provision_paths_from_lp, provision_ldapbase)
+                             provision_paths_from_lp)
 
 parser = optparse.OptionParser("provision [options]")
 parser.add_option_group(options.SambaOptions(parser))
@@ -81,9 +81,6 @@ parser.add_option("--users", type="string", metavar="GROUPNAME",
 parser.add_option("--quiet", help="Be quiet", action="store_true")
 parser.add_option("--blank", action="store_true",
                help="do not add users or groups, just the structure")
-parser.add_option("--ldap-base", 
-               help="output only an LDIF file, suitable for creating an LDAP baseDN",
-        action="store_true")
 parser.add_option("--ldap-backend", type="string", metavar="LDAPSERVER", 
                help="LDAP server to use for this provision")
 parser.add_option("--ldap-module=", type="string", metavar="MODULE", 
@@ -152,10 +149,7 @@ creds = credopts.get_credentials()
 setup_dir = opts.setupdir
 if setup_dir is None:
        setup_dir = "setup"
-if opts.ldap_base:
-       provision_ldapbase(setup_dir, message, paths)
-       message("Please install the LDIF located in %s, %s and  into your LDAP server, and re-run with --ldap-backend=ldap://my.ldap.server" % (paths.ldap_basedn_ldif, paths.ldap_config_basedn_ldif, paths.ldap_schema_basedn_ldif))
-elif opts.partitions_only:
+if opts.partitions_only:
     provision_become_dc(setup_dir, message, False, 
                         paths, lp, system_session(), creds)
 else:
index b7502e5107fac230573893a8fb09dc4767e64633..3bb4074d424d1e51d468f573c6b9db0744d6a9e8 100644 (file)
@@ -3,9 +3,6 @@ changetype: modify
 replace: description
 description: Default container for upgraded computer accounts
 -
-replace: instanceType
-instanceType: 4
--
 replace: showInAdvancedViewOnly
 showInAdvancedViewOnly: FALSE
 -
index 050f110d9a4adad188c9b0af71bac031a6a5a8ce..750fa1326a3271c3c94db8dc626c04fbf2021141 100644 (file)
@@ -5,7 +5,6 @@ dn: CN=Partitions,${CONFIGDN}
 objectClass: top
 objectClass: crossRefContainer
 cn: Partitions
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 systemFlags: 2147483648
 msDS-Behavior-Version: 0
@@ -15,7 +14,6 @@ dn: CN=Enterprise Configuration,CN=Partitions,${CONFIGDN}
 objectClass: top
 objectClass: crossRef
 cn: Enterprise Configuration
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 systemFlags: 1
 nCName: ${CONFIGDN}
@@ -25,7 +23,6 @@ dn: CN=Enterprise Schema,CN=Partitions,${CONFIGDN}
 objectClass: top
 objectClass: crossRef
 cn: Enterprise Schema
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 systemFlags: 1
 nCName: ${SCHEMADN}
@@ -35,7 +32,6 @@ dn: CN=${DOMAIN},CN=Partitions,${CONFIGDN}
 objectClass: top
 objectClass: crossRef
 cn: ${DOMAIN}
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 systemFlags: 3
 nCName: ${DOMAINDN}
@@ -46,7 +42,6 @@ dn: CN=Sites,${CONFIGDN}
 objectClass: top
 objectClass: sitesContainer
 cn: Sites
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 systemFlags: 2181038080
 
@@ -54,7 +49,6 @@ dn: CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
 objectClass: top
 objectClass: site
 cn: ${DEFAULTSITE}
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 systemFlags: 2181038080
 
@@ -62,7 +56,6 @@ dn: CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
 objectClass: top
 objectClass: serversContainer
 cn: Servers
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 systemFlags: 2181038080
 
@@ -70,7 +63,6 @@ dn: CN=Services,${CONFIGDN}
 objectClass: top
 objectClass: container
 cn: Services
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 systemFlags: 2147483648
 
@@ -78,14 +70,12 @@ dn: CN=Windows NT,CN=Services,${CONFIGDN}
 objectClass: top
 objectClass: container
 cn: Windows NT
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 
 dn: CN=Directory Service,CN=Windows NT,CN=Services,${CONFIGDN}
 objectClass: top
 objectClass: nTDSService
 cn: Directory Service
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 sPNMappings: host=ldap,dns,cifs,http
 
@@ -93,14 +83,12 @@ dn: CN=Query-Policies,CN=Directory Service,CN=Windows NT,CN=Services,${CONFIGDN}
 objectClass: top
 objectClass: container
 cn: Query-Policies
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 
 dn: CN=Default Query Policy,CN=Query-Policies,CN=Directory Service,CN=Windows NT,CN=Services,${CONFIGDN}
 objectClass: top
 objectClass: queryPolicy
 cn: Default Query Policy
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 lDAPAdminLimits: MaxValRange=1500
 lDAPAdminLimits: MaxReceiveBuffer=10485760
index 46ba4e9649a5a398f8f3ede8f61bbf84a8775a55..a72f2c8eca2e33655805dbf79e63977bf38adb5a 100644 (file)
@@ -3,14 +3,8 @@
 ###############################
 dn: ${CONFIGDN}
 changetype: modify
-replace: instanceType
-instanceType: 13
--
 replace: showInAdvancedViewOnly
 showInAdvancedViewOnly: TRUE
 -
-replace: objectCategory
-objectCategory: CN=Configuration,${SCHEMADN}
--
 replace: subRefs
 subRefs: ${SCHEMADN}
index 92c5cf1ace42e601c24baada6f9e6c8619889906..986f0d632c596c192e512801fb69607e27a7b18e 100644 (file)
@@ -3,9 +3,6 @@
 ###############################
 dn: ${SCHEMADN}
 changetype: modify
-replace: instanceType
-instanceType: 13
--
 replace: showInAdvancedViewOnly
 showInAdvancedViewOnly: TRUE
 -
index 06230e8d005673d5d8ab0f65f16b8b5a5309cafe..1caa62163e9c9a8aedb3e4e5b86844ab02e3ccf5 100644 (file)
@@ -43,7 +43,6 @@ dn: CN=${NETBIOSNAME},CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
 objectClass: top
 objectClass: server
 cn: ${NETBIOSNAME}
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 systemFlags: 1375731712
 dNSHostName: ${DNSNAME}
@@ -55,7 +54,6 @@ objectClass: applicationSettings
 objectClass: nTDSDSA
 cn: NTDS Settings
 options: 1
-instanceType: 4
 showInAdvancedViewOnly: TRUE
 systemFlags: 33554432
 dMDLocation: ${SCHEMADN}
index 8797efaf9861d2f1f224b13c3be8ea7933ff447d..04eaabcab7797ef0ce0bf8e19b4e3d70661a28a3 100644 (file)
@@ -66,7 +66,6 @@ sAMAccountType: 268435456
 #
 # dn: CN=TemplateAlias,CN=Templates
 # cn: TemplateAlias
-# instanceType: 4
 # groupType: -2147483644
 # sAMAccountType: 268435456
 
index 7c1a438d8e0f681f0788cb6df504214a408a9e4f..3e6f717f1543bb424b537d58829e46ce22b3b8ee 100644 (file)
@@ -134,7 +134,6 @@ objectClass: top
 objectClass: group
 cn: RAS and IAS Servers
 description: Servers in this group can access remote access properties of users
-instanceType: 4
 objectSid: ${DOMAINSID}-553
 sAMAccountName: RAS and IAS Servers
 sAMAccountType: 536870912
@@ -307,7 +306,6 @@ objectClass: top
 objectClass: group
 cn: Server Operators
 description: Members can administer domain servers
-instanceType: 4
 objectSid: S-1-5-32-549
 adminCount: 1
 sAMAccountName: Server Operators
@@ -327,7 +325,6 @@ objectClass: top
 objectClass: group
 cn: Account Operators
 description: Members can administer domain user and group accounts
-instanceType: 4
 objectSid: S-1-5-32-548
 adminCount: 1
 sAMAccountName: Account Operators
index 42dff070807765132218dc784cc442186d2d9f1c..06954c44f06324b2cf93599438636c257be2d116 100644 (file)
@@ -3,9 +3,6 @@ changetype: modify
 replace: description
 description: Default container for upgraded user accounts
 -
-replace: instanceType
-instanceType: 4
--
 replace: showInAdvancedViewOnly
 showInAdvancedViewOnly: FALSE
 -
index e4e86eece93c06a4f43cb797f07e483dabd7f139..83f4da335901daf6055463186860e2bd5b927a41 100644 (file)
@@ -34,6 +34,12 @@ index lDAPDisplayName eq
 index subClassOf eq
 index cn eq
 
+#syncprov is stable in OpenLDAP 2.3, and available in 2.2.  
+#We only need this for the contextCSN attribute anyway....
+overlay syncprov
+syncprov-checkpoint 100 10
+syncprov-sessionlog 100
+
 database        hdb
 suffix         ${CONFIGDN}
 directory      ${LDAPDIR}/db/config
@@ -48,6 +54,12 @@ index dnsRoot eq
 index nETBIOSName eq
 index cn eq
 
+#syncprov is stable in OpenLDAP 2.3, and available in 2.2.  
+#We only need this for the contextCSN attribute anyway....
+overlay syncprov
+syncprov-checkpoint 100 10
+syncprov-sessionlog 100
+
 database        hdb
 suffix         ${DOMAINDN}
 rootdn          ${LDAPMANAGERDN}