>From 54c38b71d76021940aed230f7255737feb30a38e Mon Sep 17 00:00:00 2001
From: Pavel Reichl <preichl@redhat.com>
Date: Mon, 21 Jul 2014 08:01:58 +0100
Subject: [PATCH 1/3] UTIL: rename find_subdomain_by_sid

The function was named "find_subdomain" yet it could find both main
domain and subdomain.

sed 's/find_subdomain_by_sid/find_domain_by_sid/' -i `find . -name "*.[ch]"`
---
 src/providers/ad/ad_id.c                   |  2 +-
 src/providers/ipa/ipa_idmap.c              |  4 ++--
 src/providers/ldap/sdap_async_users.c      |  2 +-
 src/providers/simple/simple_access_check.c |  2 +-
 src/tests/cmocka/test_utils.c              | 28 ++++++++++++++--------------
 src/util/domain_info_utils.c               |  4 ++--
 src/util/util.h                            |  4 ++--
 7 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/src/providers/ad/ad_id.c b/src/providers/ad/ad_id.c
index 90d807b25dae2d52ef5a90bbb053e01c43e2cda3..2e53a685fdc57ee72cffbca836166691fb84dfa0 100644
--- a/src/providers/ad/ad_id.c
+++ b/src/providers/ad/ad_id.c
@@ -299,7 +299,7 @@ static bool ad_account_can_shortcut(struct be_ctx *be_ctx,
     case BE_FILTER_SECID:
         csid = sid == NULL ? filter_value : sid;
 
-        req_dom = find_subdomain_by_sid(domain, csid);
+        req_dom = find_domain_by_sid(domain, csid);
         if (req_dom == NULL) {
             DEBUG(SSSDBG_OP_FAILURE, "Invalid domain\n");
             goto done;
diff --git a/src/providers/ipa/ipa_idmap.c b/src/providers/ipa/ipa_idmap.c
index ae202d616f84dd048561d160fbdbec1f7d704d04..7e4f985f32e705b0fd728b232873ed20f4ddf859 100644
--- a/src/providers/ipa/ipa_idmap.c
+++ b/src/providers/ipa/ipa_idmap.c
@@ -71,10 +71,10 @@ static errno_t ipa_idmap_check_posix_child(struct sdap_idmap_ctx *idmap_ctx,
         return EINVAL;
     }
 
-    dom = find_subdomain_by_sid(idmap_ctx->id_ctx->be->domain, dom_sid_str);
+    dom = find_domain_by_sid(idmap_ctx->id_ctx->be->domain, dom_sid_str);
     if (dom == NULL) {
         DEBUG(SSSDBG_OP_FAILURE,
-              "find_subdomain_by_sid failed with SID [%s].\n", dom_sid_str);
+              "find_domain_by_sid failed with SID [%s].\n", dom_sid_str);
         return EINVAL;
     }
 
diff --git a/src/providers/ldap/sdap_async_users.c b/src/providers/ldap/sdap_async_users.c
index be0536ef3c3ffaf398c4f2d3e85094d4deb7bd81..2331ba9df90cdbf8fdb9ae85bd97485b0bcf8bb2 100644
--- a/src/providers/ldap/sdap_async_users.c
+++ b/src/providers/ldap/sdap_async_users.c
@@ -180,7 +180,7 @@ int sdap_save_user(TALLOC_CTX *memctx,
     /* If this object has a SID available, we will determine the correct
      * domain by its SID. */
     if (sid_str != NULL) {
-        subdomain = find_subdomain_by_sid(get_domains_head(dom), sid_str);
+        subdomain = find_domain_by_sid(get_domains_head(dom), sid_str);
         if (subdomain) {
             dom = subdomain;
         } else {
diff --git a/src/providers/simple/simple_access_check.c b/src/providers/simple/simple_access_check.c
index 4b4400f6d73d6219936b53273ee04221993242fc..1fcff445f943bea3398bddb83fba84609b6c9d9a 100644
--- a/src/providers/simple/simple_access_check.c
+++ b/src/providers/simple/simple_access_check.c
@@ -611,7 +611,7 @@ simple_check_process_group(struct simple_check_groups_state *state,
         /* We will look it up in main domain. */
         domain = state->ctx->domain;
     } else {
-        domain = find_subdomain_by_sid(state->ctx->domain, group_sid);
+        domain = find_domain_by_sid(state->ctx->domain, group_sid);
         if (domain == NULL) {
             DEBUG(SSSDBG_CRIT_FAILURE, "There is no domain information for "
                                         "SID %s\n", group_sid);
diff --git a/src/tests/cmocka/test_utils.c b/src/tests/cmocka/test_utils.c
index e49e7eca5628a65492becbf13dfc5fb93063ff15..59b6e08bacf7a3c185bce08670321f709817c46f 100644
--- a/src/tests/cmocka/test_utils.c
+++ b/src/tests/cmocka/test_utils.c
@@ -306,23 +306,23 @@ void test_find_subdomain_by_name_disabled(void **state)
     }
 }
 
-void test_find_subdomain_by_sid_null(void **state)
+void test_find_domain_by_sid_null(void **state)
 {
     struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
                                                       struct dom_list_test_ctx);
     struct sss_domain_info *dom;
 
-    dom = find_subdomain_by_sid(NULL, NULL);
+    dom = find_domain_by_sid(NULL, NULL);
     assert_null(dom);
 
-    dom = find_subdomain_by_sid(test_ctx->dom_list, NULL);
+    dom = find_domain_by_sid(test_ctx->dom_list, NULL);
     assert_null(dom);
 
-    dom = find_subdomain_by_sid(NULL, "S-1-5-21-1-2-3");
+    dom = find_domain_by_sid(NULL, "S-1-5-21-1-2-3");
     assert_null(dom);
 }
 
-void test_find_subdomain_by_sid(void **state)
+void test_find_domain_by_sid(void **state)
 {
     struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
                                                       struct dom_list_test_ctx);
@@ -342,7 +342,7 @@ void test_find_subdomain_by_sid(void **state)
         sid = talloc_asprintf(global_talloc_context, SID_TMPL, c);
         assert_non_null(sid);
 
-        dom = find_subdomain_by_sid(test_ctx->dom_list, sid);
+        dom = find_domain_by_sid(test_ctx->dom_list, sid);
         assert_non_null(dom);
         assert_string_equal(name, dom->name);
         assert_string_equal(flat_name, dom->flat_name);
@@ -354,7 +354,7 @@ void test_find_subdomain_by_sid(void **state)
     }
 }
 
-void test_find_subdomain_by_sid_missing_sid(void **state)
+void test_find_domain_by_sid_missing_sid(void **state)
 {
     struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
                                                       struct dom_list_test_ctx);
@@ -386,7 +386,7 @@ void test_find_subdomain_by_sid_missing_sid(void **state)
         sid = talloc_asprintf(global_talloc_context, SID_TMPL, c);
         assert_non_null(sid);
 
-        dom = find_subdomain_by_sid(test_ctx->dom_list, sid);
+        dom = find_domain_by_sid(test_ctx->dom_list, sid);
         if (c == mis - 1) {
             assert_null(dom);
         } else {
@@ -402,7 +402,7 @@ void test_find_subdomain_by_sid_missing_sid(void **state)
     }
 }
 
-void test_find_subdomain_by_sid_disabled(void **state)
+void test_find_domain_by_sid_disabled(void **state)
 {
     struct dom_list_test_ctx *test_ctx = talloc_get_type(*state,
                                                       struct dom_list_test_ctx);
@@ -434,7 +434,7 @@ void test_find_subdomain_by_sid_disabled(void **state)
         sid = talloc_asprintf(global_talloc_context, SID_TMPL, c);
         assert_non_null(sid);
 
-        dom = find_subdomain_by_sid(test_ctx->dom_list, sid);
+        dom = find_domain_by_sid(test_ctx->dom_list, sid);
         if (c == mis - 1) {
             assert_null(dom);
         } else {
@@ -887,13 +887,13 @@ int main(int argc, const char *argv[])
     };
 
     const UnitTest tests[] = {
-        unit_test_setup_teardown(test_find_subdomain_by_sid_null,
+        unit_test_setup_teardown(test_find_domain_by_sid_null,
                                  setup_dom_list, teardown_dom_list),
-        unit_test_setup_teardown(test_find_subdomain_by_sid,
+        unit_test_setup_teardown(test_find_domain_by_sid,
                                  setup_dom_list, teardown_dom_list),
-        unit_test_setup_teardown(test_find_subdomain_by_sid_missing_sid,
+        unit_test_setup_teardown(test_find_domain_by_sid_missing_sid,
                                  setup_dom_list, teardown_dom_list),
-        unit_test_setup_teardown(test_find_subdomain_by_sid_disabled,
+        unit_test_setup_teardown(test_find_domain_by_sid_disabled,
                                  setup_dom_list, teardown_dom_list),
         unit_test_setup_teardown(test_find_subdomain_by_name_null,
                                  setup_dom_list, teardown_dom_list),
diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c
index 2a87684394628bb170f008630b74b7e0ca168674..83f3baa62b45c4c42e5dc3acddb38f8d66491bcf 100644
--- a/src/util/domain_info_utils.c
+++ b/src/util/domain_info_utils.c
@@ -112,7 +112,7 @@ struct sss_domain_info *find_subdomain_by_name(struct sss_domain_info *domain,
     return NULL;
 }
 
-struct sss_domain_info *find_subdomain_by_sid(struct sss_domain_info *domain,
+struct sss_domain_info *find_domain_by_sid(struct sss_domain_info *domain,
                                               const char *sid)
 {
     struct sss_domain_info *dom = domain;
@@ -163,7 +163,7 @@ sss_get_domain_by_sid_ldap_fallback(struct sss_domain_info *domain,
     if (strcmp(domain->provider, "ldap") == 0) {
         return domain;
     } else {
-        return find_subdomain_by_sid(get_domains_head(domain), sid);
+        return find_domain_by_sid(get_domains_head(domain), sid);
     }
 }
 
diff --git a/src/util/util.h b/src/util/util.h
index 52135e6b07b6db58bf6c7a25cbfcf1b9ba4c447a..3cf1bc0a0190a237f21e179400247d2536cb2aed 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -514,8 +514,8 @@ struct sss_domain_info *get_next_domain(struct sss_domain_info *domain,
 struct sss_domain_info *find_subdomain_by_name(struct sss_domain_info *domain,
                                                const char *name,
                                                bool match_any);
-struct sss_domain_info *find_subdomain_by_sid(struct sss_domain_info *domain,
-                                              const char *sid);
+struct sss_domain_info *find_domain_by_sid(struct sss_domain_info *domain,
+                                           const char *sid);
 
 struct sss_domain_info*
 sss_get_domain_by_sid_ldap_fallback(struct sss_domain_info *domain,
-- 
1.9.3

