dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

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

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