[SCM] Samba Shared Repository - branch master updated

Gary Lockyer gary at samba.org
Tue Jul 2 04:20:04 UTC 2019


The branch, master has been updated
       via  92f9f836aba WHATSNEW.txt: samba-tool --backend-size-parameter
       via  5583208aed0 samba-tool domain join: remove the subdomain option
       via  54fbac97ef7 join subdomain: changes for --backend-store-size
       via  2face29963d samba-tool domain dcpromo: add --backend-store-size option
       via  bdd72acd32b samba-tool dcpromo tests: add --backend-store-size option
       via  97bc3db68a5 samba-tool clone-dc-database: Add --backend-store-size option
       via  0ee3b06640b clone-dc-database tests: Add --backend-store-size option
       via  ddfc1ddd4f9 samba-tool domain join: Add --backend-store-size option
       via  f93cb76ab01 domain join tests: Add --backend-store-size option.
       via  236f5f6a8c1 provision: Add --backend-store-size option
       via  bbc20000791 lib ldb ldb_mdb: Pass the lmdb map size as an ldb option
       via  e46d5bb669d ldb: Release ldb 2.0.4
       via  3b52ca59a2d lib ldb: save a copy of the options on the context
       via  b281fc624e5 provision: If --targetdir has been specified then we must always reset posix:eadb and xattr_tdb:file
       via  5cbe76e395d samba-tool domain provision: add lmdb database size option
       via  4644416a921 samba-tool: Make the 'bytes' option type avaiable
       via  b8446c08025 python getopt: Add bytes option type
       via  b27817d4917 provision tests: Add --backend-store-size option.
      from  6e65c283120 selftest: add a test that itime is not set when setting DOS attrs

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 92f9f836abaf0fa85e6fd4fc08c2993c9a4af70b
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Mon Jul 1 11:44:36 2019 +1200

    WHATSNEW.txt: samba-tool --backend-size-parameter
    
    Document the --backend-store-size option added to the samba-tool sub
    commands:
     * domain provision
     * domain join
     * domain dcpromo
     * drs clone-dc-database
    
    And the removal os the join subdomain option.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Gary Lockyer <gary at samba.org>
    Autobuild-Date(master): Tue Jul  2 04:19:29 UTC 2019 on sn-devel-184

commit 5583208aed0e4647269e48aa1d3c5c48a73001ac
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Fri Jun 28 15:13:13 2019 +1200

    samba-tool domain join: remove the subdomain option
    
    Remove the sub domain option from join, as it currently does not work.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 54fbac97ef70ece7a0607d5d6073501f08f8adc6
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Fri Jun 28 15:11:11 2019 +1200

    join subdomain: changes for --backend-store-size
    
    Pass the 'backend_store_size' parameter through to DCJoinContext.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 2face29963da2192c81e62a98d181fe7fd22c977
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Fri Jun 28 15:12:31 2019 +1200

    samba-tool domain dcpromo: add --backend-store-size option
    
    Add a new "samba-tool domain dcpromo" option "backend-store-size".
    This allows the lmdb map size to be set during a promotion, instead of
    hard-wiring it to 8Gb.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit bdd72acd32b6777b80b54d82688048e1cb0b8f32
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Fri Jun 28 15:14:51 2019 +1200

    samba-tool dcpromo tests: add --backend-store-size option
    
    Add a new "samba-tool domain dcpromo" option "backend-store-size".
    This allows the lmdb map size to be set during a promotion, instead of
    hard-wiring it to 8Gb.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 97bc3db68a5ec2cd20e5059d77089e76a0625479
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Fri Jun 28 08:56:31 2019 +1200

    samba-tool clone-dc-database: Add --backend-store-size option
    
    Add a new "samba-tool drs clone-dc-database" option "backend-store-size".
    This allows the lmdb map size to be set during a clone, instead of
    hard-wiring it to 8Gb.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>'
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 0ee3b06640b9032f4b462aad03f076e28b8763ed
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Fri Jun 28 08:54:31 2019 +1200

    clone-dc-database tests: Add --backend-store-size option
    
    Add a new "samba-tool drs clone-dc-database" option "backend-store-size".
    This allows the lmdb map size to be set during a clone, instead of
    hard-wiring it to 8Gb.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>'
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit ddfc1ddd4f9e9b4b70e036023d7868cb48c7391f
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Fri Jun 28 08:52:50 2019 +1200

    samba-tool domain join: Add --backend-store-size option
    
    Add a new "samba-tool domain join" option "backend-store-size".
    This allows the lmdb map size to be set during a provision, instead of
    hard-wiring it to 8Gb.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit f93cb76ab01d0d6f3d59979f2c7d6711fe444f1b
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Thu Jun 27 10:19:51 2019 +1200

    domain join tests: Add --backend-store-size option.
    
    Tests for the new "samba-tool domain join" option
    "backend-store-size". This allows the lmdb map size to be set during a
    provision, instead of hard-wiring it to 8Gb.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 236f5f6a8c1063bc4ca4d95ce214c870c37e1475
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Tue Jun 25 16:23:24 2019 +1200

    provision: Add --backend-store-size option
    
    Add a new "samba-tool domain provision" option "backend-store-size".
    This allows the lmdb map size to be set during a provision, instead of
    hard-wiring it to 8Gb
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit bbc20000791d167c5f2683ef3f217a8719b47ead
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Tue Jun 25 16:22:15 2019 +1200

    lib ldb ldb_mdb: Pass the lmdb map size as an ldb option
    
    Allow the lmdb map size to be specified in the ldb option
    "lmdb_env_size".
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit e46d5bb669d1e3bec8283df64eeedaad997f6625
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Wed Jun 26 09:38:35 2019 +1200

    ldb: Release ldb 2.0.4
    
    * copy the ldb_options passed to ldb_connect onto the ldb_context,
      making them more generally available.
    
    * fix index buffering.
      As a performance enhancement the indexes are cached in memory during a
      transaction, and written to disk as part of the prepare commit. The
      indexes could become corrupt in the event of a failed operation.
    
    * fix read beyond buffer
      Calling the "ldb_parse_tree" function with a filter consisting of
      exactly a single space (" ") would trigger a read beyond the input
      buffer.
      BUG: https://bugzilla.samba.org/show_bug.cgi?id=13900
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 3b52ca59a2d01da35539a2940fda5f4df15aeb21
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Tue Jun 25 16:17:12 2019 +1200

    lib ldb: save a copy of the options on the context
    
    Copy the options supplied to to ldb_connect, and place them on the
    ldb_context. This allows backend options i.e. lmbd map size to be passed
    cleanly from the callers.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit b281fc624e53ead0ef614ea2fcff46bc9b599f92
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Jun 25 16:12:47 2019 +1200

    provision: If --targetdir has been specified then we must always reset posix:eadb and xattr_tdb:file
    
    This is required because otherwise this may have been set previously by another
    part of selftest thanks to the global loadparm and the running of multiple
    samba-tool tests within the same python process.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

commit 5cbe76e395de1c21246e1ecdaf9eeb57783a34f9
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Fri Jun 21 13:13:08 2019 +1200

    samba-tool domain provision: add lmdb database size option
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 4644416a92179f1f44ebcce90be1a058da4b3b30
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Fri Jun 21 13:12:01 2019 +1200

    samba-tool: Make the 'bytes' option type avaiable
    
    Allow samba tool to use the custom bytes option type.
      Option("--size", type="bytes", metavar="SIZE")
    To allow the input of file and memory sizes using unit suffixes i.e.  2Gb,
    4KiB ...
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit b8446c080254053b63dbb8aca7d5332e044a9c93
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Fri Jun 21 13:05:23 2019 +1200

    python getopt: Add bytes option type
    
    Add a new option type to the python command line options.
      Option("--size", type="bytes", metavar="SIZE")
    To allow the input of file and memory sizes using unit suffixes i.e.
    2Gb, 4KiB ...
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit b27817d491794a292278832e3f59f955f418a6cb
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Tue Jun 25 16:14:34 2019 +1200

    provision tests: Add --backend-store-size option.
    
    Tests for the new "samba-tool domain provision" option
    "backend-store-size".  This allows the lmdb map size to be set during a
    provision, instead of hard-wiring it to 8Gb
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 WHATSNEW.txt                                       |  19 ++-
 lib/ldb/ABI/{ldb-2.0.2.sigs => ldb-2.0.4.sigs}     |   1 +
 ...yldb-util-1.1.10.sigs => pyldb-util-2.0.4.sigs} |   0
 lib/ldb/common/ldb.c                               |   9 ++
 lib/ldb/common/ldb_options.c                       |  30 ++++
 lib/ldb/include/ldb_private.h                      |   7 +
 lib/ldb/ldb_mdb/ldb_mdb.c                          |  56 ++++---
 lib/ldb/wscript                                    |   2 +-
 python/samba/getopt.py                             |  45 ++++++
 python/samba/join.py                               |  42 +++--
 python/samba/netcmd/__init__.py                    |   3 +-
 python/samba/netcmd/domain.py                      |  47 +++---
 python/samba/netcmd/drs.py                         |  16 +-
 python/samba/provision/__init__.py                 |  61 +++++---
 python/samba/tests/__init__.py                     |  17 +++
 .../samba_tool/drs_clone_dc_data_lmdb_size.py      | 119 +++++++++++++++
 python/samba/tests/samba_tool/join_lmdb_size.py    | 148 ++++++++++++++++++
 .../samba/tests/samba_tool/promote_dc_lmdb_size.py | 170 +++++++++++++++++++++
 .../samba/tests/samba_tool/provision_lmdb_size.py  | 132 ++++++++++++++++
 selftest/target/Samba4.pm                          | 103 -------------
 source4/selftest/tests.py                          |   7 +
 21 files changed, 852 insertions(+), 182 deletions(-)
 copy lib/ldb/ABI/{ldb-2.0.2.sigs => ldb-2.0.4.sigs} (99%)
 copy lib/ldb/ABI/{pyldb-util-1.1.10.sigs => pyldb-util-2.0.4.sigs} (100%)
 create mode 100644 python/samba/tests/samba_tool/drs_clone_dc_data_lmdb_size.py
 create mode 100644 python/samba/tests/samba_tool/join_lmdb_size.py
 create mode 100644 python/samba/tests/samba_tool/promote_dc_lmdb_size.py
 create mode 100644 python/samba/tests/samba_tool/provision_lmdb_size.py


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 7ba0dbeca13..3d6cbbe8dee 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -81,7 +81,6 @@ Log lines are of the form:
 
     durations are in microseconds.
 
-
 Default schema updated to 2012_R2
 -------------------------
 
@@ -90,6 +89,17 @@ is not yet available.  Older schemas can be used by provisioning with the
 '--base-schema' argument.  Existing installations can be updated with the
 samba-tool command "domain schemaupgrade".
 
+Setting lmdb map size
+---------------------
+
+It is now possible to set the lmdb map size (The maximum permitted size for
+the database).  "samba-tool" now accepts the "--backend-store-size"
+i.e. --backend-store-size=4Gb.  If not specified it defaults to 8Gb.
+This option is avaiable for the following sub commands:
+ * domain provision
+ * domain join
+ * domain dcpromo
+ * drs clone-dc-database
 
 REMOVED FEATURES
 ================
@@ -103,6 +113,13 @@ from the 'server services' smb.conf parameter). This service was unused and has
 now been removed from Samba.
 
 
+samba-tool join subdommain
+--------------------------
+
+The subdommain role has been removed from the join command.  This option did
+not work and has no tests.
+
+
 smb.conf changes
 ================
 
diff --git a/lib/ldb/ABI/ldb-2.0.2.sigs b/lib/ldb/ABI/ldb-2.0.4.sigs
similarity index 99%
copy from lib/ldb/ABI/ldb-2.0.2.sigs
copy to lib/ldb/ABI/ldb-2.0.4.sigs
index 5fc5560ee21..446804bd95e 100644
--- a/lib/ldb/ABI/ldb-2.0.2.sigs
+++ b/lib/ldb/ABI/ldb-2.0.4.sigs
@@ -196,6 +196,7 @@ ldb_next_remote_request: int (struct ldb_module *, struct ldb_request *)
 ldb_next_request: int (struct ldb_module *, struct ldb_request *)
 ldb_next_start_trans: int (struct ldb_module *)
 ldb_op_default_callback: int (struct ldb_request *, struct ldb_reply *)
+ldb_options_copy: const char **(TALLOC_CTX *, const char **)
 ldb_options_find: const char *(struct ldb_context *, const char **, const char *)
 ldb_pack_data: int (struct ldb_context *, const struct ldb_message *, struct ldb_val *, uint32_t)
 ldb_parse_control_from_string: struct ldb_control *(struct ldb_context *, TALLOC_CTX *, const char *)
diff --git a/lib/ldb/ABI/pyldb-util-1.1.10.sigs b/lib/ldb/ABI/pyldb-util-2.0.4.sigs
similarity index 100%
copy from lib/ldb/ABI/pyldb-util-1.1.10.sigs
copy to lib/ldb/ABI/pyldb-util-2.0.4.sigs
diff --git a/lib/ldb/common/ldb.c b/lib/ldb/common/ldb.c
index b9f5164c4e9..95e9138a56b 100644
--- a/lib/ldb/common/ldb.c
+++ b/lib/ldb/common/ldb.c
@@ -257,6 +257,15 @@ int ldb_connect(struct ldb_context *ldb, const char *url,
 		return ret;
 	}
 
+	/*
+	 * Take a copy of the options.
+	 */
+	ldb->options = ldb_options_copy(ldb, options);
+	if (ldb->options == NULL && options != NULL) {
+		ldb_oom(ldb);
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
 	ret = ldb_module_connect_backend(ldb, url, options, &ldb->modules);
 	if (ret != LDB_SUCCESS) {
 		return ret;
diff --git a/lib/ldb/common/ldb_options.c b/lib/ldb/common/ldb_options.c
index f07f3935624..0aa80f75159 100644
--- a/lib/ldb/common/ldb_options.c
+++ b/lib/ldb/common/ldb_options.c
@@ -70,3 +70,33 @@ const char *ldb_options_find(struct ldb_context *ldb, const char *options[],
 
 	return NULL;
 }
+
+const char **ldb_options_copy(TALLOC_CTX *ctx, const char *options[])
+{
+
+	size_t num_options = 0;
+	const char **copy = NULL;
+	size_t i = 0;
+
+	if (options == NULL) {
+		return copy;
+	}
+
+	for (i=0; options[i]; i++) {
+		num_options++;
+	}
+
+	copy = talloc_zero_array(ctx, const char *, num_options + 1);
+	if (copy == NULL) {
+		return copy;
+	}
+
+	for (i=0; options[i]; i++) {
+		copy[i] = talloc_strdup(copy, options[i]);
+		if (copy[i] == NULL) {
+			TALLOC_FREE(copy);
+			return copy;
+		}
+	}
+	return copy;
+}
diff --git a/lib/ldb/include/ldb_private.h b/lib/ldb/include/ldb_private.h
index f999f7530bf..4deb24691ca 100644
--- a/lib/ldb/include/ldb_private.h
+++ b/lib/ldb/include/ldb_private.h
@@ -155,6 +155,12 @@ struct ldb_context {
 	char *partial_debug;
 
 	struct poptOption *popt_options;
+
+	/*
+	 * The ldb options passed to ldb_connect
+	 * A NULL terminated array of zero terminated strings
+	 */
+	const char **options;
 };
 
 /* The following definitions come from lib/ldb/common/ldb.c  */
@@ -218,6 +224,7 @@ struct ldb_val ldb_binary_decode(TALLOC_CTX *mem_ctx, const char *str);
 
 const char *ldb_options_find(struct ldb_context *ldb, const char *options[],
 			     const char *option_name);
+const char **ldb_options_copy(TALLOC_CTX *ctx, const char *options[]);
 
 /* The following definitions come from lib/ldb/common/ldb_ldif.c  */
 
diff --git a/lib/ldb/ldb_mdb/ldb_mdb.c b/lib/ldb/ldb_mdb/ldb_mdb.c
index 35e21434ff0..6c679c214b8 100644
--- a/lib/ldb/ldb_mdb/ldb_mdb.c
+++ b/lib/ldb/ldb_mdb/ldb_mdb.c
@@ -882,10 +882,10 @@ static int lmdb_open_env(TALLOC_CTX *mem_ctx,
 			 MDB_env **env,
 			 struct ldb_context *ldb,
 			 const char *path,
+			 const size_t env_map_size,
 			 unsigned int flags)
 {
 	int ret;
-	const size_t mmap_size = 8LL * GIGABYTE;
 	unsigned int mdb_flags = MDB_NOSUBDIR|MDB_NOTLS;
 	/*
 	 * MDB_NOSUBDIR implies there is a separate file called path and a
@@ -930,20 +930,19 @@ static int lmdb_open_env(TALLOC_CTX *mem_ctx,
 		return ldb_mdb_err_map(ret);
 	}
 
-	/*
-	 * Currently we set a 8Gb maximum database size
-	 * via the constant mmap_size above
-	 */
-	ret = mdb_env_set_mapsize(*env, mmap_size);
-	if (ret != 0) {
-		ldb_asprintf_errstring(
-			ldb,
-			"Could not set MDB mmap() size to %llu on %s: %s\n",
-			(unsigned long long)(mmap_size),
-			path,
-			mdb_strerror(ret));
-		TALLOC_FREE(w);
-		return ldb_mdb_err_map(ret);
+	if (env_map_size > 0) {
+		ret = mdb_env_set_mapsize(*env, env_map_size);
+		if (ret != 0) {
+			ldb_asprintf_errstring(
+				ldb,
+				"Could not set MDB mmap() size to %llu "
+				"on %s: %s\n",
+				(unsigned long long)(env_map_size),
+				path,
+				mdb_strerror(ret));
+			TALLOC_FREE(w);
+			return ldb_mdb_err_map(ret);
+		}
 	}
 
 	mdb_env_set_maxreaders(*env, 100000);
@@ -964,6 +963,19 @@ static int lmdb_open_env(TALLOC_CTX *mem_ctx,
 		return ldb_mdb_err_map(ret);
 	}
 
+	{
+		MDB_envinfo stat = {0};
+		ret = mdb_env_info (*env, &stat);
+		if (ret != 0) {
+			ldb_asprintf_errstring(
+				ldb,
+				"Could not get MDB environment stats %s: %s\n",
+				path,
+				mdb_strerror(ret));
+		return ldb_mdb_err_map(ret);
+		}
+	}
+
 	ret = mdb_env_get_fd(*env, &fd);
 	if (ret != 0) {
 		ldb_asprintf_errstring(ldb,
@@ -1010,6 +1022,7 @@ static int lmdb_open_env(TALLOC_CTX *mem_ctx,
 static int lmdb_pvt_open(struct lmdb_private *lmdb,
 			 struct ldb_context *ldb,
 			 const char *path,
+			 const size_t env_map_size,
 			 unsigned int flags)
 {
 	int ret;
@@ -1022,7 +1035,7 @@ static int lmdb_pvt_open(struct lmdb_private *lmdb,
 		}
 	}
 
-	ret = lmdb_open_env(lmdb, &lmdb->env, ldb, path, flags);
+	ret = lmdb_open_env(lmdb, &lmdb->env, ldb, path, env_map_size, flags);
 	if (ret != 0) {
 		return ret;
 	}
@@ -1053,6 +1066,7 @@ int lmdb_connect(struct ldb_context *ldb,
 	struct lmdb_private *lmdb = NULL;
 	struct ldb_kv_private *ldb_kv = NULL;
 	int ret;
+	size_t env_map_size = 0;
 
 	/*
 	 * We hold locks, so we must use a private event context
@@ -1080,7 +1094,15 @@ int lmdb_connect(struct ldb_context *ldb,
 	lmdb->ldb = ldb;
 	ldb_kv->kv_ops = &lmdb_key_value_ops;
 
-	ret = lmdb_pvt_open(lmdb, ldb, path, flags);
+	{
+		const char *size = ldb_options_find(
+			ldb, ldb->options, "lmdb_env_size");
+		if (size != NULL) {
+			env_map_size = strtoull(size, NULL, 0);
+		}
+	}
+
+	ret = lmdb_pvt_open(lmdb, ldb, path, env_map_size, flags);
 	if (ret != LDB_SUCCESS) {
 		TALLOC_FREE(ldb_kv);
 		return ret;
diff --git a/lib/ldb/wscript b/lib/ldb/wscript
index cda5cf68bca..ef92f8f5991 100644
--- a/lib/ldb/wscript
+++ b/lib/ldb/wscript
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'ldb'
-VERSION = '2.0.3'
+VERSION = '2.0.4'
 
 import sys, os
 
diff --git a/python/samba/getopt.py b/python/samba/getopt.py
index 094031ddd52..63cd775605c 100644
--- a/python/samba/getopt.py
+++ b/python/samba/getopt.py
@@ -20,6 +20,7 @@
 __docformat__ = "restructuredText"
 
 import optparse
+from copy import copy
 import os
 from samba.credentials import (
     Credentials,
@@ -285,3 +286,47 @@ class CredentialsOptionsDouble(CredentialsOptions):
         if self.no_pass2:
             self.creds2.set_cmdline_callbacks()
         return self.creds2
+
+# Custom option type to allow the input of sizes using byte, kb, mb ...
+# units, e.g. 2Gb, 4KiB ...
+#    e.g. Option("--size", type="bytes", metavar="SIZE")
+#
+def check_bytes(option, opt, value):
+
+    multipliers = {
+            "B"  : 1,
+            "KB" : 1024,
+            "MB" : 1024 * 1024,
+            "GB" : 1024 * 1024 * 1024}
+
+    # strip out any spaces
+    v = value.replace(" ", "")
+
+    # extract the numeric prefix
+    digits = ""
+    while v and v[0:1].isdigit() or v[0:1] == '.':
+        digits += v[0]
+        v = v[1:]
+
+    try:
+        m = float(digits)
+    except ValueError:
+        msg = ("{0} option requires a numeric value, "
+               "with an optional unit suffix").format(opt)
+        raise optparse.OptionValueError(msg)
+
+
+    # strip out the 'i' and convert to upper case so
+    # kib Kib kb KB are all equivalent
+    suffix = v.upper().replace("I", "")
+    try:
+        return m * multipliers[suffix]
+    except KeyError as k:
+        msg = ("{0} invalid suffix '{1}', "
+               "should be B, Kb, Mb or Gb").format(opt, v)
+        raise optparse.OptionValueError(msg)
+
+class SambaOption(optparse.Option):
+    TYPES = optparse.Option.TYPES + ("bytes",)
+    TYPE_CHECKER = copy(optparse.Option.TYPE_CHECKER)
+    TYPE_CHECKER["bytes"] = check_bytes
diff --git a/python/samba/join.py b/python/samba/join.py
index 46491122319..77d260b42fa 100644
--- a/python/samba/join.py
+++ b/python/samba/join.py
@@ -66,7 +66,9 @@ class DCJoinContext(object):
                  netbios_name=None, targetdir=None, domain=None,
                  machinepass=None, use_ntvfs=False, dns_backend=None,
                  promote_existing=False, plaintext_secrets=False,
-                 backend_store=None, forced_local_samdb=None):
+                 backend_store=None,
+                 backend_store_size=None,
+                 forced_local_samdb=None):
 
         ctx.logger = logger
         ctx.creds = creds
@@ -76,6 +78,7 @@ class DCJoinContext(object):
         ctx.use_ntvfs = use_ntvfs
         ctx.plaintext_secrets = plaintext_secrets
         ctx.backend_store = backend_store
+        ctx.backend_store_size = backend_store_size
 
         ctx.promote_existing = promote_existing
         ctx.promote_from_dn = None
@@ -301,8 +304,9 @@ class DCJoinContext(object):
             objectAttr = lsa.ObjectAttribute()
             objectAttr.sec_qos = lsa.QosInfo()
 
-            pol_handle = lsaconn.OpenPolicy2(''.decode('utf-8'),
-                                             objectAttr, security.SEC_FLAG_MAXIMUM_ALLOWED)
+            pol_handle = lsaconn.OpenPolicy2('',
+                                             objectAttr,
+                                             security.SEC_FLAG_MAXIMUM_ALLOWED)
 
             name = lsa.String()
             name.string = ctx.realm
@@ -872,7 +876,8 @@ class DCJoinContext(object):
                             sitename=ctx.site, lp=ctx.lp, ntdsguid=ctx.ntds_guid,
                             use_ntvfs=ctx.use_ntvfs, dns_backend=ctx.dns_backend,
                             plaintext_secrets=ctx.plaintext_secrets,
-                            backend_store=ctx.backend_store
+                            backend_store=ctx.backend_store,
+                            backend_store_size=ctx.backend_store_size
                             )
         print("Provision OK for domain DN %s" % presult.domaindn)
         ctx.local_samdb = presult.samdb
@@ -1459,13 +1464,15 @@ def join_RODC(logger=None, server=None, creds=None, lp=None, site=None, netbios_
               targetdir=None, domain=None, domain_critical_only=False,
               machinepass=None, use_ntvfs=False, dns_backend=None,
               promote_existing=False, plaintext_secrets=False,
-              backend_store=None):
+              backend_store=None,
+              backend_store_size=None):
     """Join as a RODC."""
 
     ctx = DCJoinContext(logger, server, creds, lp, site, netbios_name,
                         targetdir, domain, machinepass, use_ntvfs, dns_backend,
                         promote_existing, plaintext_secrets,
-                        backend_store=backend_store)
+                        backend_store=backend_store,
+                        backend_store_size=backend_store_size)
 
     lp.set("workgroup", ctx.domain_name)
     logger.info("workgroup is %s" % ctx.domain_name)
@@ -1513,12 +1520,14 @@ def join_DC(logger=None, server=None, creds=None, lp=None, site=None, netbios_na
             targetdir=None, domain=None, domain_critical_only=False,
             machinepass=None, use_ntvfs=False, dns_backend=None,
             promote_existing=False, plaintext_secrets=False,
-            backend_store=None):
+            backend_store=None,
+            backend_store_size=None):
     """Join as a DC."""
     ctx = DCJoinContext(logger, server, creds, lp, site, netbios_name,
                         targetdir, domain, machinepass, use_ntvfs, dns_backend,
                         promote_existing, plaintext_secrets,
-                        backend_store=backend_store)
+                        backend_store=backend_store,
+                        backend_store_size=backend_store_size)
 
     lp.set("workgroup", ctx.domain_name)
     logger.info("workgroup is %s" % ctx.domain_name)
@@ -1543,12 +1552,14 @@ def join_DC(logger=None, server=None, creds=None, lp=None, site=None, netbios_na
 
 def join_clone(logger=None, server=None, creds=None, lp=None,
                targetdir=None, domain=None, include_secrets=False,
-               dns_backend="NONE", backend_store=None):
+               dns_backend="NONE", backend_store=None,
+               backend_store_size=None):
     """Creates a local clone of a remote DC."""
     ctx = DCCloneContext(logger, server, creds, lp, targetdir=targetdir,
                          domain=domain, dns_backend=dns_backend,
                          include_secrets=include_secrets,
-                         backend_store=backend_store)
+                         backend_store=backend_store,
+                         backend_store_size=backend_store_size)
 
     lp.set("workgroup", ctx.domain_name)
     logger.info("workgroup is %s" % ctx.domain_name)
@@ -1565,12 +1576,13 @@ def join_subdomain(logger=None, server=None, creds=None, lp=None, site=None,
                    netbios_name=None, targetdir=None, parent_domain=None, dnsdomain=None,
                    netbios_domain=None, machinepass=None, adminpass=None, use_ntvfs=False,
                    dns_backend=None, plaintext_secrets=False,
-                   backend_store=None):
+                   backend_store=None, backend_store_size=None):
     """Join as a DC."""
     ctx = DCJoinContext(logger, server, creds, lp, site, netbios_name,
                         targetdir, parent_domain, machinepass, use_ntvfs,
                         dns_backend, plaintext_secrets,
-                        backend_store=backend_store)
+                        backend_store=backend_store,
+                        backend_store_size=backend_store_size)
     ctx.subdomain = True
     if adminpass is None:
         ctx.adminpass = samba.generate_random_password(12, 32)
@@ -1621,11 +1633,13 @@ class DCCloneContext(DCJoinContext):
 
     def __init__(ctx, logger=None, server=None, creds=None, lp=None,
                  targetdir=None, domain=None, dns_backend=None,
-                 include_secrets=False, backend_store=None):
+                 include_secrets=False, backend_store=None,
+                 backend_store_size=None):
         super(DCCloneContext, ctx).__init__(logger, server, creds, lp,
                                             targetdir=targetdir, domain=domain,
                                             dns_backend=dns_backend,
-                                            backend_store=backend_store)
+                                            backend_store=backend_store,
+                                            backend_store_size=backend_store_size)
 
         # As we don't want to create or delete these DNs, we set them to None
         ctx.server_dn = None
diff --git a/python/samba/netcmd/__init__.py b/python/samba/netcmd/__init__.py
index 54e9107005a..57df46343e9 100644
--- a/python/samba/netcmd/__init__.py
+++ b/python/samba/netcmd/__init__.py
@@ -19,6 +19,7 @@
 import optparse
 import samba
 from samba import colour
+from samba.getopt import SambaOption
 from samba.logger import get_samba_logger
 from ldb import LdbError
 import sys
@@ -26,7 +27,7 @@ import traceback
 import textwrap
 
 
-class Option(optparse.Option):
+class Option(SambaOption):
     SUPPRESS_HELP = optparse.SUPPRESS_HELP
     pass
 
diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py
index 1835de74230..66027b26d26 100644
--- a/python/samba/netcmd/domain.py
+++ b/python/samba/netcmd/domain.py
@@ -118,6 +118,9 @@ common_provision_join_options = [
            choices=["tdb", "mdb"],
            help="Specify the database backend to be used "
            "(default is %s)" % get_default_backend_store()),
+    Option("--backend-store-size", type="bytes", metavar="SIZE",
+           help="Specify the size of the backend database, currently only " +
+                "supported by lmdb backends (default is 8 Gb)."),
     Option("--targetdir", metavar="DIR",
            help="Set target directory (where to store provision)", type=str),
     Option("-q", "--quiet", help="Be quiet", action="store_true"),
@@ -364,7 +367,8 @@ class cmd_domain_provision(Command):
             ldap_dryrun_mode=None,
             base_schema=None,
             plaintext_secrets=False,
-            backend_store=None):


-- 
Samba Shared Repository



More information about the samba-cvs mailing list