diff options
author | Luke Leighton <lkcl@samba.org> | 1999-12-12 01:25:49 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1999-12-12 01:25:49 +0000 |
commit | 0ce128e3550794d4dbbd1def00e87c020f72c992 (patch) | |
tree | 9ff25319ff380a5bb219788d8a116ff5110a3343 /source3/rpc_server/srv_pipe_hnd.c | |
parent | 12ca139d5cb79f7e61a84d7dfe8a4c64ed56d82b (diff) | |
download | samba-0ce128e3550794d4dbbd1def00e87c020f72c992.tar.gz samba-0ce128e3550794d4dbbd1def00e87c020f72c992.tar.bz2 samba-0ce128e3550794d4dbbd1def00e87c020f72c992.zip |
delineation between smb and msrpc more marked. smbd now constructs
pdus, and then feeds them over either a "local" function call or a "remote"
function call to an msrpc service. the "remote" msrpc daemon, on the
other side of a unix socket, then calls the same "local" function that
smbd would, if the msrpc service were being run from inside smbd.
this allows a transition from local msrpc services (inside the same smbd
process) to remote (over a unix socket).
removed reference to pipes_struct in msrpc services. all msrpc processing
functions take rpcsrv_struct which is a structure containing state info
for the msrpc functions to decode and create pdus.
created become_vuser() which does everything not related to connection_struct
that become_user() does.
removed, as best i could, connection_struct dependencies from the nt spoolss
printing code.
todo: remove dcinfo from rpcsrv_struct because this stores NETLOGON-specific
info on a per-connection basis, and if the connection dies then so does
the info, and that's a fairly serious problem.
had to put pretty much everything that is in user_struct into parse_creds.c
to feed unix user info over to the msrpc daemons. why? because it's
expensive to do unix password/group database lookups, and it's definitely
expensive to do nt user profile lookups, not to mention pretty difficult
and if you did either of these it would introduce a complication /
unnecessary interdependency. so, send uid/gid/num_groups/gid_t* +
SID+num_rids+domain_group_rids* + unix username + nt username + nt domain
+ user session key etc. this is the MINIMUM info identified so far that's
actually implemented. missing bits include the called and calling
netbios names etc. (basically, anything that can be loaded into
standard_sub() and standard_sub_basic()...)
(This used to be commit aa3c659a8dba0437c17c60055a6ed30fdfecdb6d)
Diffstat (limited to 'source3/rpc_server/srv_pipe_hnd.c')
-rw-r--r-- | source3/rpc_server/srv_pipe_hnd.c | 111 |
1 files changed, 73 insertions, 38 deletions
diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index a7e451e6da..8a28674d3d 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -84,14 +84,40 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, pipes_struct *p; static int next_pipe; struct msrpc_state *m = NULL; + struct rpcsrv_struct *l = 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); + */ + /* 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 */ - if (next_pipe == 0) { + if (next_pipe == 0) + { next_pipe = (getpid() ^ time(NULL)) % MAX_OPEN_PIPES; } @@ -111,13 +137,33 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, if (strequal(pipe_name, "lsarpc")) { - m = msrpc_use_add(pipe_name, NULL, False); + m = msrpc_use_add(pipe_name, &usr, False); if (m == NULL) { DEBUG(5,("open pipes: msrpc redirect failed\n")); return NULL; } } + else + { + l = malloc(sizeof(*l)); + if (l == NULL) + { + DEBUG(5,("open pipes: local msrpc malloc failed\n")); + return NULL; + } + ZERO_STRUCTP(l); + l->rhdr.data = NULL; + l->rdata.data = NULL; + l->rhdr.offset = 0; + l->rdata.offset = 0; + + l->ntlmssp_validated = False; + l->ntlmssp_auth = False; + + memcpy(l->user_sess_key, vuser->user_sess_key, + sizeof(l->user_sess_key)); + } p = (pipes_struct *)malloc(sizeof(*p)); if (!p) return NULL; @@ -132,6 +178,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->pnum = i; p->m = m; + p->l = l; p->open = True; p->device_state = 0; @@ -139,20 +186,15 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->conn = conn; p->vuid = vuid; - p->rhdr.data = NULL; - p->rdata.data = NULL; - p->rhdr.offset = 0; - p->rdata.offset = 0; - p->file_offset = 0; p->prev_pdu_file_offset = 0; p->hdr_offsets = 0; - p->ntlmssp_validated = False; - p->ntlmssp_auth = False; - fstrcpy(p->name, pipe_name); + prs_init(&p->smb_pdu, 0, 4, 0, True); + prs_init(&p->rsmb_pdu, 0, 4, 0, False); + DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n", pipe_name, i, pipes_open)); @@ -175,29 +217,13 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, ****************************************************************************/ ssize_t write_pipe(pipes_struct *p, char *data, size_t n) { - prs_struct pd; - struct mem_buf data_buf; - DEBUG(6,("write_pipe: %x", p->pnum)); - DEBUG(6,("name: %s open: %s len: %d", p->name, BOOLSTR(p->open), n)); dump_data(50, data, n); - /* fake up a data buffer from the write_pipe data parameters */ - mem_create(&data_buf, data, 0, n, 0, False); - data_buf.offset.start = 0; - data_buf.offset.end = n; - - /* fake up a parsing structure */ - pd.data = &data_buf; - pd.align = 4; - pd.io = True; - pd.error = False; - pd.offset = 0; - - return rpc_command(p, &pd) ? ((ssize_t)n) : -1; + return rpc_to_smb(p, data, n) ? ((ssize_t)n) : -1; } @@ -232,8 +258,8 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) } - if (p->rhdr.data == NULL || p->rhdr.data->data == NULL || - p->rhdr.data->data_used == 0) + if (p->rsmb_pdu.data == NULL || p->rsmb_pdu.data->data == NULL || + p->rsmb_pdu.data->data_used == 0) { return 0; } @@ -246,12 +272,12 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) pdu_data_sent = p->file_offset - p->prev_pdu_file_offset; this_pdu_data_pos = (pdu_data_sent == 0) ? 0 : (pdu_data_sent - 0x18); - if (!IS_BITS_SET_ALL(p->hdr.flags, RPC_FLG_LAST)) + if (!IS_BITS_SET_ALL(p->l->hdr.flags, RPC_FLG_LAST)) { /* intermediate fragment - possibility of another header */ DEBUG(5,("read_pipe: frag_len: %d data_pos: %d pdu_data_sent: %d\n", - p->hdr.frag_len, data_pos, pdu_data_sent)); + p->l->hdr.frag_len, data_pos, pdu_data_sent)); if (pdu_data_sent == 0) { @@ -263,11 +289,11 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) data_pos -= 0x18; /* create and copy in a new header. */ - create_rpc_reply(p, data_pos, p->rdata.offset); + create_rpc_reply(p->l, data_pos); } } - pdu_len = mem_buf_len(p->rhdr.data); + pdu_len = mem_buf_len(p->rsmb_pdu.data); num = pdu_len - this_pdu_data_pos; DEBUG(6,("read_pipe: pdu_len: %d num: %d n: %d\n", pdu_len, num, n)); @@ -284,7 +310,7 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) DEBUG(5,("read_pipe: warning - data read only part of a header\n")); } - mem_buf_copy(data, p->rhdr.data, pdu_data_sent, num); + mem_buf_copy(data, p->rsmb_pdu.data, pdu_data_sent, num); p->file_offset += num; pdu_data_sent += num; @@ -294,7 +320,7 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) DEBUG(6,("read_pipe: just header read\n")); } - if (pdu_data_sent == p->hdr.frag_len) + if (pdu_data_sent == p->l->hdr.frag_len) { DEBUG(6,("read_pipe: next fragment expected\n")); p->prev_pdu_file_offset = p->file_offset; @@ -359,8 +385,8 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) return False; } - mem_buf_free(&(p->rdata.data)); - mem_buf_free(&(p->rhdr .data)); + mem_buf_free(&(p->smb_pdu .data)); + mem_buf_free(&(p->rsmb_pdu.data)); bitmap_clear(bmap, p->pnum - pipe_handle_offset); @@ -384,8 +410,17 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) } } - ZERO_STRUCTP(p); + if (p->l != NULL) + { + DEBUG(4,("closed msrpc local: OK\n")); + + mem_free_data(p->l->rdata .data); + rpcsrv_free_temp(p->l); + free(p->l); + } + + ZERO_STRUCTP(p); free(p); return True; |