From: Stefan Metzmacher Date: Thu, 11 Jun 2026 13:01:15 +0000 (+0200) Subject: s3:rpc_client: add probe_only argument to local_np_connect[_send]() X-Git-Tag: talloc-2.5.0~66 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f477ddef79ac38ec56f0aa4225eb21bc78f4013b;p=thirdparty%2Fsamba.git s3:rpc_client: add probe_only argument to local_np_connect[_send]() 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 Reviewed-by: Volker Lendecke --- diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index 81339ad0c20..babcab71003 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -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) { diff --git a/source3/rpc_client/local_np.c b/source3/rpc_client/local_np.c index e66e375f484..4c8127a4eca 100644 --- a/source3/rpc_client/local_np.c +++ b/source3/rpc_client/local_np.c @@ -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; } diff --git a/source3/rpc_client/local_np.h b/source3/rpc_client/local_np.h index 093faad151c..d7cf5df2dc9 100644 --- a/source3/rpc_client/local_np.h +++ b/source3/rpc_client/local_np.h @@ -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); diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 04f6b86d0c6..ed379c011b2 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -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) {