dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0189-LDAP-unlink-ccname_file_dummy-if-there-is-an-error.patch

b725e7
From 8d6ecbc445e5b08b1a03c7fab6ea4e4a24e033d8 Mon Sep 17 00:00:00 2001
b725e7
From: Daniel Hjorth <dh@dhjorth.com>
b725e7
Date: Wed, 25 Feb 2015 13:07:35 -0700
b725e7
Subject: [PATCH 189/190] LDAP: unlink ccname_file_dummy if there is an error
b725e7
b725e7
https://fedorahosted.org/sssd/ticket/2592
b725e7
b725e7
If there is an error after ccname_file_dummy is created but before it is
b725e7
renamed then the file isn't removed.  This can cause a lot of files to be
b725e7
created and take up inodes in a filesystem.
b725e7
b725e7
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
b725e7
Reviewed-by: Sumit Bose <sbose@redhat.com>
b725e7
(cherry picked from commit 2b20ff2e33ad3993a9cad910c4b4b828513613df)
b725e7
---
b725e7
 src/providers/ldap/ldap_child.c | 12 +++++++++++-
b725e7
 1 file changed, 11 insertions(+), 1 deletion(-)
b725e7
b725e7
diff --git a/src/providers/ldap/ldap_child.c b/src/providers/ldap/ldap_child.c
b725e7
index f7f8d1d2eab3f66fe4f7d09e50458b495739c1d2..bb61a61858abba90530150ba771053fb8abff14a 100644
b725e7
--- a/src/providers/ldap/ldap_child.c
b725e7
+++ b/src/providers/ldap/ldap_child.c
b725e7
@@ -491,16 +491,26 @@ static krb5_error_code ldap_child_get_tgt_sync(TALLOC_CTX *memctx,
b725e7
               "rename failed [%d][%s].\n", ret, strerror(ret));
b725e7
         goto done;
b725e7
     }
b725e7
+    ccname_file_dummy = NULL;
b725e7
 
b725e7
     krberr = 0;
b725e7
     *ccname_out = talloc_steal(memctx, ccname);
b725e7
     *expire_time_out = my_creds.times.endtime - kdc_time_offset;
b725e7
 
b725e7
 done:
b725e7
-    talloc_free(tmp_ctx);
b725e7
     if (krberr != 0) KRB5_SYSLOG(krberr);
b725e7
     if (keytab) krb5_kt_close(context, keytab);
b725e7
     if (context) krb5_free_context(context);
b725e7
+    if (ccname_file_dummy) {
b725e7
+        DEBUG(SSSDBG_TRACE_INTERNAL, "Unlinking [%s]\n", ccname_file_dummy);
b725e7
+        ret = unlink(ccname_file_dummy);
b725e7
+        if (ret == -1) {
b725e7
+            ret = errno;
b725e7
+            DEBUG(SSSDBG_MINOR_FAILURE,
b725e7
+                  "Unlink failed [%d][%s].\n", ret, strerror(ret));
b725e7
+        }
b725e7
+    }
b725e7
+    talloc_free(tmp_ctx);
b725e7
     return krberr;
b725e7
 }
b725e7
 
b725e7
-- 
b725e7
2.1.0
b725e7