diff options
-rw-r--r-- | source3/include/idmap_autorid_tdb.h | 5 | ||||
-rw-r--r-- | source3/winbindd/idmap_autorid.c | 9 | ||||
-rw-r--r-- | source3/winbindd/idmap_autorid_tdb.c | 20 |
3 files changed, 24 insertions, 10 deletions
diff --git a/source3/include/idmap_autorid_tdb.h b/source3/include/idmap_autorid_tdb.h index 2702f4cf09..e385f493b6 100644 --- a/source3/include/idmap_autorid_tdb.h +++ b/source3/include/idmap_autorid_tdb.h @@ -63,8 +63,9 @@ NTSTATUS idmap_autorid_db_init(const char *path, TALLOC_CTX *mem_ctx, struct db_context **db); -struct autorid_global_config *idmap_autorid_loadconfig(struct db_context *db, - TALLOC_CTX *ctx); +NTSTATUS idmap_autorid_loadconfig(struct db_context *db, + TALLOC_CTX *ctx, + struct autorid_global_config **result); NTSTATUS idmap_autorid_saveconfig(struct db_context *db, struct autorid_global_config *cfg); diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c index d6fd0b9c56..60ce33c35f 100644 --- a/source3/winbindd/idmap_autorid.c +++ b/source3/winbindd/idmap_autorid.c @@ -665,7 +665,14 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom) config->minvalue, config->rangesize, config->maxranges)); /* read previously stored config and current HWM */ - storedconfig = idmap_autorid_loadconfig(autorid_db, talloc_tos()); + status = idmap_autorid_loadconfig(autorid_db, talloc_tos(), + &storedconfig); + if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { + DEBUG(5, ("No configuration found. Storing initial " + "configuration.\n")); + } else if (!NT_STATUS_IS_OK(status)) { + goto error; + } status = dbwrap_fetch_uint32_bystring(autorid_db, HWM, &hwm); if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/winbindd/idmap_autorid_tdb.c b/source3/winbindd/idmap_autorid_tdb.c index 29d3a4dc01..7ded36f847 100644 --- a/source3/winbindd/idmap_autorid_tdb.c +++ b/source3/winbindd/idmap_autorid_tdb.c @@ -282,36 +282,42 @@ bool idmap_autorid_parse_configstr(const char *configstr, return true; } -struct autorid_global_config *idmap_autorid_loadconfig(struct db_context *db, - TALLOC_CTX *mem_ctx) +NTSTATUS idmap_autorid_loadconfig(struct db_context *db, + TALLOC_CTX *mem_ctx, + struct autorid_global_config **result) { struct autorid_global_config *cfg; NTSTATUS status; bool ok; char *configstr = NULL; + if (result == NULL) { + return NT_STATUS_INVALID_PARAMETER; + } + status = idmap_autorid_getconfigstr(db, mem_ctx, &configstr); if (!NT_STATUS_IS_OK(status)) { - return NULL; + return status; } cfg = talloc_zero(mem_ctx, struct autorid_global_config); - if (!cfg) { - return NULL; + if (cfg == NULL) { + return NT_STATUS_NO_MEMORY; } ok = idmap_autorid_parse_configstr(configstr, cfg); if (!ok) { talloc_free(cfg); - return NULL; + return NT_STATUS_INVALID_PARAMETER; } DEBUG(10, ("Loaded previously stored configuration " "minvalue:%d rangesize:%d\n", cfg->minvalue, cfg->rangesize)); - return cfg; + *result = cfg; + return NT_STATUS_OK; } NTSTATUS idmap_autorid_saveconfig(struct db_context *db, |