Blob Blame History Raw
From 4665606235605b1d5d1ec7462257aaa86aa3d7b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Wed, 28 Aug 2019 11:47:07 +0200
Subject: [PATCH 74/90] autofs: move data provider functions to responder
 common code
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

So it can be later used from cache_req.

Resolves:
https://pagure.io/SSSD/sssd/issue/2607

Reviewed-by: Tomáš Halman <thalman@redhat.com>
---
 Makefile.am                                   |  2 +-
 src/responder/common/responder.h              | 19 +++++++++++
 .../responder_dp_autofs.c}                    |  0
 src/tests/cmocka/common_mock_resp_dp.c        | 34 +++++++++++++++++++
 4 files changed, 54 insertions(+), 1 deletion(-)
 rename src/responder/{autofs/autofssrv_dp.c => common/responder_dp_autofs.c} (100%)

diff --git a/Makefile.am b/Makefile.am
index e74de422d..c109afe56 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -576,6 +576,7 @@ SSSD_RESPONDER_OBJ = \
     src/responder/common/responder_common.c \
     src/responder/common/responder_dp.c \
     src/responder/common/responder_dp_ssh.c \
+    src/responder/common/responder_dp_autofs.c \
     src/responder/common/responder_packet.c \
     src/responder/common/responder_get_domains.c \
     src/responder/common/responder_utils.c \
@@ -1434,7 +1435,6 @@ if BUILD_AUTOFS
 sssd_autofs_SOURCES = \
     src/responder/autofs/autofssrv.c \
     src/responder/autofs/autofssrv_cmd.c \
-    src/responder/autofs/autofssrv_dp.c \
     $(SSSD_RESPONDER_OBJ)
 sssd_autofs_LDADD = \
     $(LIBADD_DL) \
diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h
index 987a5d17d..17b04c3de 100644
--- a/src/responder/common/responder.h
+++ b/src/responder/common/responder.h
@@ -363,6 +363,25 @@ sss_dp_get_ssh_host_recv(TALLOC_CTX *mem_ctx,
                          dbus_uint32_t *dp_ret,
                          char **err_msg);
 
+enum sss_dp_autofs_type {
+    SSS_DP_AUTOFS
+};
+
+struct tevent_req *
+sss_dp_get_autofs_send(TALLOC_CTX *mem_ctx,
+                       struct resp_ctx *rctx,
+                       struct sss_domain_info *dom,
+                       bool fast_reply,
+                       enum sss_dp_autofs_type type,
+                       const char *name);
+
+errno_t
+sss_dp_get_autofs_recv(TALLOC_CTX *mem_ctx,
+                       struct tevent_req *req,
+                       dbus_uint16_t *dp_err,
+                       dbus_uint32_t *dp_ret,
+                       char **err_msg);
+
 bool sss_utf8_check(const uint8_t *s, size_t n);
 
 void responder_set_fd_limit(rlim_t fd_limit);
diff --git a/src/responder/autofs/autofssrv_dp.c b/src/responder/common/responder_dp_autofs.c
similarity index 100%
rename from src/responder/autofs/autofssrv_dp.c
rename to src/responder/common/responder_dp_autofs.c
diff --git a/src/tests/cmocka/common_mock_resp_dp.c b/src/tests/cmocka/common_mock_resp_dp.c
index a85257515..93e507100 100644
--- a/src/tests/cmocka/common_mock_resp_dp.c
+++ b/src/tests/cmocka/common_mock_resp_dp.c
@@ -95,6 +95,40 @@ sss_dp_get_ssh_host_recv(TALLOC_CTX *mem_ctx,
     return test_request_recv(req);
 }
 
+struct tevent_req *
+sss_dp_get_autofs_send(TALLOC_CTX *mem_ctx,
+                       struct resp_ctx *rctx,
+                       struct sss_domain_info *dom,
+                       bool fast_reply,
+                       enum sss_dp_autofs_type type,
+                       const char *mapname,
+                       const char *entryname)
+{
+    return test_req_succeed_send(mem_ctx, rctx->ev);
+}
+
+
+errno_t
+sss_dp_get_autofs_recv(TALLOC_CTX *mem_ctx,
+                       struct tevent_req *req,
+                       dbus_uint16_t *dp_err,
+                       dbus_uint32_t *dp_ret,
+                       char **err_msg)
+{
+    acct_cb_t cb;
+
+    *dp_err = sss_mock_type(dbus_uint16_t);
+    *dp_ret = sss_mock_type(dbus_uint32_t);
+    *err_msg = sss_mock_ptr_type(char *);
+
+    cb = sss_mock_ptr_type(acct_cb_t);
+    if (cb) {
+        (cb)(sss_mock_ptr_type(void *));
+    }
+
+    return test_request_recv(req);
+}
+
 errno_t
 sss_dp_req_recv(TALLOC_CTX *mem_ctx,
                 struct tevent_req *req,
-- 
2.20.1