URL: https://github.com/SSSD/sssd/pull/693
Author: jhrozek
 Title: #693: SYSDB: Fall back to the MPG result of getgrgid search if the 
non-MPG search for override doesn't match anything
Action: synchronized

To pull the PR as Git branch:
git remote add ghsssd https://github.com/SSSD/sssd
git fetch ghsssd pull/693/head:pr693
git checkout pr693
From 33aa422e4a88dd3d0297479d8832d3dfdffd4b87 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhro...@redhat.com>
Date: Wed, 7 Nov 2018 13:26:59 +0100
Subject: [PATCH] SYSDB: Fall back to the MPG result of getgrgid search if the
 non-MPG search for override doesn't match anything

---
 src/db/sysdb_search.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/db/sysdb_search.c b/src/db/sysdb_search.c
index 43341d4462..26f3b018e7 100644
--- a/src/db/sysdb_search.c
+++ b/src/db/sysdb_search.c
@@ -1088,6 +1088,7 @@ int sysdb_getgrgid_attrs(TALLOC_CTX *mem_ctx,
     const char *fmt_filter;
     struct ldb_dn *base_dn;
     struct ldb_result *res = NULL;
+    struct ldb_result *mpg_res = NULL;
     int ret;
     static const char *default_attrs[] = SYSDB_GRSRC_ATTRS;
     const char **attrs = NULL;
@@ -1116,6 +1117,10 @@ int sysdb_getgrgid_attrs(TALLOC_CTX *mem_ctx,
          * In case those are not the same, we're dealing with an
          * override and in order to return the proper overridden group
          * we must use the very same search used by a non-mpg domain
+         * to make sure that if the GID points to a group, it will
+         * be resolved. But we must also make sure to fall back
+         * to using the MPG result if the GID does not resolve
+         * to a group
          */
         fmt_filter = SYSDB_GRGID_MPG_FILTER;
         base_dn = sysdb_domain_dn(tmp_ctx, domain);
@@ -1138,6 +1143,7 @@ int sysdb_getgrgid_attrs(TALLOC_CTX *mem_ctx,
             if (ul_originalad_gid != 0 && ul_originalad_gid != ul_gid) {
                 fmt_filter = SYSDB_GRGID_FILTER;
                 base_dn = sysdb_group_base_dn(tmp_ctx, domain);
+                mpg_res = res;
                 res = NULL;
             }
         }
@@ -1162,6 +1168,14 @@ int sysdb_getgrgid_attrs(TALLOC_CTX *mem_ctx,
         }
     }
 
+    if (mpg_res != NULL && mpg_res->count > 0
+            && (res == NULL || res->count == 0)) {
+        /* The overriden group does not resolve to a proper group object,
+         * just use it as a result
+         */
+        res = mpg_res;
+    }
+
     ret = mpg_res_convert(res);
     if (ret) {
         goto done;
_______________________________________________
sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org
To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/sssd-devel@lists.fedorahosted.org

Reply via email to