>From 46b6fee28c8186d317d979defa66a3e1115d4182 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Tue, 13 May 2014 11:22:29 +0300 Subject: [PATCH] ipa subdomains provider: make sure search by SID works for homedir --- src/providers/ipa/ipa_subdomains_id.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/providers/ipa/ipa_subdomains_id.c b/src/providers/ipa/ipa_subdomains_id.c index bf68554..974e115 100644 --- a/src/providers/ipa/ipa_subdomains_id.c +++ b/src/providers/ipa/ipa_subdomains_id.c @@ -484,7 +484,8 @@ apply_subdomain_homedir(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom, uint32_t uid; const char *fqname; const char *homedir = NULL; - struct ldb_result *res; + struct ldb_result *res = NULL; + struct ldb_message *msg = NULL; if (filter_type == BE_FILTER_NAME) { ret = sysdb_getpwnam(mem_ctx, dom->sysdb, dom, filter_value, &res); @@ -496,6 +497,8 @@ apply_subdomain_homedir(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom, goto done; } ret = sysdb_getpwuid(mem_ctx, dom->sysdb, dom, uid, &res); + } else if (filter_type == BE_FILTER_SECID) { + ret = sysdb_search_user_by_sid_str(mem_ctx, dom->sysdb, dom, filter_value, NULL, &msg); } else { DEBUG(SSSDBG_OP_FAILURE, "Unsupported filter type: [%d].\n", filter_type); @@ -510,17 +513,20 @@ apply_subdomain_homedir(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom, goto done; } - if (res->count == 0) { + if (res && res->count == 0) { ret = ENOENT; goto done; } + if (res != NULL) { + msg = res->msgs[0]; + } /* * Homedir is always overriden by subdomain_homedir even if it was * explicitly set by user. */ - fqname = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_NAME, NULL); - uid = ldb_msg_find_attr_as_uint64(res->msgs[0], SYSDB_UIDNUM, 0); + fqname = ldb_msg_find_attr_as_string(msg, SYSDB_NAME, NULL); + uid = ldb_msg_find_attr_as_uint64(msg, SYSDB_UIDNUM, 0); if (uid == 0) { DEBUG(SSSDBG_OP_FAILURE, "UID for user [%s] is not known.\n", filter_value); -- 1.9.0