]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
tstream_npa: Return named_pipe_auth_req_info4 from accept_existing
authorVolker Lendecke <vl@samba.org>
Mon, 18 Jan 2021 16:30:42 +0000 (17:30 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 1 Apr 2021 19:32:36 +0000 (19:32 +0000)
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>
libcli/named_pipe_auth/npa_tstream.c
libcli/named_pipe_auth/npa_tstream.h
librpc/idl/named_pipe_auth.idl
source3/rpc_server/rpc_server.c
source4/samba/service_named_pipe.c

index fa46740cffe50e112680c9c5535ab3e0f633f7ac..7ebafaa7ddca65bf5d7fd8ca698c7a51c9191348 100644 (file)
@@ -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));
index b7d11dea6d365c43ff119131cda82ae25bbf3c35..72174ea6bf3b7d806240fbb72590495b43ffc297 100644 (file)
@@ -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, \
index e5f0b1833a07b59c0fbcb3531e31c42099cad28c..27e4dd799a2904cf6c6a3b80711716dd5eb8c0a2 100644 (file)
@@ -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;
index adf2ba70628bbeb783b13af5d1c2fd845b08b715..01350d67283163c4f892b421f35eb05eb7a668ef 100644 (file)
@@ -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,
index 7ba57e24fe864dfd4b6150abed99f34ab59dcda2..de7d61b47eb79236763e5e701b17354ea2d496d6 100644 (file)
@@ -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,