[Patches] Some misc ones... (ldbsearch and wscript cleanup)

Stefan Metzmacher metze at samba.org
Wed Feb 22 22:20:19 UTC 2017


Hi,

here're two little patches for master.

Similar to
bed19f3 Garming Sam Mon Jan 30 11:08:07 2017 +1300 ldbedit: Prevent the
use of the reveal internals control
we should not use the --show-binary option for ldb tools except ldbsearch,
as it's dangerous when using it in ldbedit.

The other one is trivial...

Please review and push:-)

Thanks!
metze
-------------- next part --------------
From ef304108a0e6bf986af5117410fda4b8f2123c85 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Wed, 22 Feb 2017 07:26:33 +0100
Subject: [PATCH 1/2] s3:wscript_build: remove unused
 bld.RECURSE('lib/pthreadpool')

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/wscript_build | 1 -
 1 file changed, 1 deletion(-)

diff --git a/source3/wscript_build b/source3/wscript_build
index 9903624..74f87bb 100644
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -1341,7 +1341,6 @@ bld.SAMBA3_BINARY('spotlight2sparql',
 
 bld.RECURSE('auth')
 bld.RECURSE('libgpo/gpext')
-bld.RECURSE('lib/pthreadpool')
 bld.RECURSE('librpc')
 bld.RECURSE('librpc/idl')
 bld.RECURSE('libsmb')
-- 
1.9.1


From 881d569d5e2e781e12080c06aaeba7a299cf67ab Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Thu, 19 Jan 2017 04:29:13 +0100
Subject: [PATCH 2/2] ldb/tools: only use LDB_FLG_SHOW_BINARY for 'ldbsearch'

--show-binary is only useful for ldbseach in all other cases
it will destroy data.

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 lib/ldb/tools/cmdline.c   | 30 ++++++++++++++++++++++++++----
 lib/ldb/tools/cmdline.h   |  3 +++
 lib/ldb/tools/ldbsearch.c |  2 +-
 3 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/lib/ldb/tools/cmdline.c b/lib/ldb/tools/cmdline.c
index 6d0a406..8baa120 100644
--- a/lib/ldb/tools/cmdline.c
+++ b/lib/ldb/tools/cmdline.c
@@ -93,9 +93,10 @@ static bool add_control(TALLOC_CTX *mem_ctx, const char *control)
 /**
   process command line options
 */
-struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, 
+static struct ldb_cmdline *ldb_cmdline_process_internal(struct ldb_context *ldb,
 					int argc, const char **argv,
-					void (*usage)(struct ldb_context *))
+					void (*usage)(struct ldb_context *),
+					bool search)
 {
 	struct ldb_cmdline *ret=NULL;
 	poptContext pc;
@@ -278,8 +279,15 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb,
 		flags |= LDB_FLG_NOSYNC;
 	}
 
-	if (options.show_binary) {
-		flags |= LDB_FLG_SHOW_BINARY;
+	if (search) {
+		/*
+		 * For now we're not adding LDB_FLG_RDONLY,
+		 * as that would result in no tdb locking.
+		 */
+
+		if (options.show_binary) {
+			flags |= LDB_FLG_SHOW_BINARY;
+		}
 	}
 
 	if (options.tracing) {
@@ -317,6 +325,20 @@ failed:
 	return NULL;
 }
 
+struct ldb_cmdline *ldb_cmdline_process_search(struct ldb_context *ldb,
+					       int argc, const char **argv,
+					       void (*usage)(struct ldb_context *))
+{
+	return ldb_cmdline_process_internal(ldb, argc, argv, usage, true);
+}
+
+struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb,
+					int argc, const char **argv,
+					void (*usage)(struct ldb_context *))
+{
+	return ldb_cmdline_process_internal(ldb, argc, argv, usage, false);
+}
+
 /* this function check controls reply and determines if more
  * processing is needed setting up the request controls correctly
  *
diff --git a/lib/ldb/tools/cmdline.h b/lib/ldb/tools/cmdline.h
index 416bf51..9af0ea1 100644
--- a/lib/ldb/tools/cmdline.h
+++ b/lib/ldb/tools/cmdline.h
@@ -46,6 +46,9 @@ struct ldb_cmdline {
 	int tracing;
 };
 
+struct ldb_cmdline *ldb_cmdline_process_search(struct ldb_context *ldb,
+					       int argc, const char **argv,
+					       void (*usage)(struct ldb_context *));
 struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc,
 					const char **argv,
 					void (*usage)(struct ldb_context *));
diff --git a/lib/ldb/tools/ldbsearch.c b/lib/ldb/tools/ldbsearch.c
index a030a5a..5eae624 100644
--- a/lib/ldb/tools/ldbsearch.c
+++ b/lib/ldb/tools/ldbsearch.c
@@ -300,7 +300,7 @@ int main(int argc, const char **argv)
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
-	options = ldb_cmdline_process(ldb, argc, argv, usage);
+	options = ldb_cmdline_process_search(ldb, argc, argv, usage);
 
 	/* the check for '=' is for compatibility with ldapsearch */
 	if (!options->interactive &&
-- 
1.9.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20170222/f1321412/signature.sig>


More information about the samba-technical mailing list