Blame SOURCES/0080-autofs-use-cache_req-to-obtain-map-in-setent.patch

5cd47f
From 61a7bf4d2a93f99a5c94da4367d350f8038bb935 Mon Sep 17 00:00:00 2001
5cd47f
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
5cd47f
Date: Wed, 14 Aug 2019 11:41:56 +0200
5cd47f
Subject: [PATCH 80/90] autofs: use cache_req to obtain map in setent
5cd47f
MIME-Version: 1.0
5cd47f
Content-Type: text/plain; charset=UTF-8
5cd47f
Content-Transfer-Encoding: 8bit
5cd47f
5cd47f
Resolves:
5cd47f
https://pagure.io/SSSD/sssd/issue/2607
5cd47f
5cd47f
Reviewed-by: Tomáš Halman <thalman@redhat.com>
5cd47f
---
5cd47f
 src/responder/autofs/autofssrv_cmd.c | 18 ++++++++++--------
5cd47f
 1 file changed, 10 insertions(+), 8 deletions(-)
5cd47f
5cd47f
diff --git a/src/responder/autofs/autofssrv_cmd.c b/src/responder/autofs/autofssrv_cmd.c
5cd47f
index 59e64014d..d413f8570 100644
5cd47f
--- a/src/responder/autofs/autofssrv_cmd.c
5cd47f
+++ b/src/responder/autofs/autofssrv_cmd.c
5cd47f
@@ -365,7 +365,7 @@ autofs_read_setautomntent_input(struct cli_ctx *cli_ctx,
5cd47f
 
5cd47f
 static errno_t
5cd47f
 autofs_write_setautomntent_output(struct cli_ctx *cli_ctx,
5cd47f
-                                  struct autofs_enum_ctx *enum_ctx)
5cd47f
+                                  struct cache_req_result *result)
5cd47f
 {
5cd47f
     struct cli_protocol *pctx;
5cd47f
     uint8_t *body;
5cd47f
@@ -380,7 +380,7 @@ autofs_write_setautomntent_output(struct cli_ctx *cli_ctx,
5cd47f
         return ret;
5cd47f
     }
5cd47f
 
5cd47f
-    if (!enum_ctx->found) {
5cd47f
+    if (result == NULL || result->count == 0) {
5cd47f
         DEBUG(SSSDBG_TRACE_FUNC, "Map was not found\n");
5cd47f
         return sss_cmd_empty_packet(pctx->creq->out);
5cd47f
     }
5cd47f
@@ -430,11 +430,13 @@ sss_autofs_cmd_setautomntent(struct cli_ctx *cli_ctx)
5cd47f
         goto done;
5cd47f
     }
5cd47f
 
5cd47f
-    DEBUG(SSSDBG_TRACE_FUNC, "Creating enumeration context for %s\n",
5cd47f
+    DEBUG(SSSDBG_TRACE_FUNC, "Obtaining autofs map %s\n",
5cd47f
           cmd_ctx->mapname);
5cd47f
 
5cd47f
-    req = autofs_setent_send(cli_ctx, cli_ctx->ev, autofs_ctx,
5cd47f
-                             cmd_ctx->mapname);
5cd47f
+    req = cache_req_autofs_map_by_name_send(cli_ctx, cli_ctx->ev,
5cd47f
+                                            autofs_ctx->rctx,
5cd47f
+                                            autofs_ctx->rctx->ncache, 0, NULL,
5cd47f
+                                            cmd_ctx->mapname);
5cd47f
     if (req == NULL) {
5cd47f
         DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create tevent request\n");
5cd47f
         ret = ENOMEM;
5cd47f
@@ -452,20 +454,20 @@ done:
5cd47f
 static void
5cd47f
 sss_autofs_cmd_setautomntent_done(struct tevent_req *req)
5cd47f
 {
5cd47f
-    struct autofs_enum_ctx *enum_ctx;
5cd47f
+    struct cache_req_result *result;
5cd47f
     struct autofs_cmd_ctx *cmd_ctx;
5cd47f
     errno_t ret;
5cd47f
 
5cd47f
     cmd_ctx = tevent_req_callback_data(req, struct autofs_cmd_ctx);
5cd47f
 
5cd47f
-    ret = autofs_setent_recv(req, &enum_ctx);
5cd47f
+    ret = cache_req_autofs_map_by_name_recv(cmd_ctx, req, &result);
5cd47f
     talloc_zfree(req);
5cd47f
     if (ret != EOK) {
5cd47f
         autofs_cmd_done(cmd_ctx, ret);
5cd47f
         return;
5cd47f
     }
5cd47f
 
5cd47f
-    ret = autofs_write_setautomntent_output(cmd_ctx->cli_ctx, enum_ctx);
5cd47f
+    ret = autofs_write_setautomntent_output(cmd_ctx->cli_ctx, result);
5cd47f
     if (ret != EOK) {
5cd47f
         DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create reply packet "
5cd47f
               "[%d]: %s\n", ret, sss_strerror(ret));
5cd47f
-- 
5cd47f
2.20.1
5cd47f