From fbd17c8dafeefac788f4bc1c41045726825f513f Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 3 Jan 2000 19:19:48 +0000 Subject: simple mods to add msrpc pipe redirection. default behaviour: fall back to using internal msrpc code in smbd. (This used to be commit 8976e26d46cb991710bc77463f7f928ac00dd4d8) --- source3/rpc_server/srv_pipe_hnd.c | 51 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server/srv_pipe_hnd.c') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index b21b768a6e..46beba6316 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -113,10 +113,44 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, int i; pipes_struct *p; static int next_pipe; + struct msrpc_state *m = NULL; + user_struct *vuser = get_valid_user_struct(vuid); + struct user_creds usr; + + ZERO_STRUCT(usr); DEBUG(4,("Open pipe requested %s (pipes_open=%d)\n", pipe_name, pipes_open)); + if (vuser == NULL) + { + DEBUG(4,("invalid vuid %d\n", vuid)); + return NULL; + } + + /* set up unix credentials from the smb side, to feed over the pipe */ + make_creds_unix(&usr.uxc, vuser->name, vuser->requested_name, + vuser->real_name, vuser->guest); + usr.ptr_uxc = 1; + make_creds_unix_sec(&usr.uxs, vuser->uid, vuser->gid, + vuser->n_groups, vuser->groups); + usr.ptr_uxs = 1; + + /* set up nt credentials from the smb side, to feed over the pipe */ + /* lkclXXXX todo! + make_creds_nt(&usr.ntc); + make_creds_nt_sec(&usr.nts); + */ + + become_root(False); /* to connect to pipe */ + m = msrpc_use_add(pipe_name, &usr, False); + unbecome_root(False); + + if (m == NULL) + { + DEBUG(10,("open pipes: msrpc redirect failed - go local.\n")); + } + /* not repeating pipe numbers makes it easier to track things in log files and prevents client bugs where pipe numbers are reused over connection restarts */ @@ -160,6 +194,8 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->priority = 0; p->conn = conn; p->vuid = vuid; + + p->m = m; p->max_trans_reply = 0; @@ -201,7 +237,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, ssize_t write_to_pipe(pipes_struct *p, char *data, size_t n) { - DEBUG(6,("write_pipe: %x", p->pnum)); + DEBUG(6,("write_to_pipe: %x", p->pnum)); DEBUG(6,("name: %s open: %s len: %d", p->name, BOOLSTR(p->open), (int)n)); @@ -372,6 +408,19 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) DEBUG(4,("closed pipe name %s pnum=%x (pipes_open=%d)\n", p->name, p->pnum, pipes_open)); + if (p->m != NULL) + { + DEBUG(4,("closed msrpc redirect: ")); + if (msrpc_use_del(p->m->pipe_name, &p->m->usr, False, NULL)) + { + DEBUG(4,("OK\n")); + } + else + { + DEBUG(4,("FAILED\n")); + } + } + DLIST_REMOVE(Pipes, p); ZERO_STRUCTP(p); -- cgit