From 5c84f945e0fe5e41d706fd7f700392214178b6aa Mon Sep 17 00:00:00 2001
From: Simo Sorce <simo@redhat.com>
Date: Wed, 22 Mar 2017 18:25:38 -0400
Subject: [PATCH] Avoid growing FILE ccaches unnecessarily
Related https://pagure.io/freeipa/issue/6775
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
---
ipapython/session_storage.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/ipapython/session_storage.py b/ipapython/session_storage.py
index 7fe17fb235614e687a88c090336d3c59a7a24aac..a88f9f7a75c73d4dc753183a100350d197d02199 100644
--- a/ipapython/session_storage.py
+++ b/ipapython/session_storage.py
@@ -104,6 +104,12 @@ def store_data(princ_name, key, value):
"""
Stores the session cookie in a hidden ccache entry.
"""
+ # FILE ccaches grow every time an entry is stored, so we need
+ # to avoid storing the same entry multiple times.
+ oldvalue = get_data(princ_name, key)
+ if oldvalue == value:
+ return
+
context = krb5_context()
principal = krb5_principal()
ccache = krb5_ccache()
--
2.12.1