diff options
author | Sumit Bose <sbose@redhat.com> | 2013-06-10 12:06:27 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-06-28 18:57:23 +0200 |
commit | 9ef0d43b961c05f1aae2ec21eed4142ae3221bc3 (patch) | |
tree | d2551632b1e5d970f12aae9463f35a3b384d27cb /src/lib | |
parent | 95a08a0c02281b28bd1914e0727b40ae25b4e16a (diff) | |
download | sssd-9ef0d43b961c05f1aae2ec21eed4142ae3221bc3.tar.gz sssd-9ef0d43b961c05f1aae2ec21eed4142ae3221bc3.tar.xz sssd-9ef0d43b961c05f1aae2ec21eed4142ae3221bc3.zip |
idmap: add optional unique range id
To be able to detect configuration changes in idranges managed by
FreeIPA an identifier should be stored on the client together with the
other idrange related data.
Fixes https://fedorahosted.org/sssd/ticket/1979
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/idmap/sss_idmap.c | 15 | ||||
-rw-r--r-- | src/lib/idmap/sss_idmap.h | 3 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/lib/idmap/sss_idmap.c b/src/lib/idmap/sss_idmap.c index 122f62f5b..b04d849ad 100644 --- a/src/lib/idmap/sss_idmap.c +++ b/src/lib/idmap/sss_idmap.c @@ -39,6 +39,7 @@ struct idmap_domain_info { struct sss_idmap_range *range; struct idmap_domain_info *next; uint32_t first_rid; + char *range_id; }; static void *default_alloc(size_t size, void *pvt) @@ -339,6 +340,9 @@ static enum idmap_error_code dom_check_collision( for (dom = dom_list; dom != NULL; dom = dom->next) { + /* TODO: if both ranges have the same ID check if an update is + * needed. */ + /* check if ID ranges overlap */ if ((new_dom->range->min >= dom->range->min && new_dom->range->min <= dom->range->max) @@ -372,6 +376,7 @@ enum idmap_error_code sss_idmap_add_domain_ex(struct sss_idmap_ctx *ctx, const char *domain_name, const char *domain_sid, struct sss_idmap_range *range, + const char *range_id, uint32_t rid) { struct idmap_domain_info *dom = NULL; @@ -412,6 +417,13 @@ enum idmap_error_code sss_idmap_add_domain_ex(struct sss_idmap_ctx *ctx, goto fail; } + if (range_id != NULL) { + dom->range_id = idmap_strdup(ctx, range_id); + if (dom->range_id == NULL) { + goto fail; + } + } + dom->first_rid = rid; err = dom_check_collision(ctx->idmap_domain_info, dom); @@ -438,7 +450,8 @@ enum idmap_error_code sss_idmap_add_domain(struct sss_idmap_ctx *ctx, const char *domain_sid, struct sss_idmap_range *range) { - return sss_idmap_add_domain_ex(ctx, domain_name, domain_sid, range, 0); + return sss_idmap_add_domain_ex(ctx, domain_name, domain_sid, range, NULL, + 0); } static bool sss_idmap_sid_is_builtin(const char *sid) diff --git a/src/lib/idmap/sss_idmap.h b/src/lib/idmap/sss_idmap.h index 3beeca114..5536aeb77 100644 --- a/src/lib/idmap/sss_idmap.h +++ b/src/lib/idmap/sss_idmap.h @@ -256,6 +256,8 @@ enum idmap_error_code sss_idmap_add_domain(struct sss_idmap_ctx *ctx, * SID (S-1-15-.....) * @param[in] range TBD Some information about the id ranges of this * domain + * @param[in] range_id optional unique identifier of a range, it is needed + * to allow updates at runtime * @param[in] rid The RID that should be mapped to the first ID of the * given range. * @@ -270,6 +272,7 @@ enum idmap_error_code sss_idmap_add_domain_ex(struct sss_idmap_ctx *ctx, const char *domain_name, const char *domain_sid, struct sss_idmap_range *range, + const char *range_id, uint32_t rid); /** * @brief Translate SID to a unix UID or GID |