From defcf0eecfb8eb035d9ca80530720b9e6873f6c7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 12 Jul 2008 12:20:08 +0200 Subject: [PATCH] Refactor make_internal_rpc_pipe_p: connection_struct is not needed --- source/include/ntdomain.h | 7 +++++-- source/include/proto.h | 4 ++++ source/rpc_server/srv_pipe_hnd.c | 32 +++++++++++--------------------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/source/include/ntdomain.h b/source/include/ntdomain.h index 23bbe9aba26..484f173afed 100644 --- a/source/include/ntdomain.h +++ b/source/include/ntdomain.h @@ -318,8 +318,11 @@ typedef struct smb_np_struct { * returns: state information representing the connection. * is stored in np_state, above. */ - void * (*namedpipe_create)(const char *pipe_name, - connection_struct *conn, uint16 vuid); + struct pipes_struct *(*namedpipe_create)( + const char *pipe_name, + const char *client_address, + struct auth_serversupplied_info *server_info, + uint16_t vuid); /* call to perform a write namedpipe operation */ diff --git a/source/include/proto.h b/source/include/proto.h index 47986ee5efb..6e503efaddb 100644 --- a/source/include/proto.h +++ b/source/include/proto.h @@ -8845,6 +8845,10 @@ bool close_rpc_pipe_hnd(smb_np_struct *p); void pipe_close_conn(connection_struct *conn); smb_np_struct *get_rpc_pipe_p(uint16 pnum); smb_np_struct *get_rpc_pipe(int pnum); +struct pipes_struct *make_internal_rpc_pipe_p(const char *pipe_name, + const char *client_address, + struct auth_serversupplied_info *server_info, + uint16_t vuid); /* The following definitions come from rpc_server/srv_samr_nt.c */ diff --git a/source/rpc_server/srv_pipe_hnd.c b/source/rpc_server/srv_pipe_hnd.c index c0b525c06bf..aa5bd5394a1 100644 --- a/source/rpc_server/srv_pipe_hnd.c +++ b/source/rpc_server/srv_pipe_hnd.c @@ -65,8 +65,6 @@ static ssize_t read_from_internal_pipe(void *np_conn, char *data, size_t n, bool *is_data_outstanding); static ssize_t write_to_internal_pipe(void *np_conn, char *data, size_t n); static bool close_internal_rpc_pipe_hnd(void *np_conn); -static void *make_internal_rpc_pipe_p(const char *pipe_name, - connection_struct *conn, uint16 vuid); /**************************************************************************** Internal Pipe iterator functions. @@ -217,7 +215,8 @@ smb_np_struct *open_rpc_pipe_p(const char *pipe_name, p->namedpipe_write = write_to_internal_pipe; p->namedpipe_close = close_internal_rpc_pipe_hnd; - p->np_state = p->namedpipe_create(pipe_name, conn, vuid); + p->np_state = p->namedpipe_create(pipe_name, conn->client_address, + conn->server_info, vuid); if (p->np_state == NULL) { DEBUG(0,("open_rpc_pipe_p: make_internal_rpc_pipe_p failed.\n")); @@ -266,19 +265,15 @@ smb_np_struct *open_rpc_pipe_p(const char *pipe_name, Make an internal namedpipes structure ****************************************************************************/ -static void *make_internal_rpc_pipe_p(const char *pipe_name, - connection_struct *conn, uint16 vuid) +struct pipes_struct *make_internal_rpc_pipe_p(const char *pipe_name, + const char *client_address, + struct auth_serversupplied_info *server_info, + uint16_t vuid) { pipes_struct *p; - user_struct *vuser = get_valid_user_struct(vuid); DEBUG(4,("Create pipe requested %s\n", pipe_name)); - if (!vuser && vuid != UID_FIELD_INVALID) { - DEBUG(0,("ERROR! vuid %d did not map to a valid vuser struct!\n", vuid)); - return NULL; - } - p = TALLOC_ZERO_P(NULL, pipes_struct); if (!p) { @@ -314,7 +309,7 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, return NULL; } - p->server_info = copy_serverinfo(p, conn->server_info); + p->server_info = copy_serverinfo(p, server_info); if (p->server_info == NULL) { DEBUG(0, ("open_rpc_pipe_p: copy_serverinfo failed\n")); talloc_destroy(p->mem_ctx); @@ -325,21 +320,16 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, DLIST_ADD(InternalPipes, p); - memcpy(p->client_address, conn->client_address, - sizeof(p->client_address)); + memcpy(p->client_address, client_address, sizeof(p->client_address)); p->endian = RPC_LITTLE_ENDIAN; ZERO_STRUCT(p->pipe_user); + p->pipe_user.vuid = vuid; p->pipe_user.ut.uid = (uid_t)-1; p->pipe_user.ut.gid = (gid_t)-1; - - /* Store the session key and NT_TOKEN */ - if (vuser) { - p->pipe_user.nt_user_token = dup_nt_token( - NULL, vuser->server_info->ptok); - } + p->pipe_user.nt_user_token = dup_nt_token(NULL, server_info->ptok); /* * Initialize the outgoing RPC data buffer with no memory. @@ -351,7 +341,7 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, DEBUG(4,("Created internal pipe %s (pipes_open=%d)\n", pipe_name, pipes_open)); - return (void*)p; + return p; } /**************************************************************************** -- 2.11.4.GIT