Blame SOURCES/0184-DOMAIN-Add-sss_domain_info_-get-set-_output_fqnames.patch

ecf709
From 3fc92dcfbd67f82d26d7db46026f1fa1b69e2c70 Mon Sep 17 00:00:00 2001
ecf709
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
ecf709
Date: Tue, 20 Jun 2017 14:22:48 +0200
ecf709
Subject: [PATCH 184/186] DOMAIN: Add
ecf709
 sss_domain_info_{get,set}_output_fqnames()
ecf709
MIME-Version: 1.0
ecf709
Content-Type: text/plain; charset=UTF-8
ecf709
Content-Transfer-Encoding: 8bit
ecf709
ecf709
Let's avoid setting a domain's property directly from cr_domain code.
ecf709
ecf709
In order to do so, let's introduce a setter, which may help us in the
ecf709
future whenever we decide to make sss_domain_info an opaque structure.
ecf709
ecf709
For completeness, a getter has also been introduced and used in the
ecf709
usertools code.
ecf709
ecf709
Related:
ecf709
https://pagure.io/SSSD/sssd/issue/3403
ecf709
ecf709
Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>
ecf709
ecf709
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
ecf709
(cherry picked from commit fa2fc8a2908619031292eaf375eb1a510b8b2eba)
ecf709
---
ecf709
 src/confdb/confdb.h                               |  5 ++++-
ecf709
 src/responder/common/cache_req/cache_req_domain.c |  4 ++--
ecf709
 src/util/domain_info_utils.c                      | 11 +++++++++++
ecf709
 src/util/usertools.c                              |  2 +-
ecf709
 src/util/util.h                                   |  5 +++++
ecf709
 5 files changed, 23 insertions(+), 4 deletions(-)
ecf709
ecf709
diff --git a/src/confdb/confdb.h b/src/confdb/confdb.h
ecf709
index 32a422155abef428e8a75fc83a5fe14620c7028e..2ba1bc47ee11f699726cefaf7c3335d2a8afee49 100644
ecf709
--- a/src/confdb/confdb.h
ecf709
+++ b/src/confdb/confdb.h
ecf709
@@ -291,7 +291,6 @@ struct sss_domain_info {
ecf709
     bool enumerate;
ecf709
     char **sd_enumerate;
ecf709
     bool fqnames;
ecf709
-    bool output_fqnames;
ecf709
     bool mpg;
ecf709
     bool ignore_group_members;
ecf709
     uint32_t id_min;
ecf709
@@ -355,6 +354,10 @@ struct sss_domain_info {
ecf709
 
ecf709
     struct certmap_info **certmaps;
ecf709
     bool user_name_hint;
ecf709
+
ecf709
+    /* Do not use the _output_fqnames property directly in new code, but rather
ecf709
+     * use sss_domain_info_{get,set}_output_fqnames(). */
ecf709
+    bool output_fqnames;
ecf709
 };
ecf709
 
ecf709
 /**
ecf709
diff --git a/src/responder/common/cache_req/cache_req_domain.c b/src/responder/common/cache_req/cache_req_domain.c
ecf709
index b5f7f6c2ffabdbd92ee46b3020cee6ef7fec32d8..c2b5abb74f3bd3d5055f29a4523f29b05feb2014 100644
ecf709
--- a/src/responder/common/cache_req/cache_req_domain.c
ecf709
+++ b/src/responder/common/cache_req/cache_req_domain.c
ecf709
@@ -140,7 +140,7 @@ cache_req_domain_new_list_from_string_list(TALLOC_CTX *mem_ctx,
ecf709
                  * input is allowed by default. However, we really want to use
ecf709
                  * the fully qualified name as output in order to avoid
ecf709
                  * conflicts whith users who have the very same name. */
ecf709
-                cr_domain->domain->output_fqnames = true;
ecf709
+                sss_domain_info_set_output_fqnames(cr_domain->domain, true);
ecf709
 
ecf709
                 DLIST_ADD_END(cr_domains, cr_domain,
ecf709
                               struct cache_req_domain *);
ecf709
@@ -170,7 +170,7 @@ cache_req_domain_new_list_from_string_list(TALLOC_CTX *mem_ctx,
ecf709
          * qualified name as output in order to avoid conflicts whith users
ecf709
          * who have the very same name. */
ecf709
         if (resolution_order != NULL) {
ecf709
-            cr_domain->domain->output_fqnames = true;
ecf709
+            sss_domain_info_set_output_fqnames(cr_domain->domain, true);
ecf709
         }
ecf709
 
ecf709
         DLIST_ADD_END(cr_domains, cr_domain, struct cache_req_domain *);
ecf709
diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c
ecf709
index 541058a16d585155b3b51511740f7db45281e2fd..45c74f089d0fdeaf6b5b50d7e5058df1716ff777 100644
ecf709
--- a/src/util/domain_info_utils.c
ecf709
+++ b/src/util/domain_info_utils.c
ecf709
@@ -904,3 +904,14 @@ const char *sss_domain_type_str(struct sss_domain_info *dom)
ecf709
     }
ecf709
     return "Unknown";
ecf709
 }
ecf709
+
ecf709
+void sss_domain_info_set_output_fqnames(struct sss_domain_info *domain,
ecf709
+                                        bool output_fqnames)
ecf709
+{
ecf709
+    domain->output_fqnames = output_fqnames;
ecf709
+}
ecf709
+
ecf709
+bool sss_domain_info_get_output_fqnames(struct sss_domain_info *domain)
ecf709
+{
ecf709
+    return domain->output_fqnames;
ecf709
+}
ecf709
diff --git a/src/util/usertools.c b/src/util/usertools.c
ecf709
index 83131da1cac25e60a5ec3fffa995a545673e53b9..33f4f7811c843704fff32db3a9ac54b3438f9d37 100644
ecf709
--- a/src/util/usertools.c
ecf709
+++ b/src/util/usertools.c
ecf709
@@ -867,7 +867,7 @@ int sss_output_fqname(TALLOC_CTX *mem_ctx,
ecf709
         goto done;
ecf709
     }
ecf709
 
ecf709
-    if (domain->output_fqnames || domain->fqnames) {
ecf709
+    if (sss_domain_info_get_output_fqnames(domain) || domain->fqnames) {
ecf709
         output_name = sss_tc_fqname(tmp_ctx, domain->names,
ecf709
                                     domain, output_name);
ecf709
         if (output_name == NULL) {
ecf709
diff --git a/src/util/util.h b/src/util/util.h
ecf709
index 5ba4c36ca88e325c20a3b1ecc8080a11ca276dcf..72d4116e1206e9cc69715edc45bf5b9b91e37e6b 100644
ecf709
--- a/src/util/util.h
ecf709
+++ b/src/util/util.h
ecf709
@@ -571,6 +571,11 @@ errno_t sssd_domain_init(TALLOC_CTX *mem_ctx,
ecf709
                          const char *db_path,
ecf709
                          struct sss_domain_info **_domain);
ecf709
 
ecf709
+void sss_domain_info_set_output_fqnames(struct sss_domain_info *domain,
ecf709
+                                        bool output_fqname);
ecf709
+
ecf709
+bool sss_domain_info_get_output_fqnames(struct sss_domain_info *domain);
ecf709
+
ecf709
 #define IS_SUBDOMAIN(dom) ((dom)->parent != NULL)
ecf709
 
ecf709
 #define DOM_HAS_VIEWS(dom) ((dom)->has_views)
ecf709
-- 
ecf709
2.9.4
ecf709