Blame SOURCES/0111-Do-not-keep-allocating-external-groups-on-a-long-liv.patch

086f82
From d2e17974c6bcb3ae2fc8a2cde696d387385c7d61 Mon Sep 17 00:00:00 2001
086f82
From: Jakub Hrozek <jhrozek@redhat.com>
086f82
Date: Tue, 3 Apr 2018 21:48:37 +0200
086f82
Subject: [PATCH] Do not keep allocating external groups on a long-lived
086f82
 context
086f82
MIME-Version: 1.0
086f82
Content-Type: text/plain; charset=UTF-8
086f82
Content-Transfer-Encoding: 8bit
086f82
086f82
The hash table with the external groups was never freed, so the
086f82
server_mode->ext_groups context was growing over time.
086f82
086f82
This patch keeps the new hash on the state if something failed, then
086f82
frees the previous hash and finally steals the new hash onto the server
086f82
mode.
086f82
086f82
Resolves:
086f82
https://pagure.io/SSSD/sssd/issue/3719
086f82
086f82
Signed-off-by: Sumit Bose <sbose@redhat.com>
086f82
Reviewed-by: Fabiano FidĂȘncio <fidencio@redhat.com>
086f82
(cherry picked from commit 10213efaf1f9f587b47a82778a252d79863f665e)
086f82
086f82
DOWNSTREAM:
086f82
Resolves: rhbz#1583746 - The SSSD IPA provider allocates information about external groups on a long lived memory context, causing memory growth of the sssd_be process [rhel-7.5.z]
086f82
---
086f82
 src/providers/ipa/ipa_subdomains_ext_groups.c | 11 ++++++++---
086f82
 1 file changed, 8 insertions(+), 3 deletions(-)
086f82
086f82
diff --git a/src/providers/ipa/ipa_subdomains_ext_groups.c b/src/providers/ipa/ipa_subdomains_ext_groups.c
086f82
index 9e1d6c3a9bdeda56b421a2dc9198dff0b84c54ce..63ff7c7d7373a4e6a18fc914eff7ca00d477bca6 100644
086f82
--- a/src/providers/ipa/ipa_subdomains_ext_groups.c
086f82
+++ b/src/providers/ipa/ipa_subdomains_ext_groups.c
086f82
@@ -583,14 +583,19 @@ static void ipa_get_ext_groups_done(struct tevent_req *subreq)
086f82
     DEBUG(SSSDBG_TRACE_FUNC, "[%zu] external groups found.\n",
086f82
                               state->reply_count);
086f82
 
086f82
-    ret = process_ext_groups(state->server_mode->ext_groups,
086f82
-                             state->reply_count, state->reply, &ext_group_hash);
086f82
+    ret = process_ext_groups(state,
086f82
+                             state->reply_count,
086f82
+                             state->reply,
086f82
+                             &ext_group_hash);
086f82
     if (ret != EOK) {
086f82
         DEBUG(SSSDBG_OP_FAILURE, "process_ext_groups failed.\n");
086f82
         goto fail;
086f82
     }
086f82
 
086f82
-    state->server_mode->ext_groups->ext_groups = ext_group_hash;
086f82
+    talloc_free(state->server_mode->ext_groups->ext_groups);
086f82
+    state->server_mode->ext_groups->ext_groups = talloc_steal(
086f82
+            state->server_mode->ext_groups,
086f82
+            ext_group_hash);
086f82
     /* Do we have to make the update timeout configurable? */
086f82
     state->server_mode->ext_groups->next_update = time(NULL) + 10;
086f82
 
086f82
-- 
086f82
2.17.0
086f82