diff options
author | Volker Lendecke <vl@samba.org> | 2021-01-18 17:30:42 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2021-04-01 19:32:36 +0000 |
commit | bbfdf2708e8e85cee56aeff43c9216d2003ed310 (patch) | |
tree | 681e34460819cdfa3db7384b1823eb0ca5b89530 | |
parent | 3a03c0a1ad7ea81d9dcae88016c42a1f9e000b47 (diff) | |
download | samba-bbfdf2708e8e85cee56aeff43c9216d2003ed310.tar.gz |
tstream_npa: Return named_pipe_auth_req_info4 from accept_existing
Callers might want the full picture. We need to make
named_pipe_auth_req_info4 public for that.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r-- | libcli/named_pipe_auth/npa_tstream.c | 78 | ||||
-rw-r--r-- | libcli/named_pipe_auth/npa_tstream.h | 25 | ||||
-rw-r--r-- | librpc/idl/named_pipe_auth.idl | 2 | ||||
-rw-r--r-- | source3/rpc_server/rpc_server.c | 1 | ||||
-rw-r--r-- | source4/samba/service_named_pipe.c | 1 |
5 files changed, 86 insertions, 21 deletions
diff --git a/libcli/named_pipe_auth/npa_tstream.c b/libcli/named_pipe_auth/npa_tstream.c index fa46740cffe..7ebafaa7ddc 100644 --- a/libcli/named_pipe_auth/npa_tstream.c +++ b/libcli/named_pipe_auth/npa_tstream.c @@ -1236,16 +1236,58 @@ static void tstream_npa_accept_existing_done(struct tevent_req *subreq) tevent_req_done(req); } -int _tstream_npa_accept_existing_recv(struct tevent_req *req, - int *perrno, - TALLOC_CTX *mem_ctx, - struct tstream_context **stream, - struct tsocket_address **remote_client_addr, - char **_remote_client_name, - struct tsocket_address **local_server_addr, - char **local_server_name, - struct auth_session_info_transport **session_info, - const char *location) +static struct named_pipe_auth_req_info4 *copy_npa_info4( + TALLOC_CTX *mem_ctx, const struct named_pipe_auth_req_info4 *src) +{ + struct named_pipe_auth_req_info4 *dst = NULL; + DATA_BLOB blob; + enum ndr_err_code ndr_err; + + dst = talloc_zero(mem_ctx, struct named_pipe_auth_req_info4); + if (dst == NULL) { + return NULL; + } + + ndr_err = ndr_push_struct_blob( + &blob, + dst, + src, + (ndr_push_flags_fn_t)ndr_push_named_pipe_auth_req_info4); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DBG_WARNING("ndr_push_named_pipe_auth_req_info4 failed: %s\n", + ndr_errstr(ndr_err)); + TALLOC_FREE(dst); + return NULL; + } + + ndr_err = ndr_pull_struct_blob_all( + &blob, + dst, + dst, + (ndr_pull_flags_fn_t)ndr_pull_named_pipe_auth_req_info4); + TALLOC_FREE(blob.data); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DBG_WARNING("ndr_push_named_pipe_auth_req_info4 failed: %s\n", + ndr_errstr(ndr_err)); + TALLOC_FREE(dst); + return NULL; + } + + return dst; +} + +int _tstream_npa_accept_existing_recv( + struct tevent_req *req, + int *perrno, + TALLOC_CTX *mem_ctx, + struct tstream_context **stream, + struct named_pipe_auth_req_info4 **info4, + struct tsocket_address **remote_client_addr, + char **_remote_client_name, + struct tsocket_address **local_server_addr, + char **local_server_name, + struct auth_session_info_transport **session_info, + const char *location) { struct tstream_npa_accept_state *state = tevent_req_data(req, struct tstream_npa_accept_state); @@ -1290,6 +1332,22 @@ int _tstream_npa_accept_existing_recv(struct tevent_req *req, npas->unix_stream = state->plain; npas->file_type = state->file_type; + if (info4 != NULL) { + /* + * Make a full copy of "info4" because further down we + * talloc_move() away substructures from + * state->pipe_request. + */ + struct named_pipe_auth_req_info4 *dst = copy_npa_info4( + mem_ctx, i4); + if (dst == NULL) { + *perrno = ENOMEM; + tevent_req_received(req); + return -1; + } + *info4 = dst; + } + *remote_client_addr = talloc_move(mem_ctx, &state->remote_client_addr); *_remote_client_name = discard_const_p( char, talloc_move(mem_ctx, &i4->remote_client_name)); diff --git a/libcli/named_pipe_auth/npa_tstream.h b/libcli/named_pipe_auth/npa_tstream.h index b7d11dea6d3..72174ea6bf3 100644 --- a/libcli/named_pipe_auth/npa_tstream.h +++ b/libcli/named_pipe_auth/npa_tstream.h @@ -24,6 +24,7 @@ struct tevent_req; struct tevent_context; struct auth_session_info_transport; struct tsocket_address; +struct named_pipe_auth_req_info4; struct tevent_req *tstream_npa_connect_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, @@ -95,18 +96,21 @@ struct tevent_req *tstream_npa_accept_existing_send(TALLOC_CTX *mem_ctx, * * @return 0 if successful, -1 on failure with *perror filled. */ -int _tstream_npa_accept_existing_recv(struct tevent_req *req, - int *perrno, - TALLOC_CTX *mem_ctx, - struct tstream_context **stream, - struct tsocket_address **remote_client_addr, - char **_remote_client_name, - struct tsocket_address **local_server_addr, - char **local_server_name, - struct auth_session_info_transport **session_info, - const char *location); +int _tstream_npa_accept_existing_recv( + struct tevent_req *req, + int *perrno, + TALLOC_CTX *mem_ctx, + struct tstream_context **stream, + struct named_pipe_auth_req_info4 **info4, + struct tsocket_address **remote_client_addr, + char **_remote_client_name, + struct tsocket_address **local_server_addr, + char **local_server_name, + struct auth_session_info_transport **session_info, + const char *location); #define tstream_npa_accept_existing_recv(req, perrno, \ mem_ctx, stream, \ + info4, \ remote_client_addr, \ remote_client_name, \ local_server_addr, \ @@ -114,6 +118,7 @@ int _tstream_npa_accept_existing_recv(struct tevent_req *req, session_info) \ _tstream_npa_accept_existing_recv(req, perrno, \ mem_ctx, stream, \ + info4, \ remote_client_addr, \ remote_client_name, \ local_server_addr, \ diff --git a/librpc/idl/named_pipe_auth.idl b/librpc/idl/named_pipe_auth.idl index e5f0b1833a0..27e4dd799a2 100644 --- a/librpc/idl/named_pipe_auth.idl +++ b/librpc/idl/named_pipe_auth.idl @@ -12,7 +12,7 @@ interface named_pipe_auth { const char *NAMED_PIPE_AUTH_MAGIC = "NPAM"; - typedef struct { + typedef [public] struct { [charset(UTF8),string] uint8 *remote_client_name; [charset(DOS),string] uint8 *remote_client_addr; uint16 remote_client_port; diff --git a/source3/rpc_server/rpc_server.c b/source3/rpc_server/rpc_server.c index adf2ba70628..01350d67283 100644 --- a/source3/rpc_server/rpc_server.c +++ b/source3/rpc_server/rpc_server.c @@ -368,6 +368,7 @@ static void dcesrv_ncacn_np_accept_done(struct tevent_req *subreq) ret = tstream_npa_accept_existing_recv(subreq, &error, ncacn_conn, &ncacn_conn->tstream, + NULL, &ncacn_conn->remote_client_addr, &ncacn_conn->remote_client_name, &ncacn_conn->local_server_addr, diff --git a/source4/samba/service_named_pipe.c b/source4/samba/service_named_pipe.c index 7ba57e24fe8..de7d61b47eb 100644 --- a/source4/samba/service_named_pipe.c +++ b/source4/samba/service_named_pipe.c @@ -106,6 +106,7 @@ static void named_pipe_accept_done(struct tevent_req *subreq) ret = tstream_npa_accept_existing_recv(subreq, &error, tmp_ctx, &conn->tstream, + NULL, &remote_client_addr, &remote_client_name, &local_server_addr, |