]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:rpc_client: add probe_only argument to local_np_connect[_send]()
authorStefan Metzmacher <metze@samba.org>
Thu, 11 Jun 2026 13:01:15 +0000 (15:01 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 24 Jul 2026 13:33:36 +0000 (13:33 +0000)
This will cause SAMBA_NPA_FLAGS_PROBE_ONLY to be passed to
the named pipe server and let local_np_connect_recv()
return EEXIST instead of tstream_context.

This will be used to implement FSCTL_PIPE_WAIT.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/rpc_client/cli_pipe.c
source3/rpc_client/local_np.c
source3/rpc_client/local_np.h
source3/rpc_server/srv_pipe_hnd.c

index 81339ad0c20a3e0892ff8b9f9738be1231836072..babcab71003b46bab5017cfa4e0381c90080686b 100644 (file)
@@ -3670,7 +3670,8 @@ NTSTATUS rpc_pipe_open_local_np(
                local_server_name,
                local_server_addr,
                session_info,
-               true,
+               true,  /* need_idle_server */
+               false, /* probe_only */
                conn,
                &npa_stream);
        if (ret != 0) {
index e66e375f484f6121c1503f8f25a9f13b3afd7755..4c8127a4ecab91c166b09958503056d5d5efe3d6 100644 (file)
@@ -459,6 +459,7 @@ struct local_np_connect_state {
        struct tevent_context *ev;
        const char *socketpath;
        struct named_pipe_auth_req *npa_req;
+       bool probe_only;
        struct tstream_context *npa_stream;
 };
 
@@ -481,6 +482,7 @@ static void local_np_connect_retried(struct tevent_req *subreq);
  * @param[in] local_server_addr The server addr to transmit
  * @param[in] session_info The authorization info to use
  * @param[in] need_idle_server Does this need to be an exclusive server?
+ * @param[in] probe_only Only check the pipename for EEXIST
  * @return The tevent_req that was started
  */
 
@@ -494,7 +496,8 @@ struct tevent_req *local_np_connect_send(
        const char *local_server_name,
        const struct tsocket_address *local_server_addr,
        const struct auth_session_info *session_info,
-       bool need_idle_server)
+       bool need_idle_server,
+       bool probe_only)
 {
        struct tevent_req *req = NULL, *subreq = NULL;
        struct local_np_connect_state *state = NULL;
@@ -514,6 +517,7 @@ struct tevent_req *local_np_connect_send(
                return NULL;
        }
        state->ev = ev;
+       state->probe_only = probe_only;
 
        num_npa_sids =
                security_token_count_flag_sids(session_info->security_token,
@@ -643,6 +647,10 @@ struct tevent_req *local_np_connect_send(
                npa_flags |= SAMBA_NPA_FLAGS_NEED_IDLE;
        }
 
+       if (probe_only) {
+               npa_flags |= SAMBA_NPA_FLAGS_PROBE_ONLY;
+       }
+
        ok = winbind_env_set();
        if (ok) {
                npa_flags |= SAMBA_NPA_FLAGS_WINBIND_OFF;
@@ -786,7 +794,13 @@ int local_np_connect_recv(
                return err;
        }
 
+       if (state->probe_only) {
+               tevent_req_received(req);
+               return EEXIST;
+       }
+
        *pstream = talloc_move(mem_ctx, &state->npa_stream);
+       tevent_req_received(req);
        return 0;
 }
 
@@ -816,6 +830,7 @@ int local_np_connect(
        const struct tsocket_address *local_server_addr,
        const struct auth_session_info *session_info,
        bool need_idle_server,
+       bool probe_only,
        TALLOC_CTX *mem_ctx,
        struct tstream_context **pstream)
 {
@@ -837,7 +852,8 @@ int local_np_connect(
                local_server_name,
                local_server_addr,
                session_info,
-               need_idle_server);
+               need_idle_server,
+               probe_only);
        if (req == NULL) {
                goto fail;
        }
index 093faad151cfffe9a4f2960f918519061e2531e1..d7cf5df2dc9cfb2a4fef8bba3f1abad1cda3e144 100644 (file)
@@ -34,7 +34,8 @@ struct tevent_req *local_np_connect_send(
        const char *local_server_name,
        const struct tsocket_address *local_server_addr,
        const struct auth_session_info *session_info,
-       bool need_idle_server);
+       bool need_idle_server,
+       bool probe_only);
 
 int local_np_connect_recv(
        struct tevent_req *req,
@@ -50,6 +51,7 @@ int local_np_connect(
        const struct tsocket_address *local_server_addr,
        const struct auth_session_info *session_info,
        bool need_idle_server,
+       bool probe_only,
        TALLOC_CTX *mem_ctx,
        struct tstream_context **stream);
 
index 04f6b86d0c67430b9555646b93924a08069611b5..ed379c011b2affb8a4e5968e7ec36af1e92ab098 100644 (file)
@@ -83,7 +83,8 @@ NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
                NULL,
                local_server_address,
                session_info,
-               false,
+               false, /* need_idle_server */
+               false, /* probe_only */
                npa,
                &npa->stream);
        if (ret != 0) {