dbwrap_local_open: never open the .tdb if there is an .ntdb
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 20 Feb 2013 04:29:42 +0000 (14:59 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 20 Feb 2013 04:31:19 +0000 (05:31 +0100)
This provides an extra safety check that everyone is using one or the
other: you can't create a tdb file if there's an ntdb file.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/dbwrap/dbwrap_local_open.c

index 87c7c68418ac7c76a359fd87e23c17845ce38245..c2eb7b73eeb0c1d1d63be5bc87455ba4deb1f13d 100644 (file)
@@ -214,6 +214,11 @@ struct db_context *dbwrap_local_open(TALLOC_CTX *mem_ctx,
                                  ntdb_flags, open_flags, mode, lock_order);
 #endif
        } else {
+               if (!streq(ntdbname, tdbname) && file_exist(ntdbname)) {
+                       DEBUG(0, ("Refusing to open '%s' when '%s' exists\n",
+                                 tdbname, ntdbname));
+                       goto out;
+               }
                db = db_open_tdb(mem_ctx, lp_ctx, tdbname, hash_size,
                                 tdb_flags, open_flags, mode,
                                 lock_order);