diff options
author | Stefan Metzmacher <metze@samba.org> | 2017-01-19 04:29:13 +0100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2017-02-24 03:59:01 +0100 |
commit | a2daa664ccd284b8894e67ed307a0bd761eb82db (patch) | |
tree | c53beee1bb0952e535f503d4478f657cfcb67e7e | |
parent | fcf5e5a9b80fe6bbe912fb114cc0ea58db8e55b3 (diff) | |
download | samba-a2daa664ccd284b8894e67ed307a0bd761eb82db.tar.gz |
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@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Feb 24 03:59:01 CET 2017 on sn-devel-144
-rw-r--r-- | lib/ldb/tools/cmdline.c | 30 | ||||
-rw-r--r-- | lib/ldb/tools/cmdline.h | 3 | ||||
-rw-r--r-- | 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 6d0a40643df..8baa1208717 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 416bf51d228..9af0ea168b7 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 a030a5abda6..5eae6242a99 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 && |