summaryrefslogtreecommitdiff
path: root/source3/winbindd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/winbindd')
-rw-r--r--source3/winbindd/idmap_autorid_tdb.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/source3/winbindd/idmap_autorid_tdb.c b/source3/winbindd/idmap_autorid_tdb.c
index 64c108520c..29d3a4dc01 100644
--- a/source3/winbindd/idmap_autorid_tdb.c
+++ b/source3/winbindd/idmap_autorid_tdb.c
@@ -261,12 +261,33 @@ NTSTATUS idmap_autorid_getconfigstr(struct db_context *db, TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
+bool idmap_autorid_parse_configstr(const char *configstr,
+ struct autorid_global_config *cfg)
+{
+ unsigned long minvalue, rangesize, maxranges;
+
+ if (sscanf(configstr,
+ "minvalue:%lu rangesize:%lu maxranges:%lu",
+ &minvalue, &rangesize, &maxranges) != 3) {
+ DEBUG(1,
+ ("Found invalid configuration data"
+ "creating new config\n"));
+ return false;
+ }
+
+ cfg->minvalue = minvalue;
+ cfg->rangesize = rangesize;
+ cfg->maxranges = maxranges;
+
+ return true;
+}
+
struct autorid_global_config *idmap_autorid_loadconfig(struct db_context *db,
TALLOC_CTX *mem_ctx)
{
struct autorid_global_config *cfg;
- unsigned long minvalue, rangesize, maxranges;
NTSTATUS status;
+ bool ok;
char *configstr = NULL;
status = idmap_autorid_getconfigstr(db, mem_ctx, &configstr);
@@ -279,19 +300,12 @@ struct autorid_global_config *idmap_autorid_loadconfig(struct db_context *db,
return NULL;
}
- if (sscanf(configstr,
- "minvalue:%lu rangesize:%lu maxranges:%lu",
- &minvalue, &rangesize, &maxranges) != 3) {
- DEBUG(1,
- ("Found invalid configuration data"
- "creating new config\n"));
+ ok = idmap_autorid_parse_configstr(configstr, cfg);
+ if (!ok) {
+ talloc_free(cfg);
return NULL;
}
- cfg->minvalue = minvalue;
- cfg->rangesize = rangesize;
- cfg->maxranges = maxranges;
-
DEBUG(10, ("Loaded previously stored configuration "
"minvalue:%d rangesize:%d\n",
cfg->minvalue, cfg->rangesize));