dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0030-sysdb-make-sysdb_update_subdomains-more-robust.patch

836b22
From 6f308f7833669b91000e42907380aa4cbe3fc145 Mon Sep 17 00:00:00 2001
836b22
From: Sumit Bose <sbose@redhat.com>
836b22
Date: Thu, 7 May 2020 15:47:35 +0200
836b22
Subject: [PATCH 30/36] sysdb: make sysdb_update_subdomains() more robust
836b22
MIME-Version: 1.0
836b22
Content-Type: text/plain; charset=UTF-8
836b22
Content-Transfer-Encoding: 8bit
836b22
836b22
Some NULL checks are added basically to allow that missing values can be
836b22
set later.
836b22
836b22
Resolves: https://github.com/SSSD/sssd/issues/5151
836b22
836b22
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
836b22
(cherry picked from commit 8ca799ea968e548337acb0300642a0d88f1bba9b)
836b22
836b22
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
836b22
---
836b22
 src/db/sysdb_subdomains.c | 12 +++++++++---
836b22
 1 file changed, 9 insertions(+), 3 deletions(-)
836b22
836b22
diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c
836b22
index 59d2c5118..ee3c7f1aa 100644
836b22
--- a/src/db/sysdb_subdomains.c
836b22
+++ b/src/db/sysdb_subdomains.c
836b22
@@ -420,7 +420,9 @@ errno_t sysdb_update_subdomains(struct sss_domain_info *domain,
836b22
                 }
836b22
 
836b22
                 /* in theory these may change, but it should never happen */
836b22
-                if (strcasecmp(dom->realm, realm) != 0) {
836b22
+                if ((dom->realm == NULL && realm != NULL)
836b22
+                        || (dom->realm != NULL && realm != NULL
836b22
+                            && strcasecmp(dom->realm, realm) != 0)) {
836b22
                     DEBUG(SSSDBG_TRACE_INTERNAL,
836b22
                           "Realm name changed from [%s] to [%s]!\n",
836b22
                            dom->realm, realm);
836b22
@@ -431,7 +433,9 @@ errno_t sysdb_update_subdomains(struct sss_domain_info *domain,
836b22
                         goto done;
836b22
                     }
836b22
                 }
836b22
-                if (strcasecmp(dom->flat_name, flat) != 0) {
836b22
+                if ((dom->flat_name == NULL && flat != NULL)
836b22
+                        || (dom->flat_name != NULL && flat != NULL
836b22
+                            && strcasecmp(dom->flat_name, flat) != 0)) {
836b22
                     DEBUG(SSSDBG_TRACE_INTERNAL,
836b22
                           "Flat name changed from [%s] to [%s]!\n",
836b22
                            dom->flat_name, flat);
836b22
@@ -442,7 +446,9 @@ errno_t sysdb_update_subdomains(struct sss_domain_info *domain,
836b22
                         goto done;
836b22
                     }
836b22
                 }
836b22
-                if (strcasecmp(dom->domain_id, id) != 0) {
836b22
+                if ((dom->domain_id == NULL && id != NULL)
836b22
+                        || (dom->domain_id != NULL && id != NULL
836b22
+                            && strcasecmp(dom->domain_id, id) != 0)) {
836b22
                     DEBUG(SSSDBG_TRACE_INTERNAL,
836b22
                           "Domain changed from [%s] to [%s]!\n",
836b22
                            dom->domain_id, id);
836b22
-- 
836b22
2.21.1
836b22