autorid: initialize: open the autorid db as late as possible.
authorMichael Adam <obnox@samba.org>
Thu, 20 Mar 2014 23:04:15 +0000 (00:04 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 2 Apr 2014 22:26:28 +0000 (00:26 +0200)
But make sure to link the db context to commonconfig afterwards.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/winbindd/idmap_autorid.c

index e9b5d2ce3c596681d66331412128ed56c0f5eea0..fcfdb2bb1e856dbd1b116d0d353f07249e36aec7 100644 (file)
@@ -613,13 +613,6 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom)
        }
        commonconfig->private_data = config;
 
-       status = idmap_autorid_db_init(state_path("autorid.tdb"),
-                                      NULL, /* TALLOC_CTX */
-                                      &autorid_db);
-       if (!NT_STATUS_IS_OK(status)) {
-               goto error;
-       }
-
        config->minvalue = dom->low_id;
        config->rangesize = lp_parm_int(-1, "idmap config *",
                                        "rangesize", 100000);
@@ -651,13 +644,21 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom)
 
        /* fill the TDB common configuration */
 
-       commonconfig->db = autorid_db;
        commonconfig->max_id = config->rangesize -1;
        commonconfig->hwmkey_uid = ALLOC_HWM_UID;
        commonconfig->hwmkey_gid = ALLOC_HWM_GID;
        commonconfig->rw_ops->get_new_id = idmap_autorid_allocate_id;
        commonconfig->rw_ops->set_mapping = idmap_tdb_common_set_mapping;
 
+       status = idmap_autorid_db_init(state_path("autorid.tdb"),
+                                      NULL, /* TALLOC_CTX */
+                                      &autorid_db);
+       if (!NT_STATUS_IS_OK(status)) {
+               goto error;
+       }
+
+       commonconfig->db = autorid_db;
+
        status = idmap_autorid_saveconfig(autorid_db, config);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1, ("Failed to store configuration data!\n"));