Blame SOURCES/0021-KCM-Pass-confdb-context-to-the-ccache-db-initializat.patch

d6181b
From f00db73d7bbf312e3e2a772b8b10895d5460b989 Mon Sep 17 00:00:00 2001
d6181b
From: Jakub Hrozek <jhrozek@redhat.com>
d6181b
Date: Wed, 28 Nov 2018 21:24:08 +0100
d6181b
Subject: [PATCH 21/23] KCM: Pass confdb context to the ccache db
d6181b
 initialization
d6181b
MIME-Version: 1.0
d6181b
Content-Type: text/plain; charset=UTF-8
d6181b
Content-Transfer-Encoding: 8bit
d6181b
d6181b
Resolves:
d6181b
https://pagure.io/SSSD/sssd/issue/3386
d6181b
d6181b
The libsecrets back end needs to read the quota options from confdb,
d6181b
therefore it needs to know the section and access the confdb handle.
d6181b
d6181b
These parameters are unused for other ccache back end types, but they
d6181b
are harmless and IMO it makes more sense to keep the ccache back end
d6181b
abstract.
d6181b
d6181b
Reviewed-by: Michal Židek <mzidek@redhat.com>
d6181b
---
d6181b
 src/responder/kcm/kcm.c                   | 14 ++++++++++++--
d6181b
 src/responder/kcm/kcmsrv_ccache.c         |  4 +++-
d6181b
 src/responder/kcm/kcmsrv_ccache.h         |  2 ++
d6181b
 src/responder/kcm/kcmsrv_ccache_be.h      |  4 +++-
d6181b
 src/responder/kcm/kcmsrv_ccache_mem.c     |  4 +++-
d6181b
 src/responder/kcm/kcmsrv_ccache_secdb.c   |  6 +++---
d6181b
 src/responder/kcm/kcmsrv_ccache_secrets.c |  4 +++-
d6181b
 7 files changed, 29 insertions(+), 9 deletions(-)
d6181b
d6181b
diff --git a/src/responder/kcm/kcm.c b/src/responder/kcm/kcm.c
d6181b
index 005dd168f..045c7801f 100644
d6181b
--- a/src/responder/kcm/kcm.c
d6181b
+++ b/src/responder/kcm/kcm.c
d6181b
@@ -170,6 +170,8 @@ static int kcm_data_destructor(void *ptr)
d6181b
 
d6181b
 static struct kcm_resp_ctx *kcm_data_setup(TALLOC_CTX *mem_ctx,
d6181b
                                            struct tevent_context *ev,
d6181b
+                                           struct confdb_ctx *cdb,
d6181b
+                                           const char *confdb_service_path,
d6181b
                                            enum kcm_ccdb_be cc_be)
d6181b
 {
d6181b
     struct kcm_resp_ctx *kcm_data;
d6181b
@@ -181,7 +183,11 @@ static struct kcm_resp_ctx *kcm_data_setup(TALLOC_CTX *mem_ctx,
d6181b
         return NULL;
d6181b
     }
d6181b
 
d6181b
-    kcm_data->db = kcm_ccdb_init(kcm_data, ev, cc_be);
d6181b
+    kcm_data->db = kcm_ccdb_init(kcm_data,
d6181b
+                                 ev,
d6181b
+                                 cdb,
d6181b
+                                 confdb_service_path,
d6181b
+                                 cc_be);
d6181b
     if (kcm_data->db == NULL) {
d6181b
         talloc_free(kcm_data);
d6181b
         return NULL;
d6181b
@@ -235,7 +241,11 @@ static int kcm_process_init(TALLOC_CTX *mem_ctx,
d6181b
         goto fail;
d6181b
     }
d6181b
 
d6181b
-    kctx->kcm_data = kcm_data_setup(kctx, ev, kctx->cc_be);
d6181b
+    kctx->kcm_data = kcm_data_setup(kctx,
d6181b
+                                    ev,
d6181b
+                                    kctx->rctx->cdb,
d6181b
+                                    kctx->rctx->confdb_service_path,
d6181b
+                                    kctx->cc_be);
d6181b
     if (kctx->kcm_data == NULL) {
d6181b
         DEBUG(SSSDBG_FATAL_FAILURE,
d6181b
               "fatal error initializing responder data\n");
d6181b
diff --git a/src/responder/kcm/kcmsrv_ccache.c b/src/responder/kcm/kcmsrv_ccache.c
d6181b
index e7800662a..085cc4464 100644
d6181b
--- a/src/responder/kcm/kcmsrv_ccache.c
d6181b
+++ b/src/responder/kcm/kcmsrv_ccache.c
d6181b
@@ -229,6 +229,8 @@ struct sss_iobuf *kcm_cred_get_creds(struct kcm_cred *crd)
d6181b
 
d6181b
 struct kcm_ccdb *kcm_ccdb_init(TALLOC_CTX *mem_ctx,
d6181b
                                struct tevent_context *ev,
d6181b
+                               struct confdb_ctx *cdb,
d6181b
+                               const char *confdb_service_path,
d6181b
                                enum kcm_ccdb_be cc_be)
d6181b
 {
d6181b
     errno_t ret;
d6181b
@@ -270,7 +272,7 @@ struct kcm_ccdb *kcm_ccdb_init(TALLOC_CTX *mem_ctx,
d6181b
         return NULL;
d6181b
     }
d6181b
 
d6181b
-    ret = ccdb->ops->init(ccdb);
d6181b
+    ret = ccdb->ops->init(ccdb, cdb, confdb_service_path);
d6181b
     if (ret != EOK) {
d6181b
         DEBUG(SSSDBG_CRIT_FAILURE, "Cannot initialize ccache database\n");
d6181b
         talloc_free(ccdb);
d6181b
diff --git a/src/responder/kcm/kcmsrv_ccache.h b/src/responder/kcm/kcmsrv_ccache.h
d6181b
index 0fd33325f..199b75b16 100644
d6181b
--- a/src/responder/kcm/kcmsrv_ccache.h
d6181b
+++ b/src/responder/kcm/kcmsrv_ccache.h
d6181b
@@ -125,6 +125,8 @@ struct kcm_ccdb;
d6181b
  */
d6181b
 struct kcm_ccdb *kcm_ccdb_init(TALLOC_CTX *mem_ctx,
d6181b
                                struct tevent_context *ev,
d6181b
+                               struct confdb_ctx *cdb,
d6181b
+                               const char *confdb_service_path,
d6181b
                                enum kcm_ccdb_be cc_be);
d6181b
 
d6181b
 /*
d6181b
diff --git a/src/responder/kcm/kcmsrv_ccache_be.h b/src/responder/kcm/kcmsrv_ccache_be.h
d6181b
index 7315f6435..166af3a76 100644
d6181b
--- a/src/responder/kcm/kcmsrv_ccache_be.h
d6181b
+++ b/src/responder/kcm/kcmsrv_ccache_be.h
d6181b
@@ -30,7 +30,9 @@
d6181b
 #include "responder/kcm/kcmsrv_ccache.h"
d6181b
 
d6181b
 typedef errno_t
d6181b
-(*ccdb_init_fn)(struct kcm_ccdb *db);
d6181b
+(*ccdb_init_fn)(struct kcm_ccdb *db,
d6181b
+                struct confdb_ctx *cdb,
d6181b
+                const char *confdb_service_path);
d6181b
 
d6181b
 typedef struct tevent_req *
d6181b
 (*ccdb_nextid_send_fn)(TALLOC_CTX *mem_ctx,
d6181b
diff --git a/src/responder/kcm/kcmsrv_ccache_mem.c b/src/responder/kcm/kcmsrv_ccache_mem.c
d6181b
index 38bc2050d..35955b2f4 100644
d6181b
--- a/src/responder/kcm/kcmsrv_ccache_mem.c
d6181b
+++ b/src/responder/kcm/kcmsrv_ccache_mem.c
d6181b
@@ -151,7 +151,9 @@ static int ccwrap_destructor(void *ptr)
d6181b
     return 0;
d6181b
 }
d6181b
 
d6181b
-static errno_t ccdb_mem_init(struct kcm_ccdb *db)
d6181b
+static errno_t ccdb_mem_init(struct kcm_ccdb *db,
d6181b
+                             struct confdb_ctx *cdb,
d6181b
+                             const char *confdb_service_path)
d6181b
 {
d6181b
     struct ccdb_mem *memdb = NULL;
d6181b
 
d6181b
diff --git a/src/responder/kcm/kcmsrv_ccache_secdb.c b/src/responder/kcm/kcmsrv_ccache_secdb.c
d6181b
index c68f53f97..d0d9a7e4c 100644
d6181b
--- a/src/responder/kcm/kcmsrv_ccache_secdb.c
d6181b
+++ b/src/responder/kcm/kcmsrv_ccache_secdb.c
d6181b
@@ -520,7 +520,9 @@ done:
d6181b
     return ret;
d6181b
 }
d6181b
 
d6181b
-static errno_t ccdb_secdb_init(struct kcm_ccdb *db)
d6181b
+static errno_t ccdb_secdb_init(struct kcm_ccdb *db,
d6181b
+                               struct confdb_ctx *cdb,
d6181b
+                               const char *confdb_service_path)
d6181b
 {
d6181b
     struct ccdb_secdb *secdb = NULL;
d6181b
     errno_t ret;
d6181b
@@ -530,8 +532,6 @@ static errno_t ccdb_secdb_init(struct kcm_ccdb *db)
d6181b
         return ENOMEM;
d6181b
     }
d6181b
 
d6181b
-    /* TODO: read configuration from the config file, adjust quotas */
d6181b
-
d6181b
     ret = sss_sec_init(db, NULL, &secdb->sctx);
d6181b
     if (ret != EOK) {
d6181b
         DEBUG(SSSDBG_CRIT_FAILURE,
d6181b
diff --git a/src/responder/kcm/kcmsrv_ccache_secrets.c b/src/responder/kcm/kcmsrv_ccache_secrets.c
d6181b
index 93be4fafa..6fa2a6dcc 100644
d6181b
--- a/src/responder/kcm/kcmsrv_ccache_secrets.c
d6181b
+++ b/src/responder/kcm/kcmsrv_ccache_secrets.c
d6181b
@@ -659,7 +659,9 @@ static errno_t sec_get_ccache_recv(struct tevent_req *req,
d6181b
 /*
d6181b
  * The actual sssd-secrets back end
d6181b
  */
d6181b
-static errno_t ccdb_sec_init(struct kcm_ccdb *db)
d6181b
+static errno_t ccdb_sec_init(struct kcm_ccdb *db,
d6181b
+                             struct confdb_ctx *cdb,
d6181b
+                             const char *confdb_service_path)
d6181b
 {
d6181b
     struct ccdb_sec *secdb = NULL;
d6181b
 
d6181b
-- 
d6181b
2.20.1
d6181b