diff options
author | Sumit Bose <sbose@redhat.com> | 2013-10-09 15:30:29 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-10-17 13:49:49 +0200 |
commit | ce8fb3255794ea046635f3527cd58fc47ab7218b (patch) | |
tree | dd7b777d063a12e948ec20a4e5f932e3bac4fb4e /src/providers | |
parent | 7e24fd63a6bdbab7b483aa4162deb78b69d1315c (diff) | |
download | sssd-ce8fb3255794ea046635f3527cd58fc47ab7218b.tar.gz sssd-ce8fb3255794ea046635f3527cd58fc47ab7218b.tar.xz sssd-ce8fb3255794ea046635f3527cd58fc47ab7218b.zip |
sdap_idmap: add sdap_idmap_get_configured_external_range()
Diffstat (limited to 'src/providers')
-rw-r--r-- | src/providers/ldap/sdap_idmap.c | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/src/providers/ldap/sdap_idmap.c b/src/providers/ldap/sdap_idmap.c index 667e37749..18e1986ed 100644 --- a/src/providers/ldap/sdap_idmap.c +++ b/src/providers/ldap/sdap_idmap.c @@ -27,12 +27,13 @@ #include "util/util_sss_idmap.h" static errno_t -sdap_idmap_add_configured_external_range(struct sdap_idmap_ctx *idmap_ctx) +sdap_idmap_get_configured_external_range(struct sdap_idmap_ctx *idmap_ctx, + struct sss_idmap_range *range) { int int_id; - struct sss_idmap_range range; struct sdap_id_ctx *id_ctx; - enum idmap_error_code err; + uint32_t min; + uint32_t max; if (idmap_ctx == NULL) { return EINVAL; @@ -45,32 +46,54 @@ sdap_idmap_add_configured_external_range(struct sdap_idmap_ctx *idmap_ctx) DEBUG(SSSDBG_CONF_SETTINGS, ("ldap_min_id must be greater than 0.\n")); return EINVAL; } - range.min = int_id; + min = int_id; int_id = dp_opt_get_int(id_ctx->opts->basic, SDAP_MAX_ID); if (int_id < 0) { - DEBUG(SSSDBG_CONF_SETTINGS, ("ldap_min_id must be greater than 0.\n")); + DEBUG(SSSDBG_CONF_SETTINGS, ("ldap_max_id must be greater than 0.\n")); return EINVAL; } - range.max = int_id; + max = int_id; - if ((range.min == 0 && range.max != 0) - || (range.min != 0 && range.max == 0)) { + if ((min == 0 && max != 0) || (min != 0 && max == 0)) { DEBUG(SSSDBG_CONF_SETTINGS, ("Both ldap_min_id and ldap_max_id " \ "either must be 0 (not set) " \ "or positive integers.\n")); return EINVAL; } - if (range.min == 0 && range.max == 0) { + if (min == 0 && max == 0) { /* ldap_min_id and ldap_max_id not set, using min_id and max_id */ - range.min = id_ctx->be->domain->id_min; - range.max = id_ctx->be->domain->id_max; - if (range.max == 0) { - range.max = UINT32_MAX; + min = id_ctx->be->domain->id_min; + max = id_ctx->be->domain->id_max; + if (max == 0) { + max = UINT32_MAX; } } + range->min = min; + range->max =max; + + return EOK; +} + +static errno_t +sdap_idmap_add_configured_external_range(struct sdap_idmap_ctx *idmap_ctx) +{ + int ret; + struct sss_idmap_range range; + struct sdap_id_ctx *id_ctx; + enum idmap_error_code err; + + ret = sdap_idmap_get_configured_external_range(idmap_ctx, &range); + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, + ("sdap_idmap_get_configured_external_range failed.\n")); + return ret; + } + + id_ctx = idmap_ctx->id_ctx; + err = sss_idmap_add_domain_ex(idmap_ctx->map, id_ctx->be->domain->name, id_ctx->be->domain->domain_id, &range, NULL, 0, true); |