summaryrefslogtreecommitdiffstats
path: root/src/responder
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2012-11-26 12:33:11 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-01-08 15:05:48 +0100
commita475178ead4f59fc96fbd0fb954e7c87355d423a (patch)
treef8d117b7772b7b462b852eaa42a1fea5a854f9ff /src/responder
parentbc1b657cbdb751c4f55eb1ef0812ae96540d859c (diff)
downloadsssd-a475178ead4f59fc96fbd0fb954e7c87355d423a.tar.gz
sssd-a475178ead4f59fc96fbd0fb954e7c87355d423a.tar.xz
sssd-a475178ead4f59fc96fbd0fb954e7c87355d423a.zip
Add find_domain_by_id()
Currently domains can only be searched by name in the global domain list. To make it easier to find the domain for a given SID find_domain_by_id() which returns a pointer to the domain or subdomain entry in the global domain list if a matching id was found.
Diffstat (limited to 'src/responder')
-rw-r--r--src/responder/pac/pacsrv.h3
-rw-r--r--src/responder/pac/pacsrv_utils.c39
2 files changed, 42 insertions, 0 deletions
diff --git a/src/responder/pac/pacsrv.h b/src/responder/pac/pacsrv.h
index 8cd492842..4d3a31643 100644
--- a/src/responder/pac/pacsrv.h
+++ b/src/responder/pac/pacsrv.h
@@ -125,4 +125,7 @@ errno_t diff_gid_lists(TALLOC_CTX *mem_ctx,
struct pac_grp **_add_gid_list,
size_t *_del_gid_num,
struct grp_info ***_del_gid_list);
+
+struct sss_domain_info *find_domain_by_id(struct sss_domain_info *domains,
+ const char *id_str);
#endif /* __PACSRV_H__ */
diff --git a/src/responder/pac/pacsrv_utils.c b/src/responder/pac/pacsrv_utils.c
index 6e0f4bfa6..d79adb1f2 100644
--- a/src/responder/pac/pacsrv_utils.c
+++ b/src/responder/pac/pacsrv_utils.c
@@ -71,6 +71,45 @@ errno_t local_sid_to_id(struct local_mapping_ranges *map, struct dom_sid *sid,
return EOK;
}
+struct sss_domain_info *find_domain_by_id(struct sss_domain_info *domains,
+ const char *id_str)
+{
+ struct sss_domain_info *dom;
+ struct sss_domain_info *ret_dom = NULL;
+ size_t c;
+
+ if (id_str == NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, ("Missing domain id.\n"));
+ return NULL;
+ }
+
+ for (dom = domains; dom; dom = dom->next) {
+ if (dom->domain_id == NULL) {
+ continue;
+ }
+
+ if (strcasecmp(dom->domain_id, id_str) == 0) {
+ ret_dom = dom;
+ break;
+ }
+
+ for (c = 0; c < dom->subdomain_count; c++) {
+ if (strcasecmp(dom->subdomains[c]->domain_id, id_str) == 0) {
+ ret_dom = dom->subdomains[c];
+ break;
+ }
+ }
+
+ }
+
+ if (!ret_dom) {
+ DEBUG(SSSDBG_OP_FAILURE, ("No domain with domain ID [%s] found",
+ id_str));
+ }
+
+ return ret_dom;
+}
+
/**
* Add a new remote domain and the corresponding ID range to the context of
* the libsss_idmap. Without this it is not possible to find the Posix UID for