s3: Add a "lock_order" argument to db_open
authorVolker Lendecke <vl@samba.org>
Fri, 6 Jan 2012 16:19:54 +0000 (17:19 +0100)
committerVolker Lendecke <vlendec@samba.org>
Wed, 18 Jan 2012 13:48:04 +0000 (14:48 +0100)
This will be used to enforce a lock hierarchy between the databases. We have
seen deadlocks between locking.tdb, brlock.tdb, serverid.tdb and notify*.tdb.
These should be fixed by refusing a dbwrap_fetch_locked that does not follow a
defined lock hierarchy.

30 files changed:
source3/groupdb/mapping_tdb.c
source3/lib/conn_tdb.c
source3/lib/dbwrap/dbwrap_open.c
source3/lib/dbwrap/dbwrap_open.h
source3/lib/dbwrap/dbwrap_private.h
source3/lib/g_lock.c
source3/lib/serverid.c
source3/lib/sessionid_tdb.c
source3/lib/sharesec.c
source3/locking/brlock.c
source3/locking/share_mode_lock.c
source3/modules/nfs4_acls.c
source3/modules/vfs_acl_tdb.c
source3/modules/vfs_xattr_tdb.c
source3/passdb/account_pol.c
source3/passdb/pdb_tdb.c
source3/passdb/secrets.c
source3/printing/printer_list.c
source3/registry/reg_backend_db.c
source3/smbd/notify_internal.c
source3/torture/torture.c
source3/utils/dbwrap_tool.c
source3/utils/dbwrap_torture.c
source3/utils/net_idmap.c
source3/utils/net_idmap_check.c
source3/utils/net_registry_check.c
source3/utils/status.c
source3/winbindd/idmap_autorid.c
source3/winbindd/idmap_tdb.c
source3/winbindd/idmap_tdb2.c

index 1dea9e482e5826ce26bf51940abd547ef8d00b08..088874ff350c2278cdb175a1bc5b45bf14e00b36 100644 (file)
@@ -53,7 +53,8 @@ static bool init_group_mapping(void)
        }
 
        db = db_open(NULL, state_path("group_mapping.tdb"), 0,
-                          TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+                    TDB_DEFAULT, O_RDWR|O_CREAT, 0600,
+                    DBWRAP_LOCK_ORDER_1);
        if (db == NULL) {
                DEBUG(0, ("Failed to open group mapping database: %s\n",
                          strerror(errno)));
index f6008714115411ea618c5647e7fcf4ecb92807f3..9b0a07a56c0a453afc486084010862b4674a9fbb 100644 (file)
@@ -36,7 +36,8 @@ static struct db_context *connections_db_ctx(bool rw)
        open_flags = rw ? (O_RDWR|O_CREAT) : O_RDONLY;
 
        db_ctx = db_open(NULL, lock_path("connections.tdb"), 0,
-                        TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH|TDB_DEFAULT, open_flags, 0644);
+                        TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH|TDB_DEFAULT,
+                        open_flags, 0644, DBWRAP_LOCK_ORDER_1);
        return db_ctx;
 }
 
index 6b8be2de16c6ba9a0654eed5cfdd563ceb2d7bb9..23d299511b4e245e4c1a73acbb1a3e52a87a96dc 100644 (file)
@@ -62,11 +62,26 @@ bool db_is_local(const char *name)
 struct db_context *db_open(TALLOC_CTX *mem_ctx,
                           const char *name,
                           int hash_size, int tdb_flags,
-                          int open_flags, mode_t mode)
+                          int open_flags, mode_t mode,
+                          enum dbwrap_lock_order lock_order)
 {
        struct db_context *result = NULL;
 #ifdef CLUSTER_SUPPORT
-       const char *sockname = lp_ctdbd_socket();
+       const char *sockname;
+#endif
+
+       if ((lock_order != DBWRAP_LOCK_ORDER_1) &&
+           (lock_order != DBWRAP_LOCK_ORDER_2)) {
+               /*
+                * Only allow 2 levels. ctdb gives us 3, and we will
+                * have the watchers database soon.
+                */
+               errno = EINVAL;
+               return NULL;
+       }
+
+#ifdef CLUSTER_SUPPORT
+       sockname = lp_ctdbd_socket();
 
        if(!sockname || !*sockname) {
                sockname = CTDB_PATH;
index 5a172a4a2a374d7a1162a1335859122ef32db7f0..2763ef2adeb6ac6fb4475103e99adf5465657a70 100644 (file)
@@ -29,6 +29,11 @@ struct db_context;
  */
 bool db_is_local(const char *name);
 
+enum dbwrap_lock_order {
+       DBWRAP_LOCK_ORDER_1 = 1,
+       DBWRAP_LOCK_ORDER_2 = 2
+};
+
 /**
  * Convenience function that will determine whether to
  * open a tdb database via the tdb backend or via the ctdb
@@ -38,6 +43,7 @@ bool db_is_local(const char *name);
 struct db_context *db_open(TALLOC_CTX *mem_ctx,
                           const char *name,
                           int hash_size, int tdb_flags,
-                          int open_flags, mode_t mode);
+                          int open_flags, mode_t mode,
+                          enum dbwrap_lock_order lock_order);
 
 #endif /* __DBWRAP_OPEN_H__ */
index 4806618543bc6e0dfef64fe6ed1fc81dc682e8ee..d0b32793684296b179a90aca1db3a00e33bd12cd 100644 (file)
@@ -23,6 +23,8 @@
 #ifndef __DBWRAP_PRIVATE_H__
 #define __DBWRAP_PRIVATE_H__
 
+#include "dbwrap/dbwrap_open.h"
+
 struct db_record {
        TDB_DATA key, value;
        NTSTATUS (*store)(struct db_record *rec, TDB_DATA data, int flag);
index 561617023f4a8e9bc698c4cc29a7f9f00058492b..1fd8ae9f387ee8f1d81817e8ae8053034e1337f5 100644 (file)
@@ -60,7 +60,8 @@ struct g_lock_ctx *g_lock_ctx_init(TALLOC_CTX *mem_ctx,
 
        result->db = db_open(result, lock_path("g_lock.tdb"), 0,
                             TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
-                            O_RDWR|O_CREAT, 0600);
+                            O_RDWR|O_CREAT, 0600,
+                            DBWRAP_LOCK_ORDER_2);
        if (result->db == NULL) {
                DEBUG(1, ("g_lock_init: Could not open g_lock.tdb\n"));
                TALLOC_FREE(result);
index 6d8a3c004fcb9cffc5e6c20fe1a54bab2a79f68a..6a8083a7a2db3f8debdf8e3ff00f7fc02560a493 100644 (file)
@@ -76,7 +76,8 @@ static struct db_context *serverid_db(void)
                return db;
        }
        db = db_open(NULL, lock_path("serverid.tdb"), 0,
-                    TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT, 0644);
+                    TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
+                    O_RDWR|O_CREAT, 0644, DBWRAP_LOCK_ORDER_2);
        return db;
 }
 
index 6fd3bbc487afd1e78385020032600694898cb715..5782c9a544358594bf27a2c71ac6887bef13d318 100644 (file)
@@ -34,7 +34,8 @@ static struct db_context *session_db_ctx(void)
 
        session_db_ctx_ptr = db_open(NULL, lock_path("sessionid.tdb"), 0,
                                     TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_INCOMPATIBLE_HASH,
-                                    O_RDWR | O_CREAT, 0644);
+                                    O_RDWR | O_CREAT, 0644,
+                                    DBWRAP_LOCK_ORDER_1);
        return session_db_ctx_ptr;
 }
 
index 2c324cf971c920a6c2f963698f05263ae852b7c8..cb8993cc8e19584e47d3b735f7e2972c277a9964 100644 (file)
@@ -148,7 +148,8 @@ bool share_info_db_init(void)
        }
 
        share_db = db_open(NULL, state_path("share_info.tdb"), 0,
-                                TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+                          TDB_DEFAULT, O_RDWR|O_CREAT, 0600,
+                          DBWRAP_LOCK_ORDER_1);
        if (share_db == NULL) {
                DEBUG(0,("Failed to open share info database %s (%s)\n",
                        state_path("share_info.tdb"), strerror(errno) ));
index a33d809286f50785db883ceab39e03d591956f8b..289e5d13c77f7b6290b199ee0ad609df9129c5de 100644 (file)
@@ -290,7 +290,8 @@ void brl_init(bool read_only)
 
        brlock_db = db_open(NULL, lock_path("brlock.tdb"),
                            lp_open_files_db_hash_size(), tdb_flags,
-                           read_only?O_RDONLY:(O_RDWR|O_CREAT), 0644 );
+                           read_only?O_RDONLY:(O_RDWR|O_CREAT), 0644,
+                           DBWRAP_LOCK_ORDER_2);
        if (!brlock_db) {
                DEBUG(0,("Failed to open byte range locking database %s\n",
                        lock_path("brlock.tdb")));
index 002a399af7806b7ad7b24187fc68c67fe1b52fc8..6bc055f70fea626a4d1d2d776eab24c368327a7e 100644 (file)
@@ -65,7 +65,8 @@ static bool locking_init_internal(bool read_only)
        lock_db = db_open(NULL, lock_path("locking.tdb"),
                          lp_open_files_db_hash_size(),
                          TDB_DEFAULT|TDB_VOLATILE|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
-                         read_only?O_RDONLY:O_RDWR|O_CREAT, 0644);
+                         read_only?O_RDONLY:O_RDWR|O_CREAT, 0644,
+                         DBWRAP_LOCK_ORDER_1);
 
        if (!lock_db) {
                DEBUG(0,("ERROR: Failed to initialise locking database\n"));
index b4715af2ed450aefab6efc4895c72bbfba0b8b8d..bd3c7fac72860dc259105355ac0a70b8c2cd2793 100644 (file)
@@ -590,7 +590,8 @@ static bool nfs4_map_sid(smbacl4_vfs_params *params, const struct dom_sid *src,
 
                become_root();
                mapping_db = db_open(NULL, dbname, 0, TDB_DEFAULT,
-                                    O_RDONLY, 0600);
+                                    O_RDONLY, 0600,
+                                    DBWRAP_LOCK_ORDER_1);
                unbecome_root();
 
                if (mapping_db == NULL) {
index 67d0540fef0744f31fc0819f16a310582e10fc37..f68afd88be0bded9950ed9148851b4911e9975df 100644 (file)
@@ -59,7 +59,8 @@ static bool acl_tdb_init(void)
        }
 
        become_root();
-       acl_db = db_open(NULL, dbname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+       acl_db = db_open(NULL, dbname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600,
+                        DBWRAP_LOCK_ORDER_1);
        unbecome_root();
 
        if (acl_db == NULL) {
index 8f367f359a7783d63ab44362d92fd0c98d04de8e..f00caa4ea7b41cf82f3857c9375672da222e7675 100644 (file)
@@ -601,7 +601,8 @@ static bool xattr_tdb_init(int snum, struct db_context **p_db)
        /* now we know dbname is not NULL */
 
        become_root();
-       db = db_open(NULL, dbname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+       db = db_open(NULL, dbname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600,
+                    DBWRAP_LOCK_ORDER_2);
        unbecome_root();
 
        if (db == NULL) {
index a32d07517d49ebeb637198b9ef7808c158a95cd6..4cb185c49479bd60e53cfffcd6b7e58fb60628fd 100644 (file)
@@ -220,12 +220,13 @@ bool init_account_policy(void)
        }
 
        db = db_open(NULL, state_path("account_policy.tdb"), 0, TDB_DEFAULT,
-                    O_RDWR, 0600);
+                    O_RDWR, 0600, DBWRAP_LOCK_ORDER_1);
 
        if (db == NULL) { /* the account policies files does not exist or open
                           * failed, try to create a new one */
                db = db_open(NULL, state_path("account_policy.tdb"), 0,
-                            TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+                            TDB_DEFAULT, O_RDWR|O_CREAT, 0600,
+                            DBWRAP_LOCK_ORDER_1);
                if (db == NULL) {
                        DEBUG(0,("Failed to open account policy database\n"));
                        return False;
index 01c0def57fab97679bc23aadcd715aa3b66fe76f..a090fcd5bb4722d1304f43ec075a92ef69c2f237 100644 (file)
@@ -224,7 +224,8 @@ static bool tdbsam_convert_backup(const char *dbname, struct db_context **pp_db)
         * it to stay around after we return from here. */
 
        tmp_db = db_open(NULL, tmp_fname, 0,
-                               TDB_DEFAULT, O_CREAT|O_RDWR, 0600);
+                        TDB_DEFAULT, O_CREAT|O_RDWR, 0600,
+                        DBWRAP_LOCK_ORDER_1);
        if (tmp_db == NULL) {
                DEBUG(0, ("tdbsam_convert_backup: Failed to create backup TDB passwd "
                          "[%s]\n", tmp_fname));
@@ -290,7 +291,8 @@ static bool tdbsam_convert_backup(const char *dbname, struct db_context **pp_db)
        /* re-open the converted TDB */
 
        orig_db = db_open(NULL, dbname, 0,
-                         TDB_DEFAULT, O_CREAT|O_RDWR, 0600);
+                         TDB_DEFAULT, O_CREAT|O_RDWR, 0600,
+                         DBWRAP_LOCK_ORDER_1);
        if (orig_db == NULL) {
                DEBUG(0, ("tdbsam_convert_backup: Failed to re-open "
                          "converted passdb TDB [%s]\n", dbname));
@@ -440,7 +442,8 @@ static bool tdbsam_open( const char *name )
 
        /* Try to open tdb passwd.  Create a new one if necessary */
 
-       db_sam = db_open(NULL, name, 0, TDB_DEFAULT, O_CREAT|O_RDWR, 0600);
+       db_sam = db_open(NULL, name, 0, TDB_DEFAULT, O_CREAT|O_RDWR, 0600,
+                        DBWRAP_LOCK_ORDER_1);
        if (db_sam == NULL) {
                DEBUG(0, ("tdbsam_open: Failed to open/create TDB passwd "
                          "[%s]\n", name));
index e40095d2af35e1fbd57f99e623c400fb43a7b9e7..bd6be353cd2332eeb8d37e66518a6cd244689036 100644 (file)
@@ -75,7 +75,8 @@ bool secrets_init_path(const char *private_dir)
        }
 
        db_ctx = db_open(NULL, fname, 0,
-                        TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+                        TDB_DEFAULT, O_RDWR|O_CREAT, 0600,
+                        DBWRAP_LOCK_ORDER_1);
 
        if (db_ctx == NULL) {
                DEBUG(0,("Failed to open %s\n", fname));
index 4b76ca50f43f8134163ea45a815f6e8b82a47dc5..d9e8737660613beaee9293d4b83e8b14676ac357 100644 (file)
@@ -40,7 +40,7 @@ static struct db_context *get_printer_list_db(void)
        }
        db = db_open(NULL, PL_DB_NAME(), 0,
                     TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
-                    O_RDWR|O_CREAT, 0644);
+                    O_RDWR|O_CREAT, 0644, DBWRAP_LOCK_ORDER_1);
        return db;
 }
 
index 378b20fc26eb04270400d49d5062e927f74ffdd5..0245f4ca109b9de46bf9a953a5b1ca4ab3a3866f 100644 (file)
@@ -727,10 +727,12 @@ WERROR regdb_init(void)
        }
 
        regdb = db_open(NULL, state_path("registry.tdb"), 0,
-                             REG_TDB_FLAGS, O_RDWR, 0600);
+                       REG_TDB_FLAGS, O_RDWR, 0600,
+                       DBWRAP_LOCK_ORDER_1);
        if (!regdb) {
                regdb = db_open(NULL, state_path("registry.tdb"), 0,
-                                     REG_TDB_FLAGS, O_RDWR|O_CREAT, 0600);
+                               REG_TDB_FLAGS, O_RDWR|O_CREAT, 0600,
+                               DBWRAP_LOCK_ORDER_1);
                if (!regdb) {
                        werr = ntstatus_to_werror(map_nt_error_from_unix(errno));
                        DEBUG(1,("regdb_init: Failed to open registry %s (%s)\n",
@@ -844,7 +846,8 @@ WERROR regdb_open( void )
        become_root();
 
        regdb = db_open(NULL, state_path("registry.tdb"), 0,
-                             REG_TDB_FLAGS, O_RDWR, 0600);
+                       REG_TDB_FLAGS, O_RDWR, 0600,
+                       DBWRAP_LOCK_ORDER_1);
        if ( !regdb ) {
                result = ntstatus_to_werror( map_nt_error_from_unix( errno ) );
                DEBUG(0,("regdb_open: Failed to open %s! (%s)\n",
index 484a31c5be8a287f051781c7a33ea08839149434..be91cd58cdb447c165ee1af7654322a5876c8c7f 100644 (file)
@@ -102,7 +102,8 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
 
        notify->db_recursive = db_open(notify, lock_path("notify.tdb"),
                                       0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
-                                      O_RDWR|O_CREAT, 0644);
+                                      O_RDWR|O_CREAT, 0644,
+                                      DBWRAP_LOCK_ORDER_2);
        if (notify->db_recursive == NULL) {
                talloc_free(notify);
                return NULL;
@@ -110,7 +111,8 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
 
        notify->db_onelevel = db_open(notify, lock_path("notify_onelevel.tdb"),
                                      0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
-                                     O_RDWR|O_CREAT, 0644);
+                                     O_RDWR|O_CREAT, 0644,
+                                     DBWRAP_LOCK_ORDER_2);
        if (notify->db_onelevel == NULL) {
                talloc_free(notify);
                return NULL;
index 3b023e732944f7f9f988c96b0773f81e694c0acd..e4ce91338ff0bdc682fe8e528c11f0941904a639 100644 (file)
@@ -8561,7 +8561,7 @@ static bool run_local_dbtrans(int dummy)
        TDB_DATA value;
 
        db = db_open(talloc_tos(), "transtest.tdb", 0, TDB_DEFAULT,
-                    O_RDWR|O_CREAT, 0600);
+                    O_RDWR|O_CREAT, 0600, DBWRAP_LOCK_ORDER_1);
        if (db == NULL) {
                printf("Could not open transtest.db\n");
                return false;
index 7850dc168e33b02c79dbc17c5e4996ebb5e6a5ea..e178d5cc6eea767b5844e92675edd3db60a4720e 100644 (file)
@@ -463,7 +463,8 @@ int main(int argc, const char **argv)
                goto done;
        }
 
-       db = db_open(mem_ctx, dbname, 0, TDB_DEFAULT, O_RDWR | O_CREAT, 0644);
+       db = db_open(mem_ctx, dbname, 0, TDB_DEFAULT, O_RDWR | O_CREAT, 0644,
+                    DBWRAP_LOCK_ORDER_1);
        if (db == NULL) {
                d_fprintf(stderr, "ERROR: could not open dbname\n");
                goto done;
index 9907f31f7672040290def5f047e889e1135f8202..fb4ed6d4ec1bdfa03775a248faadf7148c899ae6 100644 (file)
@@ -308,7 +308,8 @@ int main(int argc, const char *argv[])
                tdb_flags |= TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH;
        }
 
-       db = db_open(mem_ctx, db_name, 0, tdb_flags,  O_RDWR | O_CREAT, 0644);
+       db = db_open(mem_ctx, db_name, 0, tdb_flags,  O_RDWR | O_CREAT, 0644,
+                    DBWRAP_LOCK_ORDER_1);
 
        if (db == NULL) {
                d_fprintf(stderr, "failed to open db '%s': %s\n", db_name,
index 3a3ae21f07323096da901633fd38abaa16b35804..22734eecd810b5e5584763cfc5d126868ab7ba5e 100644 (file)
@@ -131,7 +131,8 @@ static int net_idmap_dump(struct net_context *c, int argc, const char **argv)
        }
        d_fprintf(stderr, _("dumping id mapping from %s\n"), dbfile);
 
-       db = db_open(mem_ctx, dbfile, 0, TDB_DEFAULT, O_RDONLY, 0);
+       db = db_open(mem_ctx, dbfile, 0, TDB_DEFAULT, O_RDONLY, 0,
+                    DBWRAP_LOCK_ORDER_1);
        if (db == NULL) {
                d_fprintf(stderr, _("Could not open idmap db (%s): %s\n"),
                          dbfile, strerror(errno));
@@ -240,7 +241,8 @@ static int net_idmap_restore(struct net_context *c, int argc, const char **argv)
                input = stdin;
        }
 
-       db = db_open(mem_ctx, dbfile, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0644);
+       db = db_open(mem_ctx, dbfile, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0644,
+                    DBWRAP_LOCK_ORDER_1);
        if (db == NULL) {
                d_fprintf(stderr, _("Could not open idmap db (%s): %s\n"),
                          dbfile, strerror(errno));
@@ -444,7 +446,8 @@ static int net_idmap_delete(struct net_context *c, int argc, const char **argv)
        }
        d_fprintf(stderr, _("deleting id mapping from %s\n"), dbfile);
 
-       db = db_open(mem_ctx, dbfile, 0, TDB_DEFAULT, O_RDWR, 0);
+       db = db_open(mem_ctx, dbfile, 0, TDB_DEFAULT, O_RDWR, 0,
+                    DBWRAP_LOCK_ORDER_1);
        if (db == NULL) {
                d_fprintf(stderr, _("Could not open idmap db (%s): %s\n"),
                          dbfile, strerror(errno));
@@ -616,7 +619,8 @@ static int net_idmap_aclmapset(struct net_context *c, int argc, const char **arg
        }
 
        if (!(db = db_open(mem_ctx, argv[0], 0, TDB_DEFAULT,
-                          O_RDWR|O_CREAT, 0600))) {
+                          O_RDWR|O_CREAT, 0600,
+                          DBWRAP_LOCK_ORDER_1))) {
                d_fprintf(stderr, _("db_open failed: %s\n"), strerror(errno));
                goto fail;
        }
index 3f9f3f53d96d32f685064c61c7a8c165c34050b2..1269410beeca664ce132a77f96762269e277dc34 100644 (file)
@@ -804,7 +804,8 @@ static bool check_open_db(struct check_ctx* ctx, const char* name, int oflags)
                }
        }
 
-       ctx->db = db_open(ctx, name, 0, TDB_DEFAULT, oflags, 0);
+       ctx->db = db_open(ctx, name, 0, TDB_DEFAULT, oflags, 0,
+                         DBWRAP_LOCK_ORDER_1);
        if (ctx->db == NULL) {
                d_fprintf(stderr,
                          _("Could not open idmap db (%s) for writing: %s\n"),
index 201dc5ebc16aaf47382e3243b5dde65f0d6ea3dc..8d1a91c44b3786e512e28be3bddf963f0be6f3b5 100644 (file)
@@ -354,7 +354,8 @@ static bool check_ctx_open_output(struct check_ctx *ctx)
                ctx->opt.wipe = true;
        }
 
-       ctx->odb = db_open(ctx, ctx->opt.output, 0, TDB_DEFAULT, oflags, 0644);
+       ctx->odb = db_open(ctx, ctx->opt.output, 0, TDB_DEFAULT, oflags, 0644,
+                          DBWRAP_LOCK_ORDER_1);
        if (ctx->odb == NULL) {
                d_fprintf(stderr,
                          _("Could not open db (%s) for writing: %s\n"),
@@ -366,7 +367,8 @@ static bool check_ctx_open_output(struct check_ctx *ctx)
 
 
 static bool check_ctx_open_input(struct check_ctx *ctx) {
-       ctx->idb = db_open(ctx, ctx->fname, 0, TDB_DEFAULT, O_RDONLY, 0);
+       ctx->idb = db_open(ctx, ctx->fname, 0, TDB_DEFAULT, O_RDONLY, 0,
+                          DBWRAP_LOCK_ORDER_1);
        if (ctx->idb == NULL) {
                d_fprintf(stderr,
                          _("Could not open db (%s) for reading: %s\n"),
index 8ae8de76a34b35b32768d1716f50679a0ba4480f..8f8f3945cbf976edd44c215dc4b4bffbbe8c13af 100644 (file)
@@ -455,7 +455,8 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
                int result;
                struct db_context *db;
                db = db_open(NULL, lock_path("locking.tdb"), 0,
-                            TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDONLY, 0);
+                            TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDONLY, 0,
+                            DBWRAP_LOCK_ORDER_1);
 
                if (!db) {
                        d_printf("%s not initialised\n",
index 6a39816268d82f73b6228b827d987f114334ade1..9048c126b5b28640aafaf17827c19baeb3c9d86a 100644 (file)
@@ -405,7 +405,8 @@ static NTSTATUS idmap_autorid_db_init(void)
 
        /* Open idmap repository */
        autorid_db = db_open(NULL, state_path("autorid.tdb"), 0,
-                            TDB_DEFAULT, O_RDWR | O_CREAT, 0644);
+                            TDB_DEFAULT, O_RDWR | O_CREAT, 0644,
+                            DBWRAP_LOCK_ORDER_1);
 
        if (!autorid_db) {
                DEBUG(0, ("Unable to open idmap_autorid database '%s'\n",
index 1d1ba64c21e869b7d25c7d82500e4b470f0f31ba..fa52baed8d7bb5a171b797580c74aaaacf023366 100644 (file)
@@ -338,7 +338,8 @@ static NTSTATUS idmap_tdb_open_db(struct idmap_domain *dom)
        DEBUG(10,("Opening tdbfile %s\n", tdbfile ));
 
        /* Open idmap repository */
-       db = db_open(mem_ctx, tdbfile, 0, TDB_DEFAULT, O_RDWR | O_CREAT, 0644);
+       db = db_open(mem_ctx, tdbfile, 0, TDB_DEFAULT, O_RDWR | O_CREAT, 0644,
+                    DBWRAP_LOCK_ORDER_1);
        if (!db) {
                DEBUG(0, ("Unable to open idmap database\n"));
                ret = NT_STATUS_UNSUCCESSFUL;
index ac3743e523ed19fab4723d6dc285eab6927f6cb1..7098da1ed775289241950152b55ea115429bbd18 100644 (file)
@@ -113,7 +113,8 @@ static NTSTATUS idmap_tdb2_open_db(struct idmap_domain *dom)
        NT_STATUS_HAVE_NO_MEMORY(db_path);
 
        /* Open idmap repository */
-       ctx->db = db_open(ctx, db_path, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0644);
+       ctx->db = db_open(ctx, db_path, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0644,
+                         DBWRAP_LOCK_ORDER_1);
        TALLOC_FREE(db_path);
 
        if (ctx->db == NULL) {