Blame SOURCES/0184-LDAP-Add-UUID-when-saving-incomplete-groups.patch

905b4d
From 1c1551628ca2d1f7a6cc0938f0cf79c2b2ce6e8b Mon Sep 17 00:00:00 2001
905b4d
From: Jakub Hrozek <jhrozek@redhat.com>
905b4d
Date: Tue, 27 Jan 2015 16:02:33 +0100
905b4d
Subject: [PATCH 184/188] LDAP: Add UUID when saving incomplete groups
905b4d
905b4d
Related to:
905b4d
https://fedorahosted.org/sssd/ticket/2571
905b4d
905b4d
Reviewed-by: Sumit Bose <sbose@redhat.com>
905b4d
(cherry picked from commit 108db0e3b9e06e530364ef8228634f5e3f6bd3b5)
905b4d
---
905b4d
 src/db/sysdb.h                                |  1 +
905b4d
 src/db/sysdb_ops.c                            |  6 ++++++
905b4d
 src/providers/ldap/sdap_async_initgroups.c    | 16 +++++++++++++---
905b4d
 src/providers/ldap/sdap_async_initgroups_ad.c |  2 +-
905b4d
 src/tests/sysdb-tests.c                       | 16 ++++++++--------
905b4d
 5 files changed, 29 insertions(+), 12 deletions(-)
905b4d
905b4d
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
905b4d
index 9e33fee37a352498ed0c987dc2ae0da3500d63d5..cf6028acb806d5d4eedf4cf0680cf4ac9fd6368d 100644
905b4d
--- a/src/db/sysdb.h
905b4d
+++ b/src/db/sysdb.h
905b4d
@@ -797,6 +797,7 @@ int sysdb_add_incomplete_group(struct sss_domain_info *domain,
905b4d
                                gid_t gid,
905b4d
                                const char *original_dn,
905b4d
                                const char *sid_str,
905b4d
+                               const char *uuid,
905b4d
                                bool posix,
905b4d
                                time_t now);
905b4d
 
905b4d
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
905b4d
index 0c254d8cdad1144c32aad7e470fa2a35cd24b38b..6085762dcc5585114dd3049dd3a365856cb6b190 100644
905b4d
--- a/src/db/sysdb_ops.c
905b4d
+++ b/src/db/sysdb_ops.c
905b4d
@@ -1610,6 +1610,7 @@ int sysdb_add_incomplete_group(struct sss_domain_info *domain,
905b4d
                                gid_t gid,
905b4d
                                const char *original_dn,
905b4d
                                const char *sid_str,
905b4d
+                               const char *uuid,
905b4d
                                bool posix,
905b4d
                                time_t now)
905b4d
 {
905b4d
@@ -1656,6 +1657,11 @@ int sysdb_add_incomplete_group(struct sss_domain_info *domain,
905b4d
         if (ret) goto done;
905b4d
     }
905b4d
 
905b4d
+    if (uuid) {
905b4d
+        ret = sysdb_attrs_add_string(attrs, SYSDB_UUID, uuid);
905b4d
+        if (ret) goto done;
905b4d
+    }
905b4d
+
905b4d
     ret = sysdb_set_group_attr(domain, name, attrs, SYSDB_MOD_REP);
905b4d
 
905b4d
 done:
905b4d
diff --git a/src/providers/ldap/sdap_async_initgroups.c b/src/providers/ldap/sdap_async_initgroups.c
905b4d
index d3e080013ec99c18648c6a57e478d50eb3b666f1..6b3179d2d6bb30b3b00aa35b07da42de3cf08a34 100644
905b4d
--- a/src/providers/ldap/sdap_async_initgroups.c
905b4d
+++ b/src/providers/ldap/sdap_async_initgroups.c
905b4d
@@ -41,6 +41,7 @@ static errno_t sdap_add_incomplete_groups(struct sysdb_ctx *sysdb,
905b4d
     int i, mi, ai;
905b4d
     const char *groupname;
905b4d
     const char *original_dn;
905b4d
+    const char *uuid = NULL;
905b4d
     char **missing;
905b4d
     gid_t gid;
905b4d
     int ret;
905b4d
@@ -191,15 +192,24 @@ static errno_t sdap_add_incomplete_groups(struct sysdb_ctx *sysdb,
905b4d
                                              &original_dn);
905b4d
                 if (ret) {
905b4d
                     DEBUG(SSSDBG_FUNC_DATA,
905b4d
-                          "The group has no name original DN\n");
905b4d
+                          "The group has no original DN\n");
905b4d
                     original_dn = NULL;
905b4d
                 }
905b4d
 
905b4d
+                ret = sysdb_attrs_get_string(ldap_groups[ai],
905b4d
+                                             SYSDB_UUID,
905b4d
+                                             &uuid);
905b4d
+                if (ret) {
905b4d
+                    DEBUG(SSSDBG_FUNC_DATA,
905b4d
+                          "The group has no UUID\n");
905b4d
+                    uuid = NULL;
905b4d
+                }
905b4d
+
905b4d
                 DEBUG(SSSDBG_TRACE_INTERNAL,
905b4d
                       "Adding fake group %s to sysdb\n", groupname);
905b4d
                 ret = sysdb_add_incomplete_group(domain, groupname, gid,
905b4d
-                                                 original_dn, sid_str, posix,
905b4d
-                                                 now);
905b4d
+                                                 original_dn, sid_str,
905b4d
+                                                 uuid, posix, now);
905b4d
                 if (ret != EOK) {
905b4d
                     goto done;
905b4d
                 }
905b4d
diff --git a/src/providers/ldap/sdap_async_initgroups_ad.c b/src/providers/ldap/sdap_async_initgroups_ad.c
905b4d
index a533279f680d5cabc096cb9e64cfdb1057c5c799..1b8c8d981ea14ac0fca0903f16296c8a6701c5dd 100644
905b4d
--- a/src/providers/ldap/sdap_async_initgroups_ad.c
905b4d
+++ b/src/providers/ldap/sdap_async_initgroups_ad.c
905b4d
@@ -929,7 +929,7 @@ static void sdap_ad_tokengroups_initgr_mapping_done(struct tevent_req *subreq)
905b4d
              * it will replace this temporary entry. */
905b4d
             name = sid;
905b4d
             ret = sysdb_add_incomplete_group(domain, name, gid,
905b4d
-                                             NULL, sid, false, now);
905b4d
+                                             NULL, sid, NULL, false, now);
905b4d
             if (ret != EOK) {
905b4d
                 DEBUG(SSSDBG_MINOR_FAILURE, "Could not create incomplete "
905b4d
                                              "group: [%s]\n", strerror(ret));
905b4d
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
905b4d
index 0c49d0ca7ca89d772f2a7df2ddd4acc20c4e312c..a78cf713fbe165204708bcf787b998acab0b7ca5 100644
905b4d
--- a/src/tests/sysdb-tests.c
905b4d
+++ b/src/tests/sysdb-tests.c
905b4d
@@ -266,7 +266,7 @@ static int test_add_incomplete_group(struct test_data *data)
905b4d
     int ret;
905b4d
 
905b4d
     ret = sysdb_add_incomplete_group(data->ctx->domain, data->groupname,
905b4d
-                                     data->gid, NULL, NULL, true, 0);
905b4d
+                                     data->gid, NULL, NULL, NULL, true, 0);
905b4d
     return ret;
905b4d
 }
905b4d
 
905b4d
@@ -3986,8 +3986,8 @@ START_TEST(test_odd_characters)
905b4d
     /* ===== Groups ===== */
905b4d
 
905b4d
     /* Add */
905b4d
-    ret = sysdb_add_incomplete_group(test_ctx->domain,
905b4d
-                                     odd_groupname, 20000, NULL, NULL, true, 0);
905b4d
+    ret = sysdb_add_incomplete_group(test_ctx->domain, odd_groupname,
905b4d
+                                     20000, NULL, NULL, NULL, true, 0);
905b4d
     fail_unless(ret == EOK, "sysdb_add_incomplete_group error [%d][%s]",
905b4d
                             ret, strerror(ret));
905b4d
 
905b4d
@@ -4143,8 +4143,8 @@ START_TEST(test_SSS_LDB_SEARCH)
905b4d
     fail_if(nonexist_dn == NULL, "sysdb_group_dn failed");
905b4d
 
905b4d
     /* Add */
905b4d
-    ret = sysdb_add_incomplete_group(test_ctx->domain,
905b4d
-                                     groupname, 20000, NULL, NULL, true, 0);
905b4d
+    ret = sysdb_add_incomplete_group(test_ctx->domain, groupname,
905b4d
+                                     20000, NULL, NULL, NULL, true, 0);
905b4d
     fail_unless(ret == EOK, "sysdb_add_incomplete_group error [%d][%s]",
905b4d
                 ret, strerror(ret));
905b4d
 
905b4d
@@ -4935,14 +4935,14 @@ START_TEST(test_sysdb_original_dn_case_insensitive)
905b4d
     ret = sysdb_add_incomplete_group(test_ctx->domain,
905b4d
                                      "case_sensitive_group1", 29000,
905b4d
                                      "cn=case_sensitive_group1,cn=example,cn=com",
905b4d
-                                     NULL, true, 0);
905b4d
+                                     NULL, NULL, true, 0);
905b4d
     fail_unless(ret == EOK, "sysdb_add_incomplete_group error [%d][%s]",
905b4d
                             ret, strerror(ret));
905b4d
 
905b4d
     ret = sysdb_add_incomplete_group(test_ctx->domain,
905b4d
                                      "case_sensitive_group2", 29001,
905b4d
                                      "cn=CASE_SENSITIVE_GROUP1,cn=EXAMPLE,cn=COM",
905b4d
-                                     NULL, true, 0);
905b4d
+                                     NULL, NULL, true, 0);
905b4d
     fail_unless(ret == EOK, "sysdb_add_incomplete_group error [%d][%s]",
905b4d
                             ret, strerror(ret));
905b4d
 
905b4d
@@ -4978,7 +4978,7 @@ START_TEST(test_sysdb_search_sid_str)
905b4d
     ret = sysdb_add_incomplete_group(test_ctx->domain,
905b4d
                                      "group", 29000,
905b4d
                                      "cn=group,cn=example,cn=com",
905b4d
-                                     "S-1-2-3-4", true, 0);
905b4d
+                                     "S-1-2-3-4", NULL, true, 0);
905b4d
     fail_unless(ret == EOK, "sysdb_add_incomplete_group error [%d][%s]",
905b4d
                             ret, strerror(ret));
905b4d
 
905b4d
-- 
905b4d
2.1.0
905b4d