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
*/
#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
*/
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;
}
}
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;