diff options
author | Stefan Metzmacher <metze@samba.org> | 2017-02-24 15:34:33 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2017-03-09 16:02:21 +0100 |
commit | 35f92b82b5e919a2736aec8560ea9c4c7dc4bb7a (patch) | |
tree | 73edfc034636216835e469ead76bed379125011c /lib | |
parent | 825180bcd226ea9223de2c992a84895fd3e53902 (diff) | |
download | samba-35f92b82b5e919a2736aec8560ea9c4c7dc4bb7a.tar.gz |
ldb: add LDB_FLG_DONT_CREATE_DB
This avoids creating an new tdb files on ldbsearch
or other callers which use LDB_FLG_DONT_CREATE_DB.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Mar 9 16:02:21 CET 2017 on sn-devel-144
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ldb/include/ldb.h | 9 | ||||
-rw-r--r-- | lib/ldb/ldb_tdb/ldb_tdb.c | 2 | ||||
-rw-r--r-- | lib/ldb/tools/cmdline.c | 5 |
3 files changed, 12 insertions, 4 deletions
diff --git a/lib/ldb/include/ldb.h b/lib/ldb/include/ldb.h index 397f9946710..afcf9eb6351 100644 --- a/lib/ldb/include/ldb.h +++ b/lib/ldb/include/ldb.h @@ -271,6 +271,15 @@ struct ldb_utf8_fns { */ #define LDB_FLG_ENABLE_TRACING 32 +/** + Flags to tell LDB not to create a new database file: + + Without this flag ldb_tdb (for example) will create a blank file + during an invocation of ldb_connect(), even when the caller only + wanted read operations, for example in ldbsearch. +*/ +#define LDB_FLG_DONT_CREATE_DB 64 + /* structures for ldb_parse_tree handling code */ diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_tdb/ldb_tdb.c index 707d227c2bb..8c4989f6095 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/lib/ldb/ldb_tdb/ldb_tdb.c @@ -1565,6 +1565,8 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, if (flags & LDB_FLG_RDONLY) { open_flags = O_RDONLY; + } else if (flags & LDB_FLG_DONT_CREATE_DB) { + open_flags = O_RDWR; } else { open_flags = O_CREAT | O_RDWR; } diff --git a/lib/ldb/tools/cmdline.c b/lib/ldb/tools/cmdline.c index 8baa1208717..a2fe97ee6b2 100644 --- a/lib/ldb/tools/cmdline.c +++ b/lib/ldb/tools/cmdline.c @@ -280,10 +280,7 @@ static struct ldb_cmdline *ldb_cmdline_process_internal(struct ldb_context *ldb, } if (search) { - /* - * For now we're not adding LDB_FLG_RDONLY, - * as that would result in no tdb locking. - */ + flags |= LDB_FLG_DONT_CREATE_DB; if (options.show_binary) { flags |= LDB_FLG_SHOW_BINARY; |