dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0149-IPA-handle-GID-overrides-for-MPG-domains-on-clients.patch

905b4d
From 034dcabb40e654a95f3714d871db471ff7bf97f8 Mon Sep 17 00:00:00 2001
905b4d
From: Sumit Bose <sbose@redhat.com>
905b4d
Date: Thu, 4 Dec 2014 12:50:03 +0100
905b4d
Subject: [PATCH 2/2] IPA: handle GID overrides for MPG domains on clients
905b4d
MIME-Version: 1.0
905b4d
Content-Type: text/plain; charset=UTF-8
905b4d
Content-Transfer-Encoding: 8bit
905b4d
905b4d
Resolves https://fedorahosted.org/sssd/ticket/2514
905b4d
905b4d
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
905b4d
---
905b4d
 src/providers/ipa/ipa_s2n_exop.c | 26 ++++++++++++++++++++++++++
905b4d
 1 file changed, 26 insertions(+)
905b4d
905b4d
diff --git a/src/providers/ipa/ipa_s2n_exop.c b/src/providers/ipa/ipa_s2n_exop.c
905b4d
index 6d5b45edf20f720f5b97f0ed5c8ec591c580de0d..55450c7029391a99bfc33b8446765f71c4d0928a 100644
905b4d
--- a/src/providers/ipa/ipa_s2n_exop.c
905b4d
+++ b/src/providers/ipa/ipa_s2n_exop.c
905b4d
@@ -1618,6 +1618,7 @@ static errno_t ipa_s2n_save_objects(struct sss_domain_info *dom,
905b4d
     char *realm;
905b4d
     char *upn = NULL;
905b4d
     gid_t gid;
905b4d
+    gid_t orig_gid = 0;
905b4d
     TALLOC_CTX *tmp_ctx;
905b4d
     const char *sid_str;
905b4d
     const char *tmp_str;
905b4d
@@ -1796,6 +1797,31 @@ static errno_t ipa_s2n_save_objects(struct sss_domain_info *dom,
905b4d
             gid = 0;
905b4d
             if (dom->mpg == false) {
905b4d
                 gid = attrs->a.user.pw_gid;
905b4d
+            } else {
905b4d
+                /* The extdom plugin always returns the objects with the
905b4d
+                 * default view applied. Since the GID is handled specially
905b4d
+                 * for MPG domains we have add any overridden GID separately.
905b4d
+                 */
905b4d
+                ret = sysdb_attrs_get_uint32_t(attrs->sysdb_attrs,
905b4d
+                                               ORIGINALAD_PREFIX SYSDB_GIDNUM,
905b4d
+                                               &orig_gid);
905b4d
+                if (ret == EOK || ret == ENOENT) {
905b4d
+                    if ((orig_gid != 0 && orig_gid != attrs->a.user.pw_gid)
905b4d
+                            || attrs->a.user.pw_uid != attrs->a.user.pw_gid) {
905b4d
+                        ret = sysdb_attrs_add_uint32(attrs->sysdb_attrs,
905b4d
+                                                     SYSDB_GIDNUM,
905b4d
+                                                     attrs->a.user.pw_gid);
905b4d
+                        if (ret != EOK) {
905b4d
+                            DEBUG(SSSDBG_OP_FAILURE,
905b4d
+                                  "sysdb_attrs_add_uint32 failed.\n");
905b4d
+                            goto done;
905b4d
+                        }
905b4d
+                    }
905b4d
+                } else {
905b4d
+                    DEBUG(SSSDBG_OP_FAILURE,
905b4d
+                          "sysdb_attrs_get_uint32_t failed.\n");
905b4d
+                    goto done;
905b4d
+                }
905b4d
             }
905b4d
 
905b4d
             ret = sysdb_transaction_start(dom->sysdb);
905b4d
-- 
905b4d
1.9.3
905b4d