dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0007-krb5_common-add-callback-only-once.patch

ca1eb8
From 54ea4576ba8cb8dfbefdd3ced29fc35f836afc61 Mon Sep 17 00:00:00 2001
ca1eb8
From: Sumit Bose <sbose@redhat.com>
ca1eb8
Date: Fri, 8 Jun 2018 08:29:04 +0200
ca1eb8
Subject: [PATCH] krb5_common: add callback only once
ca1eb8
ca1eb8
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
ca1eb8
(cherry picked from commit 4759a482781bcecdb0ad1119e74dcefa1fe94337)
ca1eb8
---
ca1eb8
 src/providers/krb5/krb5_common.c | 12 +++++++++++-
ca1eb8
 src/providers/krb5/krb5_common.h |  2 ++
ca1eb8
 2 files changed, 13 insertions(+), 1 deletion(-)
ca1eb8
ca1eb8
diff --git a/src/providers/krb5/krb5_common.c b/src/providers/krb5/krb5_common.c
ca1eb8
index c6896a6cd663da896075e72aa0a0602c198b45e8..d064a09ac3726c4185c2fa1eeac76ef6c261d33b 100644
ca1eb8
--- a/src/providers/krb5/krb5_common.c
ca1eb8
+++ b/src/providers/krb5/krb5_common.c
ca1eb8
@@ -399,6 +399,7 @@ static int remove_info_files_destructor(void *p)
ca1eb8
     if (ret != EOK) {
ca1eb8
         DEBUG(SSSDBG_CRIT_FAILURE, "remove_krb5_info_files failed.\n");
ca1eb8
     }
ca1eb8
+    ctx->krb5_service->removal_callback_available = false;
ca1eb8
 
ca1eb8
     return 0;
ca1eb8
 }
ca1eb8
@@ -407,7 +408,7 @@ static errno_t
ca1eb8
 krb5_add_krb5info_offline_callback(struct krb5_service *krb5_service)
ca1eb8
 {
ca1eb8
     int ret;
ca1eb8
-    struct remove_info_files_ctx *ctx;
ca1eb8
+    struct remove_info_files_ctx *ctx = NULL;
ca1eb8
 
ca1eb8
     if (krb5_service == NULL || krb5_service->name == NULL
ca1eb8
                              || krb5_service->realm == NULL
ca1eb8
@@ -416,6 +417,13 @@ krb5_add_krb5info_offline_callback(struct krb5_service *krb5_service)
ca1eb8
         return EINVAL;
ca1eb8
     }
ca1eb8
 
ca1eb8
+    if (krb5_service->removal_callback_available) {
ca1eb8
+        DEBUG(SSSDBG_TRACE_ALL,
ca1eb8
+              "Removal callback already available for service [%s].\n",
ca1eb8
+              krb5_service->name);
ca1eb8
+        return EOK;
ca1eb8
+    }
ca1eb8
+
ca1eb8
     ctx = talloc_zero(krb5_service->be_ctx, struct remove_info_files_ctx);
ca1eb8
     if (ctx == NULL) {
ca1eb8
         DEBUG(SSSDBG_CRIT_FAILURE, "talloc_zfree failed.\n");
ca1eb8
@@ -430,6 +438,7 @@ krb5_add_krb5info_offline_callback(struct krb5_service *krb5_service)
ca1eb8
     }
ca1eb8
 
ca1eb8
     ctx->be_ctx = krb5_service->be_ctx;
ca1eb8
+    ctx->krb5_service = krb5_service;
ca1eb8
     ctx->kdc_service_name = talloc_strdup(ctx, krb5_service->name);
ca1eb8
     if (ctx->kdc_service_name == NULL) {
ca1eb8
         DEBUG(SSSDBG_CRIT_FAILURE, "talloc_strdup failed!\n");
ca1eb8
@@ -445,6 +454,7 @@ krb5_add_krb5info_offline_callback(struct krb5_service *krb5_service)
ca1eb8
     }
ca1eb8
 
ca1eb8
     talloc_set_destructor((TALLOC_CTX *) ctx, remove_info_files_destructor);
ca1eb8
+    krb5_service->removal_callback_available = true;
ca1eb8
 
ca1eb8
     ret = EOK;
ca1eb8
 
ca1eb8
diff --git a/src/providers/krb5/krb5_common.h b/src/providers/krb5/krb5_common.h
ca1eb8
index a2e47b0605debdffa28305dab4f7674707f713ac..3529d740b89fee91281f936fdafd1bdb99e95bd7 100644
ca1eb8
--- a/src/providers/krb5/krb5_common.h
ca1eb8
+++ b/src/providers/krb5/krb5_common.h
ca1eb8
@@ -71,6 +71,7 @@ struct krb5_service {
ca1eb8
     char *name;
ca1eb8
     char *realm;
ca1eb8
     bool write_kdcinfo;
ca1eb8
+    bool removal_callback_available;
ca1eb8
 };
ca1eb8
 
ca1eb8
 struct fo_service;
ca1eb8
@@ -146,6 +147,7 @@ struct remove_info_files_ctx {
ca1eb8
     struct be_ctx *be_ctx;
ca1eb8
     const char *kdc_service_name;
ca1eb8
     const char *kpasswd_service_name;
ca1eb8
+    struct krb5_service *krb5_service;
ca1eb8
 };
ca1eb8
 
ca1eb8
 errno_t sss_krb5_check_options(struct dp_option *opts,
ca1eb8
-- 
ca1eb8
2.17.1
ca1eb8