diff options
author | Luke Leighton <lkcl@samba.org> | 1997-10-30 17:08:42 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1997-10-30 17:08:42 +0000 |
commit | 739a730637b8320dce85c12686a4d4647990824d (patch) | |
tree | b3888051dad64a12d5674b4cdccbb9cecfab2176 | |
parent | f1093ad693d1650bcc50b5c7dd9b5a0356088cde (diff) | |
download | samba-739a730637b8320dce85c12686a4d4647990824d.tar.gz samba-739a730637b8320dce85c12686a4d4647990824d.tar.bz2 samba-739a730637b8320dce85c12686a4d4647990824d.zip |
Makefile:
simply adding pipes.o to SMBDOBJ3.
rpc_pipes/pipe_hnd.c :
created pipe handles module.
pipes.c server.c :
use of pipe_hnd functions in SMBopenX and SMBclose, on the IPC$ pipe.
(This used to be commit ada256b5e3b9fb0db988e3be7d47943e7c19b3fb)
-rw-r--r-- | source3/include/proto.h | 13 | ||||
-rw-r--r-- | source3/smbd/ipc.c | 2 | ||||
-rw-r--r-- | source3/smbd/pipes.c | 80 | ||||
-rw-r--r-- | source3/smbd/server.c | 3 |
4 files changed, 20 insertions, 78 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index c6f98875bc..f9d1044505 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -655,6 +655,19 @@ BOOL server_validate(char *user, char *domain, BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname); void pcap_printer_fn(void (*fn)()); +/*The following definitions come from pipes.c */ + +int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize); +int reply_pipe_close(char *inbuf,char *outbuf); +BOOL api_LsarpcSNPHS(int cnum,int uid, char *param,char *data, + int mdrcnt,int mprcnt, + char **rdata,char **rparam, + int *rdata_len,int *rparam_len); +BOOL api_LsarpcTNP(int cnum,int uid, char *param,char *data, + int mdrcnt,int mprcnt, + char **rdata,char **rparam, + int *rdata_len,int *rparam_len); + /*The following definitions come from predict.c */ int read_predict(int fd,int offset,char *buf,char **ptr,int num); diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index b525f06046..a42baea80a 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -2916,7 +2916,7 @@ static int api_fd_reply(int cnum,uint16 vuid,char *outbuf, /* Get the file handle and hence the file name. */ fd = setup[1]; subcommand = setup[0]; - pipe_name = get_pipe_name(fd); + pipe_name = get_rpc_pipe_hnd_name(fd); if (pipe_name == NULL) { diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c index 990b25cb0a..ff93041fbc 100644 --- a/source3/smbd/pipes.c +++ b/source3/smbd/pipes.c @@ -38,30 +38,15 @@ extern int Protocol; extern int DEBUGLEVEL; extern char magic_char; -static int chain_pnum = -1; extern BOOL case_sensitive; extern pstring sesssetup_user; extern int Client; extern fstring myworkgroup; -#ifndef MAX_OPEN_PIPES -#define MAX_OPEN_PIPES 50 -#endif - -static struct -{ - int cnum; - BOOL open; - fstring name; - -} Pipes[MAX_OPEN_PIPES]; - #define VALID_PNUM(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PIPES)) #define OPEN_PNUM(pnum) (VALID_PNUM(pnum) && Pipes[pnum].open) #define PNUM_OK(pnum,c) (OPEN_PNUM(pnum) && (c)==Pipes[pnum].cnum) -#define CHECK_PNUM(pnum,c) if (!PNUM_OK(pnum,c)) \ - return(ERROR(ERRDOS,ERRbadfid)) /* this macro should always be used to extract an pnum (smb_fid) from a packet to ensure chaining works correctly */ #define GETPNUM(buf,where) (chain_pnum!= -1?chain_pnum:SVAL(buf,where)) @@ -77,49 +62,6 @@ char * known_pipes [] = }; /**************************************************************************** - find first available file slot -****************************************************************************/ -static int find_free_pipe(void ) -{ - int i; - /* we start at 1 here for an obscure reason I can't now remember, - but I think is important :-) */ - for (i = 1; i < MAX_OPEN_PIPES; i++) - if (!Pipes[i].open) - return(i); - - DEBUG(1,("ERROR! Out of pipe structures - perhaps increase MAX_OPEN_PIPES?\n")); - - return(-1); -} - -/**************************************************************************** - gets the name of a pipe -****************************************************************************/ -char *get_pipe_name(int pnum) -{ - DEBUG(6,("get_pipe_name: ")); - - if (VALID_PNUM(pnum - 0x800)) - { - DEBUG(6,("name: %s cnum: %d open: %s ", - Pipes[pnum - 0x800].name, - Pipes[pnum - 0x800].cnum, - BOOLSTR(Pipes[pnum - 0x800].open))); - } - if (OPEN_PNUM(pnum - 0x800)) - { - DEBUG(6,("OK\n")); - return Pipes[pnum - 0x800].name; - } - else - { - DEBUG(6,("NOT\n")); - return NULL; - } -} - -/**************************************************************************** reply to an open and X on a named pipe This code is basically stolen from reply_open_and_X with some @@ -161,13 +103,9 @@ int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize) DEBUG(3,("Known pipe %s opening.\n",fname)); smb_ofun |= 0x10; /* Add Create it not exists flag */ - pnum = find_free_pipe(); + pnum = open_rpc_pipe_hnd(fname, cnum); if (pnum < 0) return(ERROR(ERRSRV,ERRnofids)); - Pipes[pnum].open = True; - Pipes[pnum].cnum = cnum; - fstrcpy(Pipes[pnum].name, fname); - /* Prepare the reply */ set_message(outbuf,15,0,True); @@ -188,11 +126,6 @@ int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize) SSVAL(outbuf,smb_vwv8,rmode); SSVAL(outbuf,smb_vwv11,0); - DEBUG(4,("Opened pipe %s with handle %x name %s.\n", - fname, pnum + 0x800, Pipes[pnum].name)); - - chain_pnum = pnum; - return chain_reply(inbuf,outbuf,length,bufsize); } @@ -202,18 +135,11 @@ int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize) ****************************************************************************/ int reply_pipe_close(char *inbuf,char *outbuf) { - int pnum = GETPNUM(inbuf,smb_vwv0); + int pnum = get_rpc_pipe_num(inbuf,smb_vwv0); int cnum = SVAL(inbuf,smb_tid); int outsize = set_message(outbuf,0,0,True); - /* mapping is 0x800 up... */ - - CHECK_PNUM(pnum-0x800,cnum); - - DEBUG(3,("%s Closed pipe name %s pnum=%d cnum=%d\n", - timestring(),Pipes[pnum-0x800].name, pnum,cnum)); - - Pipes[pnum-0x800].open = False; + if (!close_rpc_pipe_hnd(pnum, cnum)) return(ERROR(ERRDOS,ERRbadfid)); return(outsize); } diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 93042e119b..3867240241 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -4925,6 +4925,9 @@ static void init_structs(void ) fd_ptr->real_open_flags = -1; } + /* for RPC pipes */ + init_rpc_pipe_hnd(); + init_dptrs(); } |