Blame SOURCES/0125-ipa-subdomains-provider-make-sure-search-by-SID-work.patch

9cb92d
From 503e1ebb9c36ecb978a28a5cefd94d24945ee39b Mon Sep 17 00:00:00 2001
9cb92d
From: Alexander Bokovoy <abokovoy@redhat.com>
9cb92d
Date: Tue, 13 May 2014 11:22:29 +0300
9cb92d
Subject: [PATCH 125/126] ipa subdomains provider: make sure search by SID
9cb92d
 works for homedir
9cb92d
9cb92d
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
9cb92d
---
9cb92d
 src/providers/ipa/ipa_subdomains_id.c | 20 +++++++++++++++-----
9cb92d
 1 file changed, 15 insertions(+), 5 deletions(-)
9cb92d
9cb92d
diff --git a/src/providers/ipa/ipa_subdomains_id.c b/src/providers/ipa/ipa_subdomains_id.c
9cb92d
index 978ccc261d7525662e835b867044b6a5238a29df..d8922a461fc1cbbec4bb65b8cd6e6cf25f2dc605 100644
9cb92d
--- a/src/providers/ipa/ipa_subdomains_id.c
9cb92d
+++ b/src/providers/ipa/ipa_subdomains_id.c
9cb92d
@@ -484,7 +484,11 @@ apply_subdomain_homedir(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom,
9cb92d
     uint32_t uid;
9cb92d
     const char *fqname;
9cb92d
     const char *homedir = NULL;
9cb92d
-    struct ldb_result *res;
9cb92d
+    struct ldb_result *res = NULL;
9cb92d
+    struct ldb_message *msg = NULL;
9cb92d
+    const char *attrs[] = { SYSDB_NAME,
9cb92d
+                            SYSDB_UIDNUM,
9cb92d
+                            NULL };
9cb92d
 
9cb92d
     if (filter_type == BE_FILTER_NAME) {
9cb92d
         ret = sysdb_getpwnam(mem_ctx, dom->sysdb, dom, filter_value, &res;;
9cb92d
@@ -496,6 +500,9 @@ apply_subdomain_homedir(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom,
9cb92d
             goto done;
9cb92d
         }
9cb92d
         ret = sysdb_getpwuid(mem_ctx, dom->sysdb, dom, uid, &res;;
9cb92d
+    } else if (filter_type == BE_FILTER_SECID) {
9cb92d
+        ret = sysdb_search_user_by_sid_str(mem_ctx, dom->sysdb, dom,
9cb92d
+                                           filter_value, attrs, &msg;;
9cb92d
     } else {
9cb92d
         DEBUG(SSSDBG_OP_FAILURE,
9cb92d
               ("Unsupported filter type: [%d].\n", filter_type));
9cb92d
@@ -503,24 +510,27 @@ apply_subdomain_homedir(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom,
9cb92d
         goto done;
9cb92d
     }
9cb92d
 
9cb92d
-    if (ret != EOK) {
9cb92d
+    if (ret != EOK && ret != ENOENT) {
9cb92d
         DEBUG(SSSDBG_OP_FAILURE,
9cb92d
               ("Failed to make request to our cache: [%d]: [%s]\n",
9cb92d
                ret, sss_strerror(ret)));
9cb92d
         goto done;
9cb92d
     }
9cb92d
 
9cb92d
-    if (res->count == 0) {
9cb92d
+    if ((res && res->count == 0) || (msg && msg->num_elements == 0)) {
9cb92d
         ret = ENOENT;
9cb92d
         goto done;
9cb92d
     }
9cb92d
 
9cb92d
+    if (res != NULL) {
9cb92d
+        msg = res->msgs[0];
9cb92d
+    }
9cb92d
     /*
9cb92d
      * Homedir is always overriden by subdomain_homedir even if it was
9cb92d
      * explicitly set by user.
9cb92d
      */
9cb92d
-    fqname = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_NAME, NULL);
9cb92d
-    uid = ldb_msg_find_attr_as_uint64(res->msgs[0], SYSDB_UIDNUM, 0);
9cb92d
+    fqname = ldb_msg_find_attr_as_string(msg, SYSDB_NAME, NULL);
9cb92d
+    uid = ldb_msg_find_attr_as_uint64(msg, SYSDB_UIDNUM, 0);
9cb92d
     if (uid == 0) {
9cb92d
         DEBUG(SSSDBG_OP_FAILURE, ("UID for user [%s] is not known.\n",
9cb92d
                                   filter_value));
9cb92d
-- 
9cb92d
1.9.0
9cb92d