summaryrefslogtreecommitdiff
path: root/server/confdb
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2009-02-20 18:00:05 -0500
committerSimo Sorce <idra@samba.org>2009-02-20 18:10:24 -0500
commit0998732a5621fd94ada7051d4c0fbc456e9befb8 (patch)
tree5310b3814bbf13a4d6d84727bafca52c23e52430 /server/confdb
parentb8f07efe5d98071777e3a2863688c8269a7912e4 (diff)
downloadsssd-0998732a5621fd94ada7051d4c0fbc456e9befb8.tar.gz
sssd-0998732a5621fd94ada7051d4c0fbc456e9befb8.tar.bz2
sssd-0998732a5621fd94ada7051d4c0fbc456e9befb8.zip
Add helper function to get booleans from confdb
Diffstat (limited to 'server/confdb')
-rw-r--r--server/confdb/confdb.c51
-rw-r--r--server/confdb/confdb.h4
2 files changed, 46 insertions, 9 deletions
diff --git a/server/confdb/confdb.c b/server/confdb/confdb.c
index 95df0367..72967d20 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 d117d043..57da1967 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,