diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-02-20 10:11:40 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-02-20 10:11:40 +0000 |
commit | ba3ce3404e1cd2e9da3ba1708f6fc8a12c085ef2 (patch) | |
tree | dd68fc374b07138ee8b0c7aaa4232820aad1c00d | |
parent | e1a04e621f1c28d8e6e543d43741ca0272e2237f (diff) | |
download | samba-ba3ce3404e1cd2e9da3ba1708f6fc8a12c085ef2.tar.gz samba-ba3ce3404e1cd2e9da3ba1708f6fc8a12c085ef2.tar.xz samba-ba3ce3404e1cd2e9da3ba1708f6fc8a12c085ef2.zip |
pipe opening now works with unicode
-rw-r--r-- | source/include/proto.h | 6 | ||||
-rw-r--r-- | source/libsmb/cliconnect.c | 17 | ||||
-rw-r--r-- | source/libsmb/clilist.c | 2 | ||||
-rw-r--r-- | source/libsmb/clirap.c | 19 | ||||
-rw-r--r-- | source/libsmb/clistr.c | 23 | ||||
-rw-r--r-- | source/libsmb/clitrans.c | 13 | ||||
-rw-r--r-- | source/rpc_client/cli_pipe.c | 4 |
7 files changed, 50 insertions, 34 deletions
diff --git a/source/include/proto.h b/source/include/proto.h index 2e3800256d2..6efb6f99e4c 100644 --- a/source/include/proto.h +++ b/source/include/proto.h @@ -859,7 +859,7 @@ int cli_printjob_del(struct cli_state *cli, int job); /*The following definitions come from libsmb/clirap.c */ -BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, int pipe_name_len, +BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, uint16 *setup, uint32 setup_count, uint32 max_setup_count, char *params, uint32 param_count, uint32 max_param_count, char *data, uint32 data_count, uint32 max_data_count, @@ -906,7 +906,7 @@ BOOL cli_set_secdesc(struct cli_state *cli,int fd, SEC_DESC *sd); /*The following definitions come from libsmb/clistr.c */ int clistr_push(struct cli_state *cli, void *dest, char *src, int dest_len, int flags); -int clistr_push_size(struct cli_state *cli, char *src, int dest_len, int flags); +int clistr_push_size(struct cli_state *cli, void *dest, char *src, int dest_len, int flags); int clistr_pull(struct cli_state *cli, char *dest, void *src, int dest_len, int src_len, int flags); int clistr_pull_size(struct cli_state *cli, void *src, int src_len); int clistr_align(struct cli_state *cli, int offset); @@ -914,7 +914,7 @@ int clistr_align(struct cli_state *cli, int offset); /*The following definitions come from libsmb/clitrans.c */ BOOL cli_send_trans(struct cli_state *cli, int trans, - char *name, int pipe_name_len, + char *pipe_name, int fid, int flags, uint16 *setup, int lsetup, int msetup, char *param, int lparam, int mparam, diff --git a/source/libsmb/cliconnect.c b/source/libsmb/cliconnect.c index 74a10ddf8b5..4f9c5ad6150 100644 --- a/source/libsmb/cliconnect.c +++ b/source/libsmb/cliconnect.c @@ -123,10 +123,7 @@ BOOL cli_session_setup(struct cli_state *cli, if (cli->protocol < PROTOCOL_NT1) { - set_message(cli->outbuf,10, - clistr_align(cli, 1) + - clistr_push_size(cli, user, -1, CLISTR_TERMINATE|CLISTR_CONVERT) + - passlen,True); + set_message(cli->outbuf,10, 0, True); CVAL(cli->outbuf,smb_com) = SMBsesssetupX; cli_setup_packet(cli); @@ -137,10 +134,10 @@ BOOL cli_session_setup(struct cli_state *cli, SIVAL(cli->outbuf,smb_vwv5,cli->sesskey); SSVAL(cli->outbuf,smb_vwv7,passlen); p = smb_buf(cli->outbuf); - p += clistr_align(cli, PTR_DIFF(p,cli->outbuf)); memcpy(p,pword,passlen); p += passlen; - clistr_push(cli, p, user, -1, CLISTR_CONVERT|CLISTR_UPPER|CLISTR_TERMINATE); + p += clistr_push(cli, p, user, -1, CLISTR_CONVERT|CLISTR_UPPER|CLISTR_TERMINATE); + set_message(cli->outbuf,10,PTR_DIFF(p,smb_buf(cli->outbuf)),False); } else { @@ -157,7 +154,6 @@ BOOL cli_session_setup(struct cli_state *cli, SSVAL(cli->outbuf,smb_vwv8,ntpasslen); SSVAL(cli->outbuf,smb_vwv11,CAP_NT_SMBS|(cli->use_level_II_oplocks ? CAP_LEVEL_II_OPLOCKS : 0)); p = smb_buf(cli->outbuf); - p += clistr_align(cli, PTR_DIFF(p,cli->outbuf)); memcpy(p,pword,passlen); p += SVAL(cli->outbuf,smb_vwv7); memcpy(p,ntpword,ntpasslen); @@ -188,7 +184,6 @@ BOOL cli_session_setup(struct cli_state *cli, * info. */ char *p = smb_buf(cli->inbuf); - p += clistr_align(cli, PTR_DIFF(p,cli->outbuf)); p += clistr_pull(cli, cli->server_os, p, sizeof(fstring), -1, CLISTR_TERMINATE|CLISTR_CONVERT); p += clistr_pull(cli, cli->server_type, p, sizeof(fstring), -1, CLISTR_TERMINATE|CLISTR_CONVERT); p += clistr_pull(cli, cli->server_domain, p, sizeof(fstring), -1, CLISTR_TERMINATE|CLISTR_CONVERT); @@ -262,11 +257,7 @@ BOOL cli_send_tconX(struct cli_state *cli, unix_to_dos(fullshare, True); strupper(fullshare); - set_message(cli->outbuf,4, - clistr_push_size(cli, fullshare, -1, CLISTR_TERMINATE | CLISTR_CONVERT) + - passlen + - 1+strlen(dev), - True); + set_message(cli->outbuf,4, 0, True); CVAL(cli->outbuf,smb_com) = SMBtconX; cli_setup_packet(cli); diff --git a/source/libsmb/clilist.c b/source/libsmb/clilist.c index ae1607c1c4b..d4c67fd9e4f 100644 --- a/source/libsmb/clilist.c +++ b/source/libsmb/clilist.c @@ -205,7 +205,7 @@ int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, } if (!cli_send_trans(cli, SMBtrans2, - NULL, 0, /* Name, length */ + NULL, /* Name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ param, param_len, 10, /* param, length, max */ diff --git a/source/libsmb/clirap.c b/source/libsmb/clirap.c index cd261eac595..cd0e5ab73fd 100644 --- a/source/libsmb/clirap.c +++ b/source/libsmb/clirap.c @@ -27,18 +27,15 @@ /**************************************************************************** Call a remote api on an arbitrary pipe. takes param, data and setup buffers. ****************************************************************************/ -BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, int pipe_name_len, +BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, uint16 *setup, uint32 setup_count, uint32 max_setup_count, char *params, uint32 param_count, uint32 max_param_count, char *data, uint32 data_count, uint32 max_data_count, char **rparam, uint32 *rparam_count, char **rdata, uint32 *rdata_count) { - if (pipe_name_len == 0) - pipe_name_len = strlen(pipe_name); - cli_send_trans(cli, SMBtrans, - pipe_name, pipe_name_len, + pipe_name, 0,0, /* fid, flags */ setup, setup_count, max_setup_count, params, param_count, max_param_count, @@ -59,8 +56,8 @@ BOOL cli_api(struct cli_state *cli, char **rdata, int *rdrcnt) { cli_send_trans(cli,SMBtrans, - PIPE_LANMAN,strlen(PIPE_LANMAN), /* Name, length */ - 0,0, /* fid, flags */ + PIPE_LANMAN, /* Name */ + 0,0, /* fid, flags */ NULL,0,0, /* Setup, length, max */ param, prcnt, mprcnt, /* Params, length, max */ data, drcnt, mdrcnt /* Data, length, max */ @@ -385,7 +382,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char data_len = 532; if (cli_send_trans(cli,SMBtrans, - PIPE_LANMAN,strlen(PIPE_LANMAN), /* name, length */ + PIPE_LANMAN, /* name */ 0,0, /* fid, flags */ NULL,0,0, /* setup, length, max */ param,param_len,2, /* param, length, max */ @@ -437,7 +434,7 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, do { ret = (cli_send_trans(cli, SMBtrans2, - NULL, 0, /* Name, length */ + NULL, /* Name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ param, param_len, 10, /* param, length, max */ @@ -510,7 +507,7 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, unix_to_dos(¶m[6],True); if (!cli_send_trans(cli, SMBtrans2, - NULL, 0, /* name, length */ + NULL, /* name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ param, param_len, 10, /* param, length, max */ @@ -582,7 +579,7 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, SSVAL(param, 2, SMB_QUERY_FILE_ALL_INFO); if (!cli_send_trans(cli, SMBtrans2, - NULL, 0, /* name, length */ + NULL, /* name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ param, param_len, 2, /* param, length, max */ diff --git a/source/libsmb/clistr.c b/source/libsmb/clistr.c index 839dec75928..eb66d08c302 100644 --- a/source/libsmb/clistr.c +++ b/source/libsmb/clistr.c @@ -47,6 +47,11 @@ int clistr_push(struct cli_state *cli, void *dest, char *src, int dest_len, int dest_len = sizeof(pstring); } + if (clistr_align(cli, PTR_DIFF(cli->outbuf, dest))) { + dest++; + dest_len--; + } + if (!cli_use_unicode || !(cli->capabilities & CAP_UNICODE)) { /* the server doesn't want unicode */ safe_strcpy(dest, src, dest_len); @@ -77,12 +82,18 @@ return the length that a string would occupy when copied with clistr_push() CLISTR_TERMINATE means include the null termination CLISTR_CONVERT means convert from unix to dos codepage CLISTR_UPPER means uppercase in the destination +note that dest is only used for alignment purposes. No data is written. ****************************************************************************/ -int clistr_push_size(struct cli_state *cli, char *src, int dest_len, int flags) +int clistr_push_size(struct cli_state *cli, void *dest, char *src, int dest_len, int flags) { int len = strlen(src); if (flags & CLISTR_TERMINATE) len++; if (cli_use_unicode && (cli->capabilities & CAP_UNICODE)) len *= 2; + + if (clistr_align(cli, PTR_DIFF(cli->outbuf, dest))) { + len++; + } + return len; } @@ -104,6 +115,11 @@ int clistr_pull(struct cli_state *cli, char *dest, void *src, int dest_len, int dest_len = sizeof(pstring); } + if (clistr_align(cli, PTR_DIFF(cli->inbuf, src))) { + src++; + if (src_len > 0) src_len--; + } + if (!cli_use_unicode || !(cli->capabilities & CAP_UNICODE)) { /* the server doesn't want unicode */ if (flags & CLISTR_TERMINATE) { @@ -143,6 +159,11 @@ if src_len is -1 then assume the source is null terminated ****************************************************************************/ int clistr_pull_size(struct cli_state *cli, void *src, int src_len) { + if (clistr_align(cli, PTR_DIFF(cli->inbuf, src))) { + src++; + if (src_len > 0) src_len--; + } + if (!cli_use_unicode || !(cli->capabilities & CAP_UNICODE)) { return strlen(src); } diff --git a/source/libsmb/clitrans.c b/source/libsmb/clitrans.c index 5cd6ae30ce0..3afca997cc8 100644 --- a/source/libsmb/clitrans.c +++ b/source/libsmb/clitrans.c @@ -28,7 +28,7 @@ send a SMB trans or trans2 request ****************************************************************************/ BOOL cli_send_trans(struct cli_state *cli, int trans, - char *name, int pipe_name_len, + char *pipe_name, int fid, int flags, uint16 *setup, int lsetup, int msetup, char *param, int lparam, int mparam, @@ -39,6 +39,7 @@ BOOL cli_send_trans(struct cli_state *cli, int trans, int tot_data=0,tot_param=0; char *outdata,*outparam; char *p; + int pipe_name_len=0; this_lparam = MIN(lparam,cli->max_xmit - (500+lsetup*2)); /* hack */ this_ldata = MIN(ldata,cli->max_xmit - (500+lsetup*2+this_lparam)); @@ -49,7 +50,13 @@ BOOL cli_send_trans(struct cli_state *cli, int trans, SSVAL(cli->outbuf,smb_tid, cli->cnum); cli_setup_packet(cli); - outparam = smb_buf(cli->outbuf)+(trans==SMBtrans ? pipe_name_len+1 : 3); + if (pipe_name) { + pipe_name_len = clistr_push_size(cli, smb_buf(cli->outbuf), + pipe_name, -1, + CLISTR_TERMINATE); + } + + outparam = smb_buf(cli->outbuf)+(trans==SMBtrans ? pipe_name_len : 3); outdata = outparam+this_lparam; /* primary request */ @@ -69,7 +76,7 @@ BOOL cli_send_trans(struct cli_state *cli, int trans, SSVAL(cli->outbuf,smb_setup+i*2,setup[i]); p = smb_buf(cli->outbuf); if (trans==SMBtrans) { - memcpy(p,name, pipe_name_len + 1); /* name[] */ + clistr_push(cli, p, pipe_name, -1, CLISTR_TERMINATE); } else { *p++ = 0; /* put in a null smb_name */ *p++ = 'D'; *p++ = ' '; /* observed in OS/2 */ diff --git a/source/rpc_client/cli_pipe.c b/source/rpc_client/cli_pipe.c index 0b119de5a1e..67cf65a4ff3 100644 --- a/source/rpc_client/cli_pipe.c +++ b/source/rpc_client/cli_pipe.c @@ -336,7 +336,7 @@ static BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd, prs_struct *data, pr DEBUG(5,("rpc_api_pipe: cmd:%x fnum:%x\n", (int)cmd, (int)cli->nt_pipe_fnum)); /* send the data: receive a response. */ - if (!cli_api_pipe(cli, "\\PIPE\\\0\0\0", 8, + if (!cli_api_pipe(cli, "\\PIPE\\", setup, 2, 0, /* Setup, length, max */ NULL, 0, 0, /* Params, length, max */ pdata, data_len, data_len, /* data, length, max */ @@ -889,7 +889,7 @@ static BOOL rpc_pipe_set_hnd_state(struct cli_state *cli, char *pipe_name, uint1 setup[1] = cli->nt_pipe_fnum; /* pipe file handle. got this from an SMBOpenX. */ /* send the data on \PIPE\ */ - if (cli_api_pipe(cli, "\\PIPE\\\0\0\0", 8, + if (cli_api_pipe(cli, "\\PIPE\\", setup, 2, 0, /* setup, length, max */ param, 2, 0, /* param, length, max */ NULL, 0, 1024, /* data, length, max */ |