summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2014-03-21 00:18:36 +0100
committerJeremy Allison <jra@samba.org>2014-04-03 02:41:25 +0200
commit5cf6e9c8520be49aa57436bf725521cdc5d160f8 (patch)
tree8715983cb4126c125c92348e592cc9f26b996858 /source3
parentfc987cf289e620358db945b8372aba16cdc0ea8a (diff)
downloadsamba-5cf6e9c8520be49aa57436bf725521cdc5d160f8.tar.gz
autorid: make the whole initialization atomic with one transaction.
Originally, there were several writing operations: - store the range HWM - store the alloc uid HWM - store the alloc gid HWM - store the config - create mappings for a whole list of wellknown sids Each of these consisted of its own transaction, the wellknown preallocation even of one transaction per sid. This change wrapps all of these in one big transaction. Thereby making the whole initialization atomic, and with respect to the creation of the wellknown mappings also more deterministic. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Apr 3 02:41:25 CEST 2014 on sn-devel-104
Diffstat (limited to 'source3')
-rw-r--r--source3/winbindd/idmap_autorid.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c
index 5b4b7ef1e6b..7e17b6634e0 100644
--- a/source3/winbindd/idmap_autorid.c
+++ b/source3/winbindd/idmap_autorid.c
@@ -580,6 +580,39 @@ static NTSTATUS idmap_autorid_preallocate_wellknown(struct idmap_domain *dom)
return NT_STATUS_IS_OK(status)?NT_STATUS_OK:NT_STATUS_UNSUCCESSFUL;
}
+static NTSTATUS idmap_autorid_initialize_action(struct db_context *db,
+ void *private_data)
+{
+ struct idmap_domain *dom;
+ struct idmap_tdb_common_context *common;
+ struct autorid_global_config *config;
+ NTSTATUS status;
+
+ dom = (struct idmap_domain *)private_data;
+ common = (struct idmap_tdb_common_context *)dom->private_data;
+ config = (struct autorid_global_config *)common->private_data;
+
+ status = idmap_autorid_init_hwms(autorid_db);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ status = idmap_autorid_saveconfig(autorid_db, config);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("Failed to store configuration data!\n"));
+ return status;
+ }
+
+ status = idmap_autorid_preallocate_wellknown(dom);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("Failed to preallocate wellknown sids: %s\n",
+ nt_errstr(status)));
+ return status;
+ }
+
+ return NT_STATUS_OK;
+}
+
static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom)
{
struct idmap_tdb_common_context *commonconfig;
@@ -659,20 +692,15 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom)
commonconfig->db = autorid_db;
- status = idmap_autorid_init_hwms(autorid_db);
+ status = dbwrap_trans_do(autorid_db,
+ idmap_autorid_initialize_action,
+ dom);
if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("Failed to init the idmap database: %s\n",
+ nt_errstr(status)));
goto error;
}
- status = idmap_autorid_saveconfig(autorid_db, config);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1, ("Failed to store configuration data!\n"));
- goto error;
- }
-
- /* preallocate well-known SIDs in the pool */
- status = idmap_autorid_preallocate_wellknown(dom);
-
goto done;
error: