diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-04-22 03:14:47 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-04-22 03:14:47 +0000 |
commit | b8893e82d5180e1ac8598c5b6eb1b31ecc8b2f9f (patch) | |
tree | b10bc61cd8f70343e9bd526e0e1c6f2aa1171448 | |
parent | 733a457d993d7e98a60731988ac71da2e050f2f9 (diff) | |
download | samba-b8893e82d5180e1ac8598c5b6eb1b31ecc8b2f9f.tar.gz samba-b8893e82d5180e1ac8598c5b6eb1b31ecc8b2f9f.tar.xz samba-b8893e82d5180e1ac8598c5b6eb1b31ecc8b2f9f.zip |
merged libsmb code from head
-rw-r--r-- | source/Makefile.in | 2 | ||||
-rw-r--r-- | source/client/client.c | 24 | ||||
-rw-r--r-- | source/include/proto.h | 37 | ||||
-rw-r--r-- | source/lib/util.c | 31 | ||||
-rw-r--r-- | source/libsmb/cliconnect.c | 94 | ||||
-rw-r--r-- | source/libsmb/clientgen.c | 14 | ||||
-rw-r--r-- | source/libsmb/clierror.c | 3 | ||||
-rw-r--r-- | source/libsmb/clifile.c | 186 | ||||
-rw-r--r-- | source/libsmb/clilist.c | 142 | ||||
-rw-r--r-- | source/libsmb/climessage.c | 12 | ||||
-rw-r--r-- | source/libsmb/clirap.c | 63 | ||||
-rw-r--r-- | source/libsmb/clitrans.c | 25 | ||||
-rw-r--r-- | source/libsmb/namequery.c | 149 | ||||
-rw-r--r-- | source/libsmb/pwd_cache.c | 10 | ||||
-rw-r--r-- | source/nmbd/nmbd_synclists.c | 9 | ||||
-rw-r--r-- | source/rpc_client/cli_pipe.c | 4 |
16 files changed, 505 insertions, 300 deletions
diff --git a/source/Makefile.in b/source/Makefile.in index c09eba634ec..64873070a33 100644 --- a/source/Makefile.in +++ b/source/Makefile.in @@ -119,7 +119,7 @@ LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \ libsmb/clirap.o libsmb/clierror.o libsmb/climessage.o \ libsmb/clireadwrite.o libsmb/clilist.o libsmb/cliprint.o \ libsmb/clitrans.o libsmb/clisecdesc.o \ - libsmb/namequery.o libsmb/nmblib.o \ + libsmb/namequery.o libsmb/nmblib.o libsmb/clistr.o \ libsmb/nterr.o libsmb/smbdes.o libsmb/smbencrypt.o \ libsmb/smberr.o libsmb/credentials.o libsmb/pwd_cache.o \ libsmb/passchange.o libsmb/unexpected.o $(RPC_PARSE_OBJ1) diff --git a/source/client/client.c b/source/client/client.c index be2e6238c3b..9c167e20c2c 100644 --- a/source/client/client.c +++ b/source/client/client.c @@ -473,7 +473,7 @@ static int do_list_queue_empty(void) /**************************************************************************** a helper for do_list ****************************************************************************/ -static void do_list_helper(file_info *f, const char *mask) +static void do_list_helper(file_info *f, const char *mask, void *state) { if (f->mode & aDIR) { if (do_list_dirs && do_this_one(f)) { @@ -537,7 +537,7 @@ void do_list(const char *mask,uint16 attribute,void (*fn)(file_info *),BOOL rec, */ pstring head; pstrcpy(head, do_list_queue_head()); - cli_list(cli, head, attribute, do_list_helper); + cli_list(cli, head, attribute, do_list_helper, NULL); remove_do_list_queue_head(); if ((! do_list_queue_empty()) && (fn == display_finfo)) { @@ -561,7 +561,7 @@ void do_list(const char *mask,uint16 attribute,void (*fn)(file_info *),BOOL rec, } else { - if (cli_list(cli, mask, attribute, do_list_helper) == -1) + if (cli_list(cli, mask, attribute, do_list_helper, NULL) == -1) { DEBUG(0, ("%s listing %s\n", cli_errstr(cli), mask)); } @@ -1548,7 +1548,8 @@ static void cmd_lcd(void) /**************************************************************************** list a share name ****************************************************************************/ -static void browse_fn(const char *name, uint32 m, const char *comment) +static void browse_fn(const char *name, uint32 m, + const char *comment, void *state) { fstring typestr; @@ -1581,7 +1582,7 @@ static BOOL browse_host(BOOL sort) printf("\n\tSharename Type Comment\n"); printf("\t--------- ---- -------\n"); - if((ret = cli_RNetShareEnum(cli, browse_fn)) == -1) + if((ret = cli_RNetShareEnum(cli, browse_fn, NULL)) == -1) printf("Error returning browse list: %s\n", cli_errstr(cli)); return (ret != -1); @@ -1590,7 +1591,8 @@ static BOOL browse_host(BOOL sort) /**************************************************************************** list a server name ****************************************************************************/ -static void server_fn(const char *name, uint32 m, const char *comment) +static void server_fn(const char *name, uint32 m, + const char *comment, void *state) { printf("\t%-16.16s %s\n", name, comment); } @@ -1605,12 +1607,12 @@ static BOOL list_servers(char *wk_grp) printf("\n\tServer Comment\n"); printf("\t--------- -------\n"); - cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL, server_fn); + cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL, server_fn, NULL); printf("\n\tWorkgroup Master\n"); printf("\t--------- -------\n"); - cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_DOMAIN_ENUM, server_fn); + cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_DOMAIN_ENUM, server_fn, NULL); return True; } @@ -1846,13 +1848,13 @@ static void process_stdin(void) while (1) { fstring tok; - fstring prompt; + fstring the_prompt; char *line; int i; /* display a prompt */ - slprintf(prompt, sizeof(prompt)-1, "smb: %s> ", cur_dir); - line = smb_readline(prompt, readline_callback, completion_fn); + slprintf(the_prompt, sizeof(the_prompt)-1, "smb: %s> ", cur_dir); + line = smb_readline(the_prompt, readline_callback, completion_fn); if (!line) break; diff --git a/source/include/proto.h b/source/include/proto.h index 036cfea8dd0..9c6d937ccc8 100644 --- a/source/include/proto.h +++ b/source/include/proto.h @@ -443,6 +443,8 @@ char *attrib_string(uint16 mode); void show_msg(char *buf); void smb_setlen(char *buf,int len); int set_message(char *buf,int num_words,int num_bytes,BOOL zero); +void set_message_bcc(char *buf,int num_bytes); +void set_message_end(void *outbuf,void *end_ptr); void dos_clean_name(char *s); void unix_clean_name(char *s); void make_dir_struct(char *buf,char *mask,char *fname,SMB_OFF_T size,int mode,time_t date); @@ -879,6 +881,7 @@ int cli_set_port(struct cli_state *cli, int port); BOOL cli_receive_smb(struct cli_state *cli); BOOL cli_send_smb(struct cli_state *cli); void cli_setup_packet(struct cli_state *cli); +void cli_setup_bcc(struct cli_state *cli, void *p); void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr); struct cli_state *cli_initialise(struct cli_state *cli); void cli_shutdown(struct cli_state *cli); @@ -897,10 +900,10 @@ BOOL cli_unlink(struct cli_state *cli, char *fname); BOOL cli_mkdir(struct cli_state *cli, char *dname); BOOL cli_rmdir(struct cli_state *cli, char *dname); int cli_nt_delete_on_close(struct cli_state *cli, int fnum, BOOL flag); -int cli_nt_create_full(struct cli_state *cli, char *fname, uint32 DesiredAccess, uint32 FileAttributes, - uint32 ShareAccess, uint32 CreateDisposition, uint32 CreateOptions); +int cli_nt_create_full(struct cli_state *cli, char *fname, uint32 DesiredAccess, + uint32 FileAttributes, uint32 ShareAccess, + uint32 CreateDisposition, uint32 CreateOptions); int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess); -int cli_nt_create_uni(struct cli_state *cli, char *fname, uint32 DesiredAccess); int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode); BOOL cli_close(struct cli_state *cli, int fnum); BOOL cli_lock(struct cli_state *cli, int fnum, @@ -921,10 +924,12 @@ int cli_ctemp(struct cli_state *cli, char *path, char **tmp_path); /*The following definitions come from libsmb/clilist.c */ -int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, - void (*fn)(file_info *, const char *)); +int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, + void (*fn)(file_info *, const char *, void *), void *state); int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, - void (*fn)(file_info *, const char *)); + void (*fn)(file_info *, const char *, void *), void *state); +int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, + void (*fn)(file_info *, const char *, void *), void *state); /*The following definitions come from libsmb/climessage.c */ @@ -941,7 +946,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, @@ -953,9 +958,10 @@ BOOL cli_api(struct cli_state *cli, char **rparam, int *rprcnt, char **rdata, int *rdrcnt); BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation); -int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *)); +int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *, void *), void *state); BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, - void (*fn)(const char *, uint32, const char *)); + void (*fn)(const char *, uint32, const char *, void *), + void *state); BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, const char *old_password); BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, @@ -984,10 +990,16 @@ ssize_t cli_smbwrite(struct cli_state *cli, SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd); 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, const char *src, int dest_len, int flags); +int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len, int src_len, int flags); +int clistr_align(const void *buf, const void *p); + /*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, @@ -1025,12 +1037,17 @@ BOOL deal_with_creds(uchar sess_key[8], struct node_status *name_status_query(int fd,struct nmb_name *name, struct in_addr to_ip, int *num_names); BOOL name_status_find(int type, struct in_addr to_ip, char *name); +BOOL name_register(int fd, const char *name, int name_type, + struct in_addr name_ip, int opcode, + BOOL bcast, + struct in_addr to_ip, int *count); struct in_addr *name_query(int fd,const char *name,int name_type, BOOL bcast,BOOL recurse, struct in_addr to_ip, int *count); FILE *startlmhosts(char *fname); BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr); void endlmhosts(FILE *fp); +BOOL name_register_wins(const char *name, int name_type); BOOL name_resolve_bcast(const char *name, int name_type, struct in_addr **return_ip_list, int *return_count); BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type); diff --git a/source/lib/util.c b/source/lib/util.c index deaed54a284..3bee53abbcc 100644 --- a/source/lib/util.c +++ b/source/lib/util.c @@ -335,12 +335,31 @@ void smb_setlen(char *buf,int len) ********************************************************************/ int set_message(char *buf,int num_words,int num_bytes,BOOL zero) { - if (zero) - memset(buf + smb_size,'\0',num_words*2 + num_bytes); - CVAL(buf,smb_wct) = num_words; - SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes); - smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4); - return (smb_size + num_words*2 + num_bytes); + if (zero) + memset(buf + smb_size,'\0',num_words*2 + num_bytes); + CVAL(buf,smb_wct) = num_words; + SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes); + smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4); + return (smb_size + num_words*2 + num_bytes); +} + +/******************************************************************* + setup only the byte count for a smb message +********************************************************************/ +void set_message_bcc(char *buf,int num_bytes) +{ + int num_words = CVAL(buf,smb_wct); + SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes); + smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4); +} + +/******************************************************************* + setup only the byte count for a smb message, using the end of the + message as a marker +********************************************************************/ +void set_message_end(void *outbuf,void *end_ptr) +{ + set_message_bcc((char *)outbuf,PTR_DIFF(end_ptr,smb_buf((char *)outbuf))); } /******************************************************************* diff --git a/source/libsmb/cliconnect.c b/source/libsmb/cliconnect.c index 8a56a08b1d4..06f283c321a 100644 --- a/source/libsmb/cliconnect.c +++ b/source/libsmb/cliconnect.c @@ -104,8 +104,7 @@ BOOL cli_session_setup(struct cli_state *cli, /* * Plaintext mode needed, assume plaintext supplied. */ - fstrcpy(pword, pass); - unix_to_dos(pword,True); + passlen = clistr_push(cli, pword, pass, -1, STR_CONVERT|STR_TERMINATE); fstrcpy(ntpword, ""); ntpasslen = 0; } @@ -124,7 +123,7 @@ BOOL cli_session_setup(struct cli_state *cli, if (cli->protocol < PROTOCOL_NT1) { - set_message(cli->outbuf,10,1 + strlen(user) + passlen,True); + set_message(cli->outbuf,10, 0, True); CVAL(cli->outbuf,smb_com) = SMBsesssetupX; cli_setup_packet(cli); @@ -137,12 +136,20 @@ BOOL cli_session_setup(struct cli_state *cli, p = smb_buf(cli->outbuf); memcpy(p,pword,passlen); p += passlen; - pstrcpy(p,user); - unix_to_dos(p,True); - strupper(p); + p += clistr_push(cli, p, user, -1, STR_CONVERT|STR_UPPER|STR_TERMINATE); + cli_setup_bcc(cli, p); } else { + uint32 capabilities; + + capabilities = CAP_NT_SMBS; + if (cli->use_level_II_oplocks) { + capabilities |= CAP_LEVEL_II_OPLOCKS; + } + if (cli->capabilities & CAP_UNICODE) { + capabilities |= CAP_UNICODE; + } set_message(cli->outbuf,13,0,True); CVAL(cli->outbuf,smb_com) = SMBsesssetupX; cli_setup_packet(cli); @@ -154,23 +161,17 @@ BOOL cli_session_setup(struct cli_state *cli, SIVAL(cli->outbuf,smb_vwv5,cli->sesskey); SSVAL(cli->outbuf,smb_vwv7,passlen); SSVAL(cli->outbuf,smb_vwv8,ntpasslen); - SSVAL(cli->outbuf,smb_vwv11,CAP_NT_SMBS|(cli->use_level_II_oplocks ? CAP_LEVEL_II_OPLOCKS : 0)); + SIVAL(cli->outbuf,smb_vwv11,capabilities); p = smb_buf(cli->outbuf); memcpy(p,pword,passlen); p += SVAL(cli->outbuf,smb_vwv7); memcpy(p,ntpword,ntpasslen); p += SVAL(cli->outbuf,smb_vwv8); - pstrcpy(p,user); - unix_to_dos(p,True); - strupper(p); - p = skip_string(p,1); - pstrcpy(p,workgroup); - unix_to_dos(p,True); - strupper(p); - p = skip_string(p,1); - pstrcpy(p,"Unix");p = skip_string(p,1); - pstrcpy(p,"Samba");p = skip_string(p,1); - set_message(cli->outbuf,13,PTR_DIFF(p,smb_buf(cli->outbuf)),False); + p += clistr_push(cli, p, user, -1, STR_CONVERT|STR_TERMINATE|STR_UPPER); + p += clistr_push(cli, p, workgroup, -1, STR_CONVERT|STR_TERMINATE|STR_UPPER); + p += clistr_push(cli, p, "Unix", -1, STR_CONVERT|STR_TERMINATE); + p += clistr_push(cli, p, "Samba", -1, STR_CONVERT|STR_TERMINATE); + cli_setup_bcc(cli, p); } cli_send_smb(cli); @@ -187,24 +188,17 @@ BOOL cli_session_setup(struct cli_state *cli, cli->vuid = SVAL(cli->inbuf,smb_uid); if (cli->protocol >= PROTOCOL_NT1) { - /* - * Save off some of the connected server - * info. - */ - char *server_domain,*server_os,*server_type; - server_os = smb_buf(cli->inbuf); - server_type = skip_string(server_os,1); - server_domain = skip_string(server_type,1); - fstrcpy(cli->server_os, server_os); - dos_to_unix(cli->server_os, True); - fstrcpy(cli->server_type, server_type); - dos_to_unix(cli->server_type, True); - fstrcpy(cli->server_domain, server_domain); - dos_to_unix(cli->server_domain, True); + /* + * Save off some of the connected server + * info. + */ + char *q = smb_buf(cli->inbuf); + q += clistr_pull(cli, cli->server_os, q, sizeof(fstring), -1, STR_TERMINATE|STR_CONVERT); + q += clistr_pull(cli, cli->server_type, q, sizeof(fstring), -1, STR_TERMINATE|STR_CONVERT); + q += clistr_pull(cli, cli->server_domain, q, sizeof(fstring), -1, STR_TERMINATE|STR_CONVERT); } fstrcpy(cli->user_name, user); - dos_to_unix(cli->user_name, True); return True; } @@ -257,12 +251,11 @@ BOOL cli_send_tconX(struct cli_state *cli, unix_to_dos(dos_pword,True); SMBencrypt((uchar *)dos_pword,(uchar *)cli->cryptkey,(uchar *)pword); } else { - if(!(cli->sec_mode & 2)) { + if((cli->sec_mode & 3) == 0) { /* * Non-encrypted passwords - convert to DOS codepage before using. */ - fstrcpy(pword,pass); - unix_to_dos(pword,True); + passlen = clistr_push(cli, pword, pass, -1, STR_CONVERT|STR_TERMINATE); } else { memcpy(pword, pass, passlen); } @@ -273,8 +266,7 @@ BOOL cli_send_tconX(struct cli_state *cli, unix_to_dos(fullshare, True); strupper(fullshare); - set_message(cli->outbuf,4, - 2 + strlen(fullshare) + passlen + strlen(dev),True); + set_message(cli->outbuf,4, 0, True); CVAL(cli->outbuf,smb_com) = SMBtconX; cli_setup_packet(cli); @@ -284,10 +276,10 @@ BOOL cli_send_tconX(struct cli_state *cli, p = smb_buf(cli->outbuf); memcpy(p,pword,passlen); p += passlen; - fstrcpy(p,fullshare); - p = skip_string(p,1); - pstrcpy(p,dev); - unix_to_dos(p,True); + p += clistr_push(cli, p, fullshare, -1, STR_CONVERT | STR_TERMINATE); + fstrcpy(p, dev); p += strlen(dev)+1; + + cli_setup_bcc(cli, p); SCVAL(cli->inbuf,smb_rcls, 1); @@ -302,7 +294,7 @@ BOOL cli_send_tconX(struct cli_state *cli, fstrcpy(cli->dev, "A:"); if (cli->protocol >= PROTOCOL_NT1) { - fstrcpy(cli->dev, smb_buf(cli->inbuf)); + clistr_pull(cli, cli->dev, smb_buf(cli->inbuf), sizeof(fstring), -1, STR_TERMINATE | STR_CONVERT); } if (strcasecmp(share,"IPC$")==0) { @@ -347,17 +339,11 @@ void cli_negprot_send(struct cli_state *cli) { char *p; int numprots; - int plength; memset(cli->outbuf,'\0',smb_size); /* setup the protocol strings */ - for (plength=0,numprots=0; - prots[numprots].name && prots[numprots].prot<=cli->protocol; - numprots++) - plength += strlen(prots[numprots].name)+2; - - set_message(cli->outbuf,0,plength,True); + set_message(cli->outbuf,0,0,True); p = smb_buf(cli->outbuf); for (numprots=0; @@ -370,6 +356,7 @@ void cli_negprot_send(struct cli_state *cli) } CVAL(cli->outbuf,smb_com) = SMBnegprot; + cli_setup_bcc(cli, p); cli_setup_packet(cli); CVAL(smb_buf(cli->outbuf),0) = 2; @@ -461,6 +448,11 @@ BOOL cli_negprot(struct cli_state *cli) cli->max_xmit = MIN(cli->max_xmit, CLI_BUFFER_SIZE); + /* a way to force ascii SMB */ + if (getenv("CLI_FORCE_ASCII")) { + cli->capabilities &= ~CAP_UNICODE; + } + return True; } @@ -677,7 +669,7 @@ BOOL cli_establish_connection(struct cli_state *cli, { DEBUG(1,("failed session request\n")); if (do_shutdown) - cli_shutdown(cli); + cli_shutdown(cli); return False; } diff --git a/source/libsmb/clientgen.c b/source/libsmb/clientgen.c index 19380498063..8d4a025fcc0 100644 --- a/source/libsmb/clientgen.c +++ b/source/libsmb/clientgen.c @@ -106,11 +106,23 @@ void cli_setup_packet(struct cli_state *cli) SSVAL(cli->outbuf,smb_uid,cli->vuid); SSVAL(cli->outbuf,smb_mid,cli->mid); if (cli->protocol > PROTOCOL_CORE) { + uint16 flags2; SCVAL(cli->outbuf,smb_flg,0x8); - SSVAL(cli->outbuf,smb_flg2,0x1); + flags2 = FLAGS2_LONG_PATH_COMPONENTS; + if (cli->capabilities & CAP_UNICODE) { + flags2 |= FLAGS2_UNICODE_STRINGS; + } + SSVAL(cli->outbuf,smb_flg2, flags2); } } +/**************************************************************************** +setup the bcc length of the packet from a pointer to the end of the data +****************************************************************************/ +void cli_setup_bcc(struct cli_state *cli, void *p) +{ + set_message_bcc(cli->outbuf, PTR_DIFF(p, smb_buf(cli->outbuf))); +} /**************************************************************************** diff --git a/source/libsmb/clierror.c b/source/libsmb/clierror.c index eb2ca624e85..6d499867905 100644 --- a/source/libsmb/clierror.c +++ b/source/libsmb/clierror.c @@ -198,11 +198,12 @@ int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_ case ERRbadshare: return EBUSY; case ERRlock: return EBUSY; case ERROR_INVALID_NAME: return ENOENT; + case ERRnosuchshare: return ENODEV; } } if (rcls == ERRSRV) { switch (code) { - case ERRbadpw: return EACCES; + case ERRbadpw: return EPERM; case ERRaccess: return EACCES; case ERRnoresource: return ENOMEM; case ERRinvdevice: return ENODEV; diff --git a/source/libsmb/clifile.c b/source/libsmb/clifile.c index 42fdc3f3519..c2db97cb3e8 100644 --- a/source/libsmb/clifile.c +++ b/source/libsmb/clifile.c @@ -33,7 +33,7 @@ BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst) memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,1, 4 + strlen(fname_src) + strlen(fname_dst), True); + set_message(cli->outbuf,1, 0, True); CVAL(cli->outbuf,smb_com) = SMBmv; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -43,12 +43,13 @@ BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst) p = smb_buf(cli->outbuf); *p++ = 4; - pstrcpy(p,fname_src); - unix_to_dos(p,True); - p = skip_string(p,1); + p += clistr_push(cli, p, fname_src, -1, + STR_TERMINATE | STR_CONVERT); *p++ = 4; - pstrcpy(p,fname_dst); - unix_to_dos(p,True); + p += clistr_push(cli, p, fname_dst, -1, + STR_TERMINATE | STR_CONVERT); + + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -72,7 +73,7 @@ BOOL cli_unlink(struct cli_state *cli, char *fname) memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,1, 2 + strlen(fname),True); + set_message(cli->outbuf,1, 0,True); CVAL(cli->outbuf,smb_com) = SMBunlink; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -82,9 +83,9 @@ BOOL cli_unlink(struct cli_state *cli, char *fname) p = smb_buf(cli->outbuf); *p++ = 4; - pstrcpy(p,fname); - unix_to_dos(p,True); + p += clistr_push(cli, p, fname, -1, STR_TERMINATE | STR_CONVERT); + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { return False; @@ -107,7 +108,7 @@ BOOL cli_mkdir(struct cli_state *cli, char *dname) memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,0, 2 + strlen(dname),True); + set_message(cli->outbuf,0, 0,True); CVAL(cli->outbuf,smb_com) = SMBmkdir; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -115,8 +116,9 @@ BOOL cli_mkdir(struct cli_state *cli, char *dname) p = smb_buf(cli->outbuf); *p++ = 4; - pstrcpy(p,dname); - unix_to_dos(p,True); + p += clistr_push(cli, p, dname, -1, STR_CONVERT|STR_TERMINATE); + + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -140,7 +142,7 @@ BOOL cli_rmdir(struct cli_state *cli, char *dname) memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,0, 2 + strlen(dname),True); + set_message(cli->outbuf,0, 0, True); CVAL(cli->outbuf,smb_com) = SMBrmdir; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -148,8 +150,9 @@ BOOL cli_rmdir(struct cli_state *cli, char *dname) p = smb_buf(cli->outbuf); *p++ = 4; - pstrcpy(p,dname); - unix_to_dos(p,True); + p += clistr_push(cli, p, dname, -1, STR_TERMINATE|STR_CONVERT); + + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -173,7 +176,7 @@ int cli_nt_delete_on_close(struct cli_state *cli, int fnum, BOOL flag) int param_len = 6; uint16 setup = TRANSACT2_SETFILEINFO; pstring param; - char data; + unsigned char data; char *rparam=NULL, *rdata=NULL; memset(param, 0, param_len); @@ -183,11 +186,11 @@ int cli_nt_delete_on_close(struct cli_state *cli, int fnum, BOOL flag) data = flag ? 1 : 0; if (!cli_send_trans(cli, SMBtrans2, - NULL, 0, /* name, length */ - -1, 0, /* fid, flags */ - &setup, 1, 0, /* setup, length, max */ - param, param_len, 2, /* param, length, max */ - &data, data_len, cli->max_xmit /* data, length, max */ + NULL, /* name */ + -1, 0, /* fid, flags */ + &setup, 1, 0, /* setup, length, max */ + param, param_len, 2, /* param, length, max */ + &data, data_len, cli->max_xmit /* data, length, max */ )) { return False; } @@ -209,15 +212,17 @@ int cli_nt_delete_on_close(struct cli_state *cli, int fnum, BOOL flag) Used in smbtorture. ****************************************************************************/ -int cli_nt_create_full(struct cli_state *cli, char *fname, uint32 DesiredAccess, uint32 FileAttributes, - uint32 ShareAccess, uint32 CreateDisposition, uint32 CreateOptions) +int cli_nt_create_full(struct cli_state *cli, char *fname, uint32 DesiredAccess, + uint32 FileAttributes, uint32 ShareAccess, + uint32 CreateDisposition, uint32 CreateOptions) { char *p; + int len; memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,24,1 + strlen(fname),True); + set_message(cli->outbuf,24,0,True); CVAL(cli->outbuf,smb_com) = SMBntcreateX; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -235,12 +240,17 @@ int cli_nt_create_full(struct cli_state *cli, char *fname, uint32 DesiredAccess, SIVAL(cli->outbuf,smb_ntcreate_CreateDisposition, CreateDisposition); SIVAL(cli->outbuf,smb_ntcreate_CreateOptions, CreateOptions); SIVAL(cli->outbuf,smb_ntcreate_ImpersonationLevel, 0x02); - SSVAL(cli->outbuf,smb_ntcreate_NameLength, strlen(fname)); p = smb_buf(cli->outbuf); - pstrcpy(p,fname); - unix_to_dos(p,True); - p = skip_string(p,1); + /* this alignment and termination is critical for netapp filers. Don't change */ + p += clistr_align(cli->outbuf, p); + len = clistr_push(cli, p, fname, -1, STR_CONVERT); + p += len; + SSVAL(cli->outbuf,smb_ntcreate_NameLength, len); + /* sigh. this copes with broken netapp filer behaviour */ + p += clistr_push(cli, p, "", -1, STR_TERMINATE); + + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -257,6 +267,7 @@ int cli_nt_create_full(struct cli_state *cli, char *fname, uint32 DesiredAccess, /**************************************************************************** open a file ****************************************************************************/ + int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess) { return cli_nt_create_full(cli, fname, DesiredAccess, 0, @@ -265,56 +276,6 @@ int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess) /**************************************************************************** open a file -****************************************************************************/ -int cli_nt_create_uni(struct cli_state *cli, char *fname, uint32 DesiredAccess) -{ - pstring uni; - char *p; - - memset(cli->outbuf,'\0',smb_size); - memset(cli->inbuf,'\0',smb_size); - - set_message(cli->outbuf,24,(strlen(fname) + 1) * 2 + 1,True); - - CVAL(cli->outbuf,smb_com) = SMBntcreateX; - SSVAL(cli->outbuf,smb_tid,cli->cnum); - cli_setup_packet(cli); - - SSVAL(cli->outbuf,smb_vwv0,0xFF); - if (cli->use_oplocks) - SIVAL(cli->outbuf,smb_ntcreate_Flags, REQUEST_OPLOCK|REQUEST_BATCH_OPLOCK); - else - SIVAL(cli->outbuf,smb_ntcreate_Flags, 0); - SIVAL(cli->outbuf,smb_ntcreate_RootDirectoryFid, 0x0); - SIVAL(cli->outbuf,smb_ntcreate_DesiredAccess, DesiredAccess); - SIVAL(cli->outbuf,smb_ntcreate_FileAttributes, 0x0); - SIVAL(cli->outbuf,smb_ntcreate_ShareAccess, 0x03); - SIVAL(cli->outbuf,smb_ntcreate_CreateDisposition, 0x01); - SIVAL(cli->outbuf,smb_ntcreate_CreateOptions, 0x0); - SIVAL(cli->outbuf,smb_ntcreate_ImpersonationLevel, 0x02); - SSVAL(cli->outbuf,smb_ntcreate_NameLength, strlen(fname) * 2); - - p = smb_buf(cli->outbuf); - p++; /* Alignment */ - pstrcpy(uni, fname); - unix_to_dos(uni, True); - dos_struni2(p, uni, (strlen(fname) + 1) * 2); - - cli_send_smb(cli); - if (!cli_receive_smb(cli)) { - return -1; - } - - if (CVAL(cli->inbuf,smb_rcls) != 0) { - return -1; - } - - return SVAL(cli->inbuf,smb_vwv2 + 1); -} - - -/**************************************************************************** -open a file WARNING: if you open with O_WRONLY then getattrE won't work! ****************************************************************************/ int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode) @@ -353,7 +314,7 @@ int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode) memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,15,1 + strlen(fname),True); + set_message(cli->outbuf,15,0,True); CVAL(cli->outbuf,smb_com) = SMBopenX; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -375,9 +336,9 @@ int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode) } p = smb_buf(cli->outbuf); - pstrcpy(p,fname); - unix_to_dos(p,True); - p = skip_string(p,1); + p += clistr_push(cli, p, fname, -1, STR_TERMINATE | STR_CONVERT); + + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -436,7 +397,7 @@ BOOL cli_lock(struct cli_state *cli, int fnum, memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0', smb_size); - set_message(cli->outbuf,8,10,True); + set_message(cli->outbuf,8,0,True); CVAL(cli->outbuf,smb_com) = SMBlockingX; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -453,6 +414,11 @@ BOOL cli_lock(struct cli_state *cli, int fnum, SSVAL(p, 0, cli->pid); SIVAL(p, 2, offset); SIVAL(p, 6, len); + + p += 10; + + cli_setup_bcc(cli, p); + cli_send_smb(cli); cli->timeout = (timeout == -1) ? 0x7FFFFFFF : (timeout + 2*1000); @@ -481,7 +447,7 @@ BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len) memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,8,10,True); + set_message(cli->outbuf,8,0,True); CVAL(cli->outbuf,smb_com) = SMBlockingX; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -498,7 +464,8 @@ BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len) SSVAL(p, 0, cli->pid); SIVAL(p, 2, offset); SIVAL(p, 6, len); - + p += 10; + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { return False; @@ -528,7 +495,7 @@ BOOL cli_lock64(struct cli_state *cli, int fnum, memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0', smb_size); - set_message(cli->outbuf,8,20,True); + set_message(cli->outbuf,8,0,True); CVAL(cli->outbuf,smb_com) = SMBlockingX; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -543,8 +510,11 @@ BOOL cli_lock64(struct cli_state *cli, int fnum, p = smb_buf(cli->outbuf); SIVAL(p, 0, cli->pid); - SOFF_T_R(p, 0, offset); + SOFF_T_R(p, 4, offset); SOFF_T_R(p, 12, len); + p += 20; + + cli_setup_bcc(cli, p); cli_send_smb(cli); cli->timeout = (timeout == -1) ? 0x7FFFFFFF : (timeout + 2*1000); @@ -573,7 +543,7 @@ BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_ memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,8,20,True); + set_message(cli->outbuf,8,0,True); CVAL(cli->outbuf,smb_com) = SMBlockingX; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -590,7 +560,8 @@ BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_ SIVAL(p, 0, cli->pid); SOFF_T_R(p, 4, offset); SOFF_T_R(p, 12, len); - + p += 20; + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { return False; @@ -669,16 +640,17 @@ BOOL cli_getatr(struct cli_state *cli, char *fname, memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,0,strlen(fname)+2,True); + set_message(cli->outbuf,0,0,True); CVAL(cli->outbuf,smb_com) = SMBgetatr; SSVAL(cli->outbuf,smb_tid,cli->cnum); cli_setup_packet(cli); p = smb_buf(cli->outbuf); - *p = 4; - pstrcpy(p+1, fname); - unix_to_dos(p+1,True); + *p++ = 4; + p += clistr_push(cli, p, fname, -1, STR_TERMINATE | STR_CONVERT); + + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -716,7 +688,7 @@ BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t) memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,8,strlen(fname)+4,True); + set_message(cli->outbuf,8,0,True); CVAL(cli->outbuf,smb_com) = SMBsetatr; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -726,11 +698,11 @@ BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t) put_dos_date3(cli->outbuf,smb_vwv1, t); p = smb_buf(cli->outbuf); - *p = 4; - pstrcpy(p+1, fname); - unix_to_dos(p+1,True); - p = skip_string(p,1); - *p = 4; + *p++ = 4; + p += clistr_push(cli, p, fname, -1, STR_TERMINATE | STR_CONVERT); + *p++ = 4; + + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -758,14 +730,15 @@ BOOL cli_chkpath(struct cli_state *cli, char *path) if (!*path2) *path2 = '\\'; memset(cli->outbuf,'\0',smb_size); - set_message(cli->outbuf,0,4 + strlen(path2),True); + set_message(cli->outbuf,0,0,True); SCVAL(cli->outbuf,smb_com,SMBchkpth); SSVAL(cli->outbuf,smb_tid,cli->cnum); cli_setup_packet(cli); p = smb_buf(cli->outbuf); *p++ = 4; - safe_strcpy(p,path2,strlen(path2)); - unix_to_dos(p,True); + p += clistr_push(cli, p, path2, -1, STR_TERMINATE | STR_CONVERT); + + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -823,9 +796,7 @@ int cli_ctemp(struct cli_state *cli, char *path, char **tmp_path) p = smb_buf(cli->outbuf); *p++ = 4; - pstrcpy(p,path); - unix_to_dos(p,True); - p = skip_string(p,1); + p += clistr_push(cli, p, path, -1, STR_TERMINATE | STR_CONVERT); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -837,7 +808,10 @@ int cli_ctemp(struct cli_state *cli, char *path, char **tmp_path) } if (tmp_path) { - *tmp_path = strdup(smb_buf(cli->inbuf)+1); + pstring path2; + clistr_pull(cli, path2, smb_buf(cli->inbuf)+1, + sizeof(path2), -1, STR_TERMINATE | STR_CONVERT); + *tmp_path = strdup(path2); } return SVAL(cli->inbuf,smb_vwv0); diff --git a/source/libsmb/clilist.c b/source/libsmb/clilist.c index 2e904e06b7d..9080a9c2215 100644 --- a/source/libsmb/clilist.c +++ b/source/libsmb/clilist.c @@ -30,7 +30,8 @@ The length of the structure is returned The structure of a long filename depends on the info level. 260 is used by NT and 2 is used by OS/2 ****************************************************************************/ -static int interpret_long_filename(int level,char *p,file_info *finfo) +static int interpret_long_filename(struct cli_state *cli, + int level,char *p,file_info *finfo) { extern file_info def_finfo; @@ -47,8 +48,10 @@ static int interpret_long_filename(int level,char *p,file_info *finfo) finfo->mtime = make_unix_date2(p+12); finfo->size = IVAL(p,16); finfo->mode = CVAL(p,24); - pstrcpy(finfo->name,p+27); - dos_to_unix(finfo->name,True); + clistr_pull(cli, finfo->name, p+27, + sizeof(finfo->name), + -1, + STR_TERMINATE | STR_CONVERT); } return(28 + CVAL(p,26)); @@ -60,8 +63,10 @@ static int interpret_long_filename(int level,char *p,file_info *finfo) finfo->mtime = make_unix_date2(p+12); finfo->size = IVAL(p,16); finfo->mode = CVAL(p,24); - pstrcpy(finfo->name,p+31); - dos_to_unix(finfo->name,True); + clistr_pull(cli, finfo->name, p+31, + sizeof(finfo->name), + -1, + STR_TERMINATE | STR_CONVERT); } return(32 + CVAL(p,30)); @@ -74,8 +79,10 @@ static int interpret_long_filename(int level,char *p,file_info *finfo) finfo->mtime = make_unix_date2(p+16); finfo->size = IVAL(p,20); finfo->mode = CVAL(p,28); - pstrcpy(finfo->name,p+33); - dos_to_unix(finfo->name,True); + clistr_pull(cli, finfo->name, p+33, + sizeof(finfo->name), + -1, + STR_TERMINATE | STR_CONVERT); } return(SVAL(p,4)+4); @@ -87,8 +94,10 @@ static int interpret_long_filename(int level,char *p,file_info *finfo) finfo->mtime = make_unix_date2(p+16); finfo->size = IVAL(p,20); finfo->mode = CVAL(p,28); - pstrcpy(finfo->name,p+37); - dos_to_unix(finfo->name,True); + clistr_pull(cli, finfo->name, p+37, + sizeof(finfo->name), + -1, + STR_TERMINATE | STR_CONVERT); } return(SVAL(p,4)+4); @@ -124,16 +133,19 @@ static int interpret_long_filename(int level,char *p,file_info *finfo) p += 4; /* EA size */ slen = SVAL(p, 0); p += 2; - if (p[1] == 0 && slen > 1) { - /* NT has stuffed up again */ - unistr_to_dos(finfo->short_name, p, slen/2); - } else { - strncpy(finfo->short_name, p, 12); - finfo->short_name[12] = 0; + { + /* stupid NT bugs. grr */ + int flags = STR_CONVERT; + if (p[1] == 0 && namelen > 1) flags |= STR_UNICODE; + clistr_pull(cli, finfo->short_name, p, + sizeof(finfo->short_name), + 24, flags); } p += 24; /* short name? */ - StrnCpy(finfo->name,p,MIN(sizeof(finfo->name)-1,namelen)); - dos_to_unix(finfo->name,True); + clistr_pull(cli, finfo->name, p, + sizeof(finfo->name), + namelen, + STR_CONVERT); return(ret); } return(SVAL(p,0)); @@ -147,12 +159,11 @@ static int interpret_long_filename(int level,char *p,file_info *finfo) /**************************************************************************** do a directory listing, calling fn on each file found ****************************************************************************/ -int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, - void (*fn)(file_info *, const char *)) +int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, + void (*fn)(file_info *, const char *, void *), void *state) { int max_matches = 512; - /* NT uses 260, OS/2 uses 2. Both accept 1. */ - int info_level = cli->protocol<PROTOCOL_NT1?1:260; + int info_level; char *p, *p2; pstring mask; file_info finfo; @@ -170,9 +181,11 @@ int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, int param_len, data_len; uint16 setup; pstring param; - + + /* NT uses 260, OS/2 uses 2. Both accept 1. */ + info_level = (cli->capabilities&CAP_NT_SMBS)?260:1; + pstrcpy(mask,Mask); - unix_to_dos(mask,True); while (ff_eos == 0) { loop_count++; @@ -181,8 +194,6 @@ int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, break; } - param_len = 12+strlen(mask)+1; - if (First) { setup = TRANSACT2_FINDFIRST; SSVAL(param,0,attribute); /* attribute */ @@ -190,7 +201,9 @@ int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, SSVAL(param,4,4+2); /* resume required + close on end */ SSVAL(param,6,info_level); SIVAL(param,8,0); - pstrcpy(param+12,mask); + p = param+12; + p += clistr_push(cli, param+12, mask, -1, + STR_TERMINATE | STR_CONVERT); } else { setup = TRANSACT2_FINDNEXT; SSVAL(param,0,ff_dir_handle); @@ -198,14 +211,15 @@ int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, SSVAL(param,4,info_level); SIVAL(param,6,0); /* ff_resume_key */ SSVAL(param,10,8+4+2); /* continue + resume required + close on end */ - pstrcpy(param+12,mask); - - DEBUG(5,("hand=0x%X ff_lastname=%d mask=%s\n", - ff_dir_handle,ff_lastname,mask)); + p = param+12; + p += clistr_push(cli, param+12, mask, -1, + STR_TERMINATE | STR_CONVERT); } + param_len = PTR_DIFF(p, param); + 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 */ @@ -254,19 +268,24 @@ int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, switch(info_level) { case 260: - StrnCpy(mask,p+ff_lastname, - MIN(sizeof(mask)-1,data_len-ff_lastname)); + clistr_pull(cli, mask, p+ff_lastname, + sizeof(mask), + data_len-ff_lastname, + STR_TERMINATE | + STR_CONVERT); break; case 1: - pstrcpy(mask,p + ff_lastname + 1); + clistr_pull(cli, mask, p+ff_lastname+1, + sizeof(mask), + -1, + STR_TERMINATE | + STR_CONVERT); break; } } else { pstrcpy(mask,""); } - dos_to_unix(mask, True); - /* and add them to the dirlist pool */ dirlist = Realloc(dirlist,dirlist_len + data_len); @@ -278,7 +297,7 @@ int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, /* put in a length for the last entry, to ensure we can chain entries into the next packet */ for (p2=p,i=0;i<(ff_searchcount-1);i++) - p2 += interpret_long_filename(info_level,p2,NULL); + p2 += interpret_long_filename(cli,info_level,p2,NULL); SSVAL(p2,0,data_len - PTR_DIFF(p2,p)); /* grab the data for later use */ @@ -299,8 +318,8 @@ int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, } for (p=dirlist,i=0;i<total_received;i++) { - p += interpret_long_filename(info_level,p,&finfo); - fn(&finfo, Mask); + p += interpret_long_filename(cli,info_level,p,&finfo); + fn(&finfo, Mask, state); } /* free up the dirlist buffer */ @@ -314,7 +333,7 @@ int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, interpret a short filename structure The length of the structure is returned ****************************************************************************/ -static int interpret_short_filename(char *p,file_info *finfo) +static int interpret_short_filename(struct cli_state *cli, char *p,file_info *finfo) { extern file_info def_finfo; @@ -326,7 +345,7 @@ static int interpret_short_filename(char *p,file_info *finfo) finfo->ctime = make_unix_date(p+22); finfo->mtime = finfo->atime = finfo->ctime; finfo->size = IVAL(p,26); - pstrcpy(finfo->name,p+30); + clistr_pull(cli, finfo->name, p+30, sizeof(finfo->name), 12, STR_CONVERT|STR_ASCII); if (strcmp(finfo->name, "..") && strcmp(finfo->name, ".")) fstrcpy(finfo->short_name,finfo->name); @@ -340,7 +359,7 @@ static int interpret_short_filename(char *p,file_info *finfo) but should otherwise not be used ****************************************************************************/ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, - void (*fn)(file_info *, const char *)) + void (*fn)(file_info *, const char *, void *), void *state) { char *p; int received = 0; @@ -360,12 +379,9 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - if (first) - set_message(cli->outbuf,2,5 + strlen(mask),True); - else - set_message(cli->outbuf,2,5 + 21,True); + set_message(cli->outbuf,2,0,True); - CVAL(cli->outbuf,smb_com) = SMBffirst; + CVAL(cli->outbuf,smb_com) = SMBsearch; SSVAL(cli->outbuf,smb_tid,cli->cnum); cli_setup_packet(cli); @@ -376,21 +392,19 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, p = smb_buf(cli->outbuf); *p++ = 4; - if (first) - pstrcpy(p,mask); - else - pstrcpy(p,""); - p += strlen(p) + 1; - + p += clistr_push(cli, p, first?mask:"", -1, STR_TERMINATE|STR_CONVERT); *p++ = 5; if (first) { SSVAL(p,0,0); + p += 2; } else { SSVAL(p,0,21); p += 2; memcpy(p,status,21); + p += 21; } + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) break; @@ -420,7 +434,7 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,2,5 + 21,True); + set_message(cli->outbuf,2,0,True); CVAL(cli->outbuf,smb_com) = SMBfclose; SSVAL(cli->outbuf,smb_tid,cli->cnum); cli_setup_packet(cli); @@ -436,7 +450,9 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, SSVAL(p, 0, 21); p += 2; memcpy(p,status,21); + p += 21; + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { DEBUG(0,("Error closing search: %s\n",smb_errstr(cli->inbuf))); @@ -445,10 +461,24 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, for (p=dirlist,i=0;i<num_received;i++) { file_info finfo; - p += interpret_short_filename(p,&finfo); - fn(&finfo, Mask); + p += interpret_short_filename(cli, p,&finfo); + fn(&finfo, Mask, state); } if (dirlist) free(dirlist); return(num_received); } + + +/**************************************************************************** + do a directory listing, calling fn on each file found + this auto-switches between old and new style + ****************************************************************************/ +int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, + void (*fn)(file_info *, const char *, void *), void *state) +{ + if (cli->protocol <= PROTOCOL_LANMAN1) { + return cli_list_old(cli, Mask, attribute, fn, state); + } + return cli_list_new(cli, Mask, attribute, fn, state); +} diff --git a/source/libsmb/climessage.c b/source/libsmb/climessage.c index c15fdbce8c5..87f81754599 100644 --- a/source/libsmb/climessage.c +++ b/source/libsmb/climessage.c @@ -41,15 +41,13 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username, p = smb_buf(cli->outbuf); *p++ = 4; - pstrcpy(p,username); - unix_to_dos(p,True); - p = skip_string(p,1); + p += clistr_push(cli, p, username, -1, + STR_TERMINATE|STR_CONVERT); *p++ = 4; - pstrcpy(p,host); - unix_to_dos(p,True); - p = skip_string(p,1); + p += clistr_push(cli, p, host, -1, + STR_TERMINATE|STR_CONVERT); - set_message(cli->outbuf,0,PTR_DIFF(p,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, p); cli_send_smb(cli); diff --git a/source/libsmb/clirap.c b/source/libsmb/clirap.c index 085b1c35bb9..561d717e730 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 */ @@ -137,7 +134,7 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) /**************************************************************************** call a NetShareEnum - try and browse available connections on a host ****************************************************************************/ -int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *)) +int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *, void *), void *state) { char *rparam = NULL; char *rdata = NULL; @@ -184,7 +181,7 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co char *cmnt = comment_offset?(rdata+comment_offset-converter):""; dos_to_unix(sname,True); dos_to_unix(cmnt,True); - fn(sname, type, cmnt); + fn(sname, type, cmnt, state); } } else { DEBUG(4,("NetShareEnum res=%d\n", res)); @@ -210,7 +207,8 @@ The callback function takes 3 arguments: the machine name, the server type and the comment. ****************************************************************************/ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, - void (*fn)(const char *, uint32, const char *)) + void (*fn)(const char *, uint32, const char *, void *), + void *state) { char *rparam = NULL; char *rdata = NULL; @@ -219,7 +217,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, pstring param; int uLevel = 1; int count = -1; - + /* send a SMBtrans command with api NetServerEnum */ p = param; SSVAL(p,0,0x68); /* api number */ @@ -228,17 +226,16 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, p = skip_string(p,1); pstrcpy(p,"B16BBDz"); - + p = skip_string(p,1); SSVAL(p,0,uLevel); SSVAL(p,2,CLI_BUFFER_SIZE); p += 4; SIVAL(p,0,stype); p += 4; - - pstrcpy(p, workgroup); - unix_to_dos(p, True); - p = skip_string(p,1); + + p += clistr_push(cli, p, workgroup, -1, + STR_TERMINATE | STR_CONVERT | STR_ASCII); if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */ @@ -265,7 +262,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, dos_to_unix(sname, True); dos_to_unix(cmnt, True); - fn(sname, stype, cmnt); + fn(sname, stype, cmnt, state); } } } @@ -349,7 +346,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 */ @@ -391,17 +388,19 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, int count=8; BOOL ret; time_t (*date_fn)(void *); + char *p; - param_len = strlen(fname) + 7; + p = param; + memset(p, 0, 6); + SSVAL(p, 0, SMB_INFO_STANDARD); + p += 6; + p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE | STR_CONVERT); - memset(param, 0, param_len); - SSVAL(param, 0, SMB_INFO_STANDARD); - pstrcpy(¶m[6], fname); - unix_to_dos(¶m[6],True); + param_len = PTR_DIFF(p, param); 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 */ @@ -465,16 +464,18 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, uint16 setup = TRANSACT2_QPATHINFO; pstring param; char *rparam=NULL, *rdata=NULL; + char *p; - param_len = strlen(fname) + 7; + p = param; + memset(p, 0, 6); + SSVAL(p, 0, SMB_QUERY_FILE_ALL_INFO); + p += 6; + p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE | STR_CONVERT); - memset(param, 0, param_len); - SSVAL(param, 0, SMB_QUERY_FILE_ALL_INFO); - pstrcpy(¶m[6], fname); - unix_to_dos(¶m[6],True); + param_len = PTR_DIFF(p, param); 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 */ @@ -546,7 +547,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/clitrans.c b/source/libsmb/clitrans.c index 5cd6ae30ce0..d21d179126a 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,11 @@ 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(cli, smb_buf(cli->outbuf), pipe_name, -1, STR_TERMINATE); + } + + outparam = smb_buf(cli->outbuf)+(trans==SMBtrans ? pipe_name_len : 3); outdata = outparam+this_lparam; /* primary request */ @@ -68,9 +73,7 @@ BOOL cli_send_trans(struct cli_state *cli, int trans, for (i=0;i<lsetup;i++) /* setup[] */ 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[] */ - } else { + if (trans != SMBtrans) { *p++ = 0; /* put in a null smb_name */ *p++ = 'D'; *p++ = ' '; /* observed in OS/2 */ } @@ -78,8 +81,7 @@ BOOL cli_send_trans(struct cli_state *cli, int trans, memcpy(outparam,param,this_lparam); if (this_ldata) /* data[] */ memcpy(outdata,data,this_ldata); - set_message(cli->outbuf,14+lsetup, /* wcnt, bcc */ - PTR_DIFF(outdata+this_ldata,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, outdata+this_ldata); show_msg(cli->outbuf); cli_send_smb(cli); @@ -119,8 +121,7 @@ BOOL cli_send_trans(struct cli_state *cli, int trans, memcpy(outparam,param+tot_param,this_lparam); if (this_ldata) /* data[] */ memcpy(outdata,data+tot_data,this_ldata); - set_message(cli->outbuf,trans==SMBtrans?8:9, /* wcnt, bcc */ - PTR_DIFF(outdata+this_ldata,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, outdata+this_ldata); show_msg(cli->outbuf); cli_send_smb(cli); @@ -288,8 +289,7 @@ BOOL cli_send_nt_trans(struct cli_state *cli, if (this_ldata) /* data[] */ memcpy(outdata,data,this_ldata); - set_message(cli->outbuf,19+lsetup, /* wcnt, bcc */ - PTR_DIFF(outdata+this_ldata,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, outdata+this_ldata); show_msg(cli->outbuf); cli_send_smb(cli); @@ -328,8 +328,7 @@ BOOL cli_send_nt_trans(struct cli_state *cli, memcpy(outparam,param+tot_param,this_lparam); if (this_ldata) /* data[] */ memcpy(outdata,data+tot_data,this_ldata); - set_message(cli->outbuf,18, - PTR_DIFF(outdata+this_ldata,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, outdata+this_ldata); show_msg(cli->outbuf); cli_send_smb(cli); diff --git a/source/libsmb/namequery.c b/source/libsmb/namequery.c index 816804753e7..7714de760b2 100644 --- a/source/libsmb/namequery.c +++ b/source/libsmb/namequery.c @@ -190,6 +190,96 @@ BOOL name_status_find(int type, struct in_addr to_ip, char *name) return True; } +/**************************************************************************** + Do a NetBIOS name registation to try to claim a name ... +***************************************************************************/ +BOOL name_register(int fd, const char *name, int name_type, + struct in_addr name_ip, int opcode, + BOOL bcast, + struct in_addr to_ip, int *count) +{ + int retries = 3; + struct timeval tval; + struct packet_struct p; + struct packet_struct *p2; + struct nmb_packet *nmb = &p.packet.nmb; + struct in_addr register_ip; + + DEBUG(4, ("name_register: %s as %s on %s\n", name, inet_ntoa(name_ip), inet_ntoa(to_ip))); + + register_ip.s_addr = name_ip.s_addr; /* Fix this ... */ + + bzero((char *)&p, sizeof(p)); + + *count = 0; + + nmb->header.name_trn_id = generate_trn_id(); + nmb->header.opcode = opcode; + nmb->header.response = False; + nmb->header.nm_flags.bcast = False; + nmb->header.nm_flags.recursion_available = False; + nmb->header.nm_flags.recursion_desired = True; /* ? */ + nmb->header.nm_flags.trunc = False; + nmb->header.nm_flags.authoritative = True; + + nmb->header.qdcount = 1; + nmb->header.ancount = 0; + nmb->header.nscount = 0; + nmb->header.arcount = 1; + + make_nmb_name(&nmb->question.question_name, name, name_type); + + nmb->question.question_type = 0x20; + nmb->question.question_class = 0x1; + + /* Now, create the additional stuff for a registration request */ + + if ((nmb->additional = (struct res_rec *)malloc(sizeof(struct res_rec))) == NULL) { + + DEBUG(0, ("name_register: malloc fail for additional record.\n")); + return False; + + } + + bzero((char *)nmb->additional, sizeof(struct res_rec)); + + nmb->additional->rr_name = nmb->question.question_name; + nmb->additional->rr_type = RR_TYPE_NB; + nmb->additional->rr_class = RR_CLASS_IN; + + /* See RFC 1002, sections 5.1.1.1, 5.1.1.2 and 5.1.1.3 */ + if (nmb->header.nm_flags.bcast) + nmb->additional->ttl = PERMANENT_TTL; + else + nmb->additional->ttl = lp_max_ttl(); + + nmb->additional->rdlength = 6; + + nmb->additional->rdata[0] = NB_MFLAG & 0xFF; + + /* Set the address for the name we are registering. */ + putip(&nmb->additional->rdata[2], ®ister_ip); + + p.ip = to_ip; + p.port = NMB_PORT; + p.fd = fd; + p.timestamp = time(NULL); + p.packet_type = NMB_PACKET; + + GetTimeOfDay(&tval); + + if (!send_packet(&p)) + return False; + + retries--; + + if ((p2 = receive_nmb_packet(fd, 10, nmb->header.name_trn_id))) { + debug_nmb_packet(p2); + free(p2); /* No memory leaks ... */ + } + + return True; +} /**************************************************************************** Do a netbios name query to find someones IP. @@ -456,6 +546,65 @@ void endlmhosts(FILE *fp) fclose(fp); } +BOOL name_register_wins(const char *name, int name_type) +{ + int sock, i, return_count; + int num_interfaces = iface_count(); + struct in_addr sendto_ip; + + /* + * Do a broadcast register ... + */ + + if (!lp_wins_server()) + return False; + + DEBUG(4, ("name_register_wins:Registering my name %s on %s\n", name, lp_wins_server())); + + sock = open_socket_in(SOCK_DGRAM, 0, 3, + interpret_addr("0.0.0.0"), True); + + if (sock == -1) return False; + + set_socket_options(sock, "SO_BROADCAST"); + + sendto_ip.s_addr = inet_addr(lp_wins_server()); + + if (num_interfaces > 1) { + + for (i = 0; i < num_interfaces; i++) { + + if (!name_register(sock, name, name_type, *iface_n_ip(i), + NMB_NAME_MULTIHOMED_REG_OPCODE, + True, sendto_ip, &return_count)) { + + close(sock); + return False; + + } + + } + + } + else { + + if (!name_register(sock, name, name_type, *iface_n_ip(0), + NMB_NAME_REG_OPCODE, + True, sendto_ip, &return_count)) { + + close(sock); + return False; + + } + + } + + close(sock); + + return True; + +} + /******************************************************** Resolve via "bcast" method. *********************************************************/ diff --git a/source/libsmb/pwd_cache.c b/source/libsmb/pwd_cache.c index 26b1d192f09..420b49ed2e7 100644 --- a/source/libsmb/pwd_cache.c +++ b/source/libsmb/pwd_cache.c @@ -103,11 +103,21 @@ void pwd_read(struct pwd_info *pwd, char *passwd_report, BOOL do_encrypt) user_pass = (char*)getpass(passwd_report); + /* + * Do not assume that an empty string is a NULL password. + * If you do this will break the session key generation for + * and account with an emtpy password. If you wish to use + * a NULL password, use the -N option to smbclient and rpcclient + * --jerry + */ +#if 0 if (user_pass == NULL || user_pass[0] == 0) { pwd_set_nullpwd(pwd); } else if (do_encrypt) +#endif + if (do_encrypt) { pwd_make_lm_nt_16(pwd, user_pass); } diff --git a/source/nmbd/nmbd_synclists.c b/source/nmbd/nmbd_synclists.c index 6105fb41650..23cbc01b889 100644 --- a/source/nmbd/nmbd_synclists.c +++ b/source/nmbd/nmbd_synclists.c @@ -51,7 +51,8 @@ static FILE *fp; This is the NetServerEnum callback. Note sname and comment are in UNIX codepage format. ******************************************************************/ -static void callback(const char *sname, uint32 stype, const char *comment) +static void callback(const char *sname, uint32 stype, + const char *comment, void *state) { fprintf(fp,"\"%s\" %08X \"%s\"\n", sname, stype, comment); } @@ -106,8 +107,8 @@ static void sync_child(char *name, int nm_type, /* Fetch a workgroup list. */ cli_NetServerEnum(&cli, unix_workgroup, - local_type|SV_TYPE_DOMAIN_ENUM, - callback); + local_type|SV_TYPE_DOMAIN_ENUM, + callback, NULL); /* Now fetch a server list. */ if (servers) { @@ -115,7 +116,7 @@ static void sync_child(char *name, int nm_type, dos_to_unix(unix_workgroup, True); cli_NetServerEnum(&cli, unix_workgroup, local?SV_TYPE_LOCAL_LIST_ONLY:SV_TYPE_ALL, - callback); + callback, NULL); } cli_shutdown(&cli); diff --git a/source/rpc_client/cli_pipe.c b/source/rpc_client/cli_pipe.c index 1ef8a78ea14..b4ca34ea7d5 100644 --- a/source/rpc_client/cli_pipe.c +++ b/source/rpc_client/cli_pipe.c @@ -347,7 +347,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 */ @@ -913,7 +913,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 */ |