diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-02-21 03:40:20 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-02-21 03:40:20 +0000 |
commit | a8ab9840786b8376283743de8eef861d382b3171 (patch) | |
tree | b0724235c8223e11e1287f0b542bf9f2bd28ef1e | |
parent | 518f2fc391266c2f9b9cfc8b485a8e57ce359be8 (diff) | |
download | samba-a8ab9840786b8376283743de8eef861d382b3171.tar.gz samba-a8ab9840786b8376283743de8eef861d382b3171.tar.bz2 samba-a8ab9840786b8376283743de8eef861d382b3171.zip |
the unicode conversion of our client code is complete enough to be
enabled by default
you can disable it by setting the environment variable CLI_FORCE_ASCII
(This used to be commit 4d59c08c5e6f54c0d6ced7650750cb987e77b6c9)
-rw-r--r-- | source3/Makefile.in | 2 | ||||
-rw-r--r-- | source3/include/proto.h | 3 | ||||
-rw-r--r-- | source3/libsmb/cliconnect.c | 12 | ||||
-rw-r--r-- | source3/libsmb/clientgen.c | 13 | ||||
-rw-r--r-- | source3/libsmb/clifile.c | 50 | ||||
-rw-r--r-- | source3/libsmb/clilist.c | 25 | ||||
-rw-r--r-- | source3/libsmb/clistr.c | 13 | ||||
-rw-r--r-- | source3/libsmb/libsmbclient.c | 6 |
8 files changed, 26 insertions, 98 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index a3c3849743..5f0b19bf00 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -83,7 +83,7 @@ FLAGS32 = $(ISA32) $(FLAGS5) $(PASSWD_FLAGS) SPROGS = bin/smbd bin/nmbd bin/swat PROGS1 = bin/smbclient bin/smbspool bin/testparm bin/testprns bin/smbstatus bin/smbcontrol @RUNPROG@ -PROGS2 = bin/smbpasswd bin/make_smbcodepage bin/make_unicodemap bin/rpcclient @WRAP@ @WRAP32@ +PROGS2 = bin/smbpasswd bin/make_smbcodepage bin/make_unicodemap bin/rpcclient bin/smbcacls @WRAP@ @WRAP32@ MPROGS = @MPROGS@ PROGS = $(PROGS1) $(PROGS2) $(MPROGS) bin/nmblookup bin/make_printerdef bin/pdbedit diff --git a/source3/include/proto.h b/source3/include/proto.h index d25935c9c6..ab1f235aa7 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -821,7 +821,6 @@ 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_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, @@ -844,7 +843,7 @@ BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail); int cli_list(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); /*The following definitions come from libsmb/climessage.c */ diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 4a957a9ccd..d572c0f7d7 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -144,10 +144,10 @@ BOOL cli_session_setup(struct cli_state *cli, uint32 capabilities; capabilities = CAP_NT_SMBS; - if (cli->use_level_II_oplocks) + if (cli->use_level_II_oplocks) { capabilities |= CAP_LEVEL_II_OPLOCKS; - if (getenv("USE_UNICODE") && - (cli->capabilities & CAP_UNICODE)) { + } + if (cli->capabilities & CAP_UNICODE) { capabilities |= CAP_UNICODE; } set_message(cli->outbuf,13,0,True); @@ -453,8 +453,10 @@ BOOL cli_negprot(struct cli_state *cli) cli->max_xmit = MIN(cli->max_xmit, CLI_BUFFER_SIZE); - /* this ensures cli_use_unicode is setup - delete this call later (tridge) */ - cli_setup_packet(cli); + /* a way to force ascii SMB */ + if (getenv("CLI_FORCE_ASCII")) { + cli->capabilities &= ~CAP_UNICODE; + } return True; } diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index c25e71ff3d..8d4a025fcc 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -95,22 +95,11 @@ BOOL cli_send_smb(struct cli_state *cli) return True; } -int cli_use_unicode = 0; - /**************************************************************************** setup basics in a outgoing packet ****************************************************************************/ void cli_setup_packet(struct cli_state *cli) { - static int initialised; - - /* the USE_UNICODE check will be deleted once our client side unicode - support is complete (tridge) */ - if (!initialised) { - initialised = 1; - if (getenv("USE_UNICODE")) cli_use_unicode = 1; - } - cli->rap_error = 0; cli->nt_error = 0; SSVAL(cli->outbuf,smb_pid,cli->pid); @@ -120,7 +109,7 @@ void cli_setup_packet(struct cli_state *cli) uint16 flags2; SCVAL(cli->outbuf,smb_flg,0x8); flags2 = FLAGS2_LONG_PATH_COMPONENTS; - if (cli_use_unicode && cli->capabilities & CAP_UNICODE) { + if (cli->capabilities & CAP_UNICODE) { flags2 |= FLAGS2_UNICODE_STRINGS; } SSVAL(cli->outbuf,smb_flg2, flags2); diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index c5da049cf4..6264baf00e 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -221,56 +221,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,0,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); - p += dos_struni2(p, uni, (strlen(fname) + 1) * 2) * 2; - cli_setup_bcc(cli, p); - 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) diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c index 9348b65bad..d4cc00d9f3 100644 --- a/source3/libsmb/clilist.c +++ b/source3/libsmb/clilist.c @@ -353,7 +353,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; @@ -373,12 +373,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); @@ -389,21 +386,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, CLISTR_TERMINATE|CLISTR_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; @@ -433,7 +428,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); @@ -449,7 +444,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))); @@ -459,7 +456,7 @@ 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); + fn(&finfo, Mask, state); } if (dirlist) free(dirlist); diff --git a/source3/libsmb/clistr.c b/source3/libsmb/clistr.c index da40fba9e6..9f46099ba9 100644 --- a/source3/libsmb/clistr.c +++ b/source3/libsmb/clistr.c @@ -23,9 +23,6 @@ #include "includes.h" -/* we will delete this variable once our client side unicode support is complete */ -extern int cli_use_unicode; - /**************************************************************************** copy a string from a char* src to a unicode or ascii dos code page destination choosing unicode or ascii based on the @@ -55,7 +52,7 @@ int clistr_push(struct cli_state *cli, void *dest, char *src, int dest_len, int len++; } - if ((flags & CLISTR_ASCII) || !cli_use_unicode || !(cli->capabilities & CAP_UNICODE)) { + if ((flags & CLISTR_ASCII) || !(cli->capabilities & CAP_UNICODE)) { /* the server doesn't want unicode */ safe_strcpy(dest, src, dest_len); len = strlen(dest); @@ -91,7 +88,7 @@ int clistr_push_size(struct cli_state *cli, void *dest, char *src, int dest_len, { int len = strlen(src); if (flags & CLISTR_TERMINATE) len++; - if (!(flags & CLISTR_ASCII) && cli_use_unicode && (cli->capabilities & CAP_UNICODE)) len *= 2; + if (!(flags & CLISTR_ASCII) && (cli->capabilities & CAP_UNICODE)) len *= 2; if (!(flags & CLISTR_ASCII) && dest && clistr_align(cli, PTR_DIFF(cli->outbuf, dest))) { len++; @@ -123,7 +120,7 @@ int clistr_pull(struct cli_state *cli, char *dest, void *src, int dest_len, int if (src_len > 0) src_len--; } - if (!cli_use_unicode || !(cli->capabilities & CAP_UNICODE)) { + if (!(cli->capabilities & CAP_UNICODE)) { /* the server doesn't want unicode */ if (flags & CLISTR_TERMINATE) { safe_strcpy(dest, src, dest_len); @@ -167,7 +164,7 @@ int clistr_pull_size(struct cli_state *cli, void *src, int src_len) if (src_len > 0) src_len--; } - if (!cli_use_unicode || !(cli->capabilities & CAP_UNICODE)) { + if (!(cli->capabilities & CAP_UNICODE)) { return strlen(src); } return strlen_w(src); @@ -180,6 +177,6 @@ otherwise return 1 if offset is off ****************************************************************************/ int clistr_align(struct cli_state *cli, int offset) { - if (!cli_use_unicode || !(cli->capabilities & CAP_UNICODE)) return 0; + if (!(cli->capabilities & CAP_UNICODE)) return 0; return offset & 1; } diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c index 1444e5883a..bc400d5b8d 100644 --- a/source3/libsmb/libsmbclient.c +++ b/source3/libsmb/libsmbclient.c @@ -1575,11 +1575,8 @@ int smbc_opendir(const char *fname) /* find the name of the server ... */ if (!name_status_find(0, rem_ip, server)) { - - fprintf(stderr, "Could not get the name of local master browser ...\n"); errno = EINVAL; return -1; - } /* @@ -1637,11 +1634,8 @@ int smbc_opendir(const char *fname) /*cli_get_backup_server(my_netbios_name, server, buserver, sizeof(buserver)); */ if (!name_status_find(0, rem_ip, buserver)) { - - fprintf(stderr, "Could not get name of local master browser ...\n"); errno = EPERM; /* FIXME, is this correct */ return -1; - } /* |