summaryrefslogtreecommitdiffstats
path: root/server/confdb/confdb.c
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-03-04 23:05:54 -0500
committerSimo Sorce <ssorce@redhat.com>2009-03-04 23:05:54 -0500
commitf9f42495c5ab22e17f7e59bd2df3f9353301d8b8 (patch)
treef002e47c49a1a5a3fac6bdf22d265588bf6f52ad /server/confdb/confdb.c
parenteb4f8ab8ddd78e3b2efc6130509f035001154ba3 (diff)
downloadsssd-f9f42495c5ab22e17f7e59bd2df3f9353301d8b8.tar.gz
sssd-f9f42495c5ab22e17f7e59bd2df3f9353301d8b8.tar.xz
sssd-f9f42495c5ab22e17f7e59bd2df3f9353301d8b8.zip
Add internal min/max/next id management fucntions
Retrieve minID and maxID from domain configuration so that lower and upper bounds can be set per domain. Add function that keeps track of the next available id, increments and returns it on requests, avoiding collisions with existing ids.
Diffstat (limited to 'server/confdb/confdb.c')
-rw-r--r--server/confdb/confdb.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/server/confdb/confdb.c b/server/confdb/confdb.c
index 4c895d5f1..f86df6ca4 100644
--- a/server/confdb/confdb.c
+++ b/server/confdb/confdb.c
@@ -333,7 +333,7 @@ int confdb_get_int(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
int defval, int *result)
{
char **values;
- long int val;
+ long val;
int ret;
ret = confdb_get_param(cdb, ctx, section, attribute, &values);
@@ -370,6 +370,43 @@ int confdb_get_int(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
return EOK;
}
+long confdb_get_long(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
+ const char *section, const char *attribute,
+ long defval, long *result)
+{
+ char **values;
+ long 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;
+ }
+
+ errno = 0;
+ val = strtol(values[0], NULL, 0);
+ if (errno) {
+ talloc_free(values);
+ return errno;
+ }
+
+ } else {
+ val = defval;
+ }
+
+ talloc_free(values);
+
+ *result = val;
+ return EOK;
+}
+
int confdb_get_bool(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
const char *section, const char *attribute,
bool defval, bool *result)
@@ -680,6 +717,11 @@ int confdb_get_domains(struct confdb_ctx *cdb,
domain->legacy = true;
}
+ domain->id_min = ldb_msg_find_attr_as_uint(res->msgs[i],
+ "minId", SSSD_MIN_ID);
+ domain->id_max = ldb_msg_find_attr_as_uint(res->msgs[i],
+ "maxId", 0);
+
ret = btreemap_set_value(mem_ctx, &domain_map,
domain->name, domain,
_domain_comparator);