diff options
-rw-r--r-- | server/confdb/confdb.c | 51 | ||||
-rw-r--r-- | server/confdb/confdb.h | 4 |
2 files changed, 46 insertions, 9 deletions
diff --git a/server/confdb/confdb.c b/server/confdb/confdb.c index 95df0367b..72967d204 100644 --- a/server/confdb/confdb.c +++ b/server/confdb/confdb.c @@ -371,6 +371,48 @@ int confdb_get_int(struct confdb_ctx *cdb, TALLOC_CTX *ctx, return EOK; } +int confdb_get_bool(struct confdb_ctx *cdb, TALLOC_CTX *ctx, + const char *section, const char *attribute, + bool defval, bool *result) +{ + char **values; + bool val; + int ret; + + ret = confdb_get_param(cdb, ctx, section, attribute, &values); + if (ret != EOK) { + return ret; + } + + if (values[0]) { + if (values[1] != NULL) { + /* too many values */ + talloc_free(values); + return EINVAL; + } + + if (strcasecmp(values[0], "FALSE") == 0) { + val = false; + + } else if (strcasecmp(values[0], "TRUE") == 0) { + val = true; + + } else { + + DEBUG(2, ("Value is not a boolean!\n")); + return EINVAL; + } + + } else { + val = defval; + } + + talloc_free(values); + + *result = val; + return EOK; +} + static int confdb_test(struct confdb_ctx *cdb) { char **values; @@ -514,15 +556,6 @@ static int confdb_init_db(struct confdb_ctx *cdb) ret = confdb_add_param(cdb, false, "config/domains/LOCAL", "description", val); if (ret != EOK) goto done; - val[0] = "local"; - ret = confdb_add_param(cdb, false, "config/domains/LOCAL", "provider", val); - if (ret != EOK) goto done; - - val[0] = "cn=local,dc=sysdb"; - ret = confdb_add_param(cdb, false, "config/domains/LOCAL", "basedn", val); - if (ret != EOK) goto done; - - done: talloc_free(tmp_ctx); return ret; diff --git a/server/confdb/confdb.h b/server/confdb/confdb.h index d117d0430..57da19675 100644 --- a/server/confdb/confdb.h +++ b/server/confdb/confdb.h @@ -44,6 +44,10 @@ int confdb_get_int(struct confdb_ctx *cdb, TALLOC_CTX *ctx, const char *section, const char *attribute, int defval, int *result); +int confdb_get_bool(struct confdb_ctx *cdb, TALLOC_CTX *ctx, + const char *section, const char *attribute, + bool defval, bool *result); + int confdb_init(TALLOC_CTX *mem_ctx, struct event_context *ev, struct confdb_ctx **cdb_ctx, |