diff options
-rw-r--r-- | source3/include/proto.h | 6 | ||||
-rw-r--r-- | source3/include/rpc_creds.h | 2 | ||||
-rw-r--r-- | source3/include/smb.h | 2 | ||||
-rw-r--r-- | source3/lib/msrpc-client.c | 9 | ||||
-rw-r--r-- | source3/lib/msrpc_use.c | 10 | ||||
-rw-r--r-- | source3/rpc_parse/parse_creds.c | 11 | ||||
-rw-r--r-- | source3/rpc_server/srv_pipe_hnd.c | 2 |
7 files changed, 32 insertions, 10 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 9b25b5e865..f78f19cb40 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -136,9 +136,10 @@ void msrpc_init_creds(struct msrpc_state *msrpc, const struct user_creds *usr); void msrpc_close_socket(struct msrpc_state *msrpc); void msrpc_sockopt(struct msrpc_state *msrpc, char *options); BOOL msrpc_connect_auth(struct msrpc_state *msrpc, + uint32 pid, const char* pipename, const struct user_creds *usr); -struct msrpc_state *msrpc_initialise(struct msrpc_state *msrpc); +struct msrpc_state *msrpc_initialise(struct msrpc_state *msrpc, uint32 pid); void msrpc_shutdown(struct msrpc_state *msrpc); BOOL msrpc_establish_connection(struct msrpc_state *msrpc, const char *pipe_name); @@ -148,6 +149,7 @@ BOOL msrpc_establish_connection(struct msrpc_state *msrpc, void init_msrpc_use(void); void free_msrpc_use(void); struct msrpc_state *msrpc_use_add(const char* pipe_name, + uint32 pid, const struct user_creds *usr_creds, BOOL redir); BOOL msrpc_use_del(const char* pipe_name, @@ -1704,11 +1706,13 @@ BOOL creds_io_cmd(char *desc, CREDS_CMD *r_u, prs_struct *ps, int depth); BOOL create_ntuser_creds( prs_struct *ps, const char* name, uint16 version, uint16 command, + uint32 pid, const struct ntuser_creds *ntu, BOOL reuse); BOOL create_user_creds( prs_struct *ps, const char* name, uint16 version, uint16 command, + uint32 pid, const struct user_creds *usr); /*The following definitions come from rpc_parse/parse_lsa.c */ diff --git a/source3/include/rpc_creds.h b/source3/include/rpc_creds.h index 7869fe339c..3247e1efdf 100644 --- a/source3/include/rpc_creds.h +++ b/source3/include/rpc_creds.h @@ -62,6 +62,7 @@ typedef struct ntsec_creds typedef struct user_creds { BOOL reuse; + uint32 ptr_ntc; uint32 ptr_uxc; uint32 ptr_nts; @@ -82,6 +83,7 @@ typedef struct cred_command { uint16 version; uint16 command; + uint32 pid; /* unique process id */ fstring name; diff --git a/source3/include/smb.h b/source3/include/smb.h index 4527ff9bff..8d4a367179 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -1832,6 +1832,8 @@ struct msrpc_state BOOL initialised; char *inbuf; char *outbuf; + + uint32 pid; }; #include "client.h" #include "rpcclient.h" diff --git a/source3/lib/msrpc-client.c b/source3/lib/msrpc-client.c index 051a051093..60924ed81c 100644 --- a/source3/lib/msrpc-client.c +++ b/source3/lib/msrpc-client.c @@ -195,7 +195,8 @@ static BOOL msrpc_authenticate(struct msrpc_state *msrpc, command = usr != NULL ? AGENT_CMD_CON : AGENT_CMD_CON_ANON; - if (!create_user_creds(&ps, msrpc->pipe_name, 0x0, command, usr)) + if (!create_user_creds(&ps, msrpc->pipe_name, 0x0, command, + msrpc->pid, usr)) { DEBUG(0,("could not parse credentials\n")); close(sock); @@ -274,11 +275,12 @@ static BOOL msrpc_init_redirect(struct msrpc_state *msrpc, } BOOL msrpc_connect_auth(struct msrpc_state *msrpc, + uint32 pid, const char* pipename, const struct user_creds *usr) { ZERO_STRUCTP(msrpc); - if (!msrpc_initialise(msrpc)) + if (!msrpc_initialise(msrpc, pid)) { DEBUG(0,("unable to initialise msrpcent connection.\n")); return False; @@ -298,7 +300,7 @@ BOOL msrpc_connect_auth(struct msrpc_state *msrpc, /**************************************************************************** initialise a msrpcent structure ****************************************************************************/ -struct msrpc_state *msrpc_initialise(struct msrpc_state *msrpc) +struct msrpc_state *msrpc_initialise(struct msrpc_state *msrpc, uint32 pid) { if (!msrpc) { msrpc = (struct msrpc_state *)malloc(sizeof(*msrpc)); @@ -323,6 +325,7 @@ struct msrpc_state *msrpc_initialise(struct msrpc_state *msrpc) msrpc->initialised = 1; msrpc_init_creds(msrpc, NULL); + msrpc->pid = pid; return msrpc; } diff --git a/source3/lib/msrpc_use.c b/source3/lib/msrpc_use.c index 13bf7eb5f7..1d0df1872f 100644 --- a/source3/lib/msrpc_use.c +++ b/source3/lib/msrpc_use.c @@ -121,8 +121,8 @@ static struct msrpc_use *msrpc_find(const char* pipe_name, DEBUG(10,("msrpc_find: %s %s %s\n", pipe_name, - usr_creds->ntc.user_name, - usr_creds->ntc.domain)); + usr_creds != NULL ? usr_creds->ntc.user_name : "null", + usr_creds != NULL ? usr_creds->ntc.domain : "null")); for (i = 0; i < num_msrpcs; i++) { @@ -169,6 +169,7 @@ static struct msrpc_use *msrpc_find(const char* pipe_name, create a new client state from user credentials ****************************************************************************/ static struct msrpc_use *msrpc_use_get(const char* pipe_name, + uint32 pid, const struct user_creds *usr_creds) { struct msrpc_use *cli = (struct msrpc_use*)malloc(sizeof(*cli)); @@ -180,7 +181,7 @@ static struct msrpc_use *msrpc_use_get(const char* pipe_name, memset(cli, 0, sizeof(*cli)); - cli->cli = msrpc_initialise(NULL); + cli->cli = msrpc_initialise(NULL, pid); if (cli->cli == NULL) { @@ -196,6 +197,7 @@ static struct msrpc_use *msrpc_use_get(const char* pipe_name, init client state ****************************************************************************/ struct msrpc_state *msrpc_use_add(const char* pipe_name, + uint32 pid, const struct user_creds *usr_creds, BOOL redir) { @@ -221,7 +223,7 @@ struct msrpc_state *msrpc_use_add(const char* pipe_name, * allocate */ - cli = msrpc_use_get(pipe_name, usr_creds); + cli = msrpc_use_get(pipe_name, pid, usr_creds); cli->cli->redirect = redir; if (!msrpc_establish_connection(cli->cli, pipe_name)) diff --git a/source3/rpc_parse/parse_creds.c b/source3/rpc_parse/parse_creds.c index 54c9c48cba..ba45fa163a 100644 --- a/source3/rpc_parse/parse_creds.c +++ b/source3/rpc_parse/parse_creds.c @@ -330,6 +330,7 @@ BOOL creds_io_hybrid(char *desc, CREDS_HYBRID *r_u, prs_struct *ps, int depth) prs_align(ps); prs_uint32("reuse", ps, depth, &(r_u->reuse)); + prs_uint32("ptr_ntc", ps, depth, &(r_u->ptr_ntc)); prs_uint32("ptr_uxc", ps, depth, &(r_u->ptr_uxc)); prs_uint32("ptr_nts", ps, depth, &(r_u->ptr_nts)); @@ -464,11 +465,15 @@ void copy_user_creds(struct user_creds *to, to->reuse = False; return; } + + to->reuse = from->reuse; + to->ptr_nts = from->ptr_nts; to->ptr_uxs = from->ptr_uxs; to->ptr_ntc = from->ptr_ntc; to->ptr_uxc = from->ptr_uxc; to->ptr_ssk = from->ptr_ssk; + if (to->ptr_ntc != 0) { copy_nt_creds(&to->ntc, &from->ntc); @@ -490,7 +495,6 @@ void copy_user_creds(struct user_creds *to, memcpy(to->usr_sess_key, from->usr_sess_key, sizeof(to->usr_sess_key)); } - to->reuse = from->reuse; }; void free_user_creds(struct user_creds *creds) @@ -515,6 +519,7 @@ BOOL creds_io_cmd(char *desc, CREDS_CMD *r_u, prs_struct *ps, int depth) prs_uint16("version", ps, depth, &(r_u->version)); prs_uint16("command", ps, depth, &(r_u->command)); + prs_uint32("pid ", ps, depth, &(r_u->pid )); prs_string("name ", ps, depth, r_u->name, strlen(r_u->name), sizeof(r_u->name)); prs_align(ps); @@ -536,6 +541,7 @@ BOOL creds_io_cmd(char *desc, CREDS_CMD *r_u, prs_struct *ps, int depth) BOOL create_ntuser_creds( prs_struct *ps, const char* name, uint16 version, uint16 command, + uint32 pid, const struct ntuser_creds *ntu, BOOL reuse) { @@ -553,6 +559,7 @@ BOOL create_ntuser_creds( prs_struct *ps, fstrcpy(cmd.name, name); cmd.version = version; cmd.command = command; + cmd.pid = pid ; cmd.ptr_creds = ntu != NULL ? 1 : 0; cmd.cred = &usr; @@ -575,6 +582,7 @@ BOOL create_ntuser_creds( prs_struct *ps, BOOL create_user_creds( prs_struct *ps, const char* name, uint16 version, uint16 command, + uint32 pid, const struct user_creds *usr) { CREDS_CMD cmd; @@ -587,6 +595,7 @@ BOOL create_user_creds( prs_struct *ps, fstrcpy(cmd.name, name); cmd.version = version; cmd.command = command; + cmd.pid = pid ; cmd.ptr_creds = usr != NULL ? 1 : 0; cmd.cred = usr; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 736d1435d1..b8e7c1946a 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -153,7 +153,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, */ become_root(False); /* to connect to pipe */ - m = msrpc_use_add(pipe_name, &usr, False); + m = msrpc_use_add(pipe_name, getpid(), &usr, False); unbecome_root(False); if (m == NULL) |