diff options
author | cvs2svn Import User <samba-bugs@samba.org> | 1997-10-21 16:43:44 +0000 |
---|---|---|
committer | cvs2svn Import User <samba-bugs@samba.org> | 1997-10-21 16:43:44 +0000 |
commit | 46a05ffe430b3db815d567f09b0f293b2a9bd269 (patch) | |
tree | 1a63a7ef14f516dbdc1bbbc0ff2cedf1a0070bd1 /source/client | |
parent | 332f78bbc945c327069e9c9e29c7137c8cbd5c02 (diff) | |
parent | 460186a1b4de8ddeebe9d37faafd9b5b321ee493 (diff) | |
download | samba-1.9.17p4.tar.gz samba-1.9.17p4.tar.xz samba-1.9.17p4.zip |
This commit was manufactured by cvs2svn to create tagsamba-1.9.17p4
'release-1-9-17p4'.
Diffstat (limited to 'source/client')
-rw-r--r-- | source/client/client.c | 86 | ||||
-rw-r--r-- | source/client/clientutil.c | 71 | ||||
-rw-r--r-- | source/client/clitar.c | 123 |
3 files changed, 129 insertions, 151 deletions
diff --git a/source/client/client.c b/source/client/client.c index 275d03ddba2..a48d1b4990b 100644 --- a/source/client/client.c +++ b/source/client/client.c @@ -143,8 +143,12 @@ extern int Client; #define USENMB +#ifdef KANJI extern int coding_system; -static BOOL setup_term_code (char *code) +#define CNV_LANG(s) (coding_system == DOSV_CODE?s:dos_to_unix(s, False)) +#define CNV_INPUT(s) (coding_system == DOSV_CODE?s:unix_to_dos(s, True)) +static BOOL +setup_term_code (char *code) { int new; new = interpret_coding_system (code, UNKNOWN_CODE); @@ -154,8 +158,10 @@ static BOOL setup_term_code (char *code) } return False; } +#else #define CNV_LANG(s) dos2unix_format(s,False) #define CNV_INPUT(s) unix2dos_format(s,True) +#endif /**************************************************************************** setup basics in a outgoing packet @@ -3303,11 +3309,15 @@ static BOOL send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setu int passlen = strlen(pass)+1; strcpy(pword,pass); +#ifdef SMB_PASSWD if (doencrypt && *pass) { DEBUG(3,("Using encrypted passwords\n")); passlen = 24; SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword); } +#else + doencrypt = False; +#endif /* if in share level security then don't send a password now */ if (!(sec_mode & 1)) {strcpy(pword, "");passlen=1;} @@ -3401,6 +3411,13 @@ static BOOL send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setu uid = SVAL(inbuf,smb_uid); } + if (SVAL(inbuf, smb_vwv2) & 1) + DEBUG(1,("connected as guest ")); + if (sec_mode & 1) + DEBUG(1,("security=user\n")); + else + DEBUG(1,("security=share\n")); + /* now we've got a connection - send a tcon message */ bzero(outbuf,smb_size); @@ -3418,10 +3435,12 @@ static BOOL send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setu fstring pword; strcpy(pword,pass); +#ifdef SMB_PASSWD if (doencrypt && *pass) { passlen=24; SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword); } +#endif /* if in user level security then don't send a password now */ if ((sec_mode & 1)) { @@ -3508,6 +3527,7 @@ static BOOL send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setu free(inbuf); free(outbuf); } + return True; } @@ -3681,6 +3701,7 @@ static BOOL send_trans_request(char *outbuf,int trans, return(True); } + /**************************************************************************** try and browse available connections on a host ****************************************************************************/ @@ -4106,7 +4127,7 @@ static BOOL open_sockets(int port ) strcpy(desthost,host); } - if (*myname == 0) { + if (!(*myname)) { get_myname(myname,NULL); } strupper(myname); @@ -4380,6 +4401,10 @@ static void usage(char *pname) DEBUG(0,("Usage: %s service <password> [-p port] [-d debuglevel] [-l log] ", pname)); +#ifdef KANJI + DEBUG(0,("[-t termcode] ")); +#endif /* KANJI */ + DEBUG(0,("\nVersion %s\n",VERSION)); DEBUG(0,("\t-p port listen on the specified port\n")); DEBUG(0,("\t-d debuglevel set the debuglevel\n")); @@ -4395,7 +4420,9 @@ static void usage(char *pname) DEBUG(0,("\t-U username set the network username\n")); DEBUG(0,("\t-W workgroup set the workgroup name\n")); DEBUG(0,("\t-c command string execute semicolon separated commands\n")); +#ifdef KANJI DEBUG(0,("\t-t terminal code terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n")); +#endif /* KANJI */ DEBUG(0,("\t-T<c|x>IXgbNa command line tar\n")); DEBUG(0,("\t-D directory start from directory\n")); DEBUG(0,("\n")); @@ -4417,14 +4444,6 @@ static void usage(char *pname) BOOL message = False; extern char tar_type; static pstring servicesf = CONFIGFILE; - pstring term_code; - char *p; - -#ifdef KANJI - strcpy(term_code, KANJI); -#else /* KANJI */ - *term_code = 0; -#endif /* KANJI */ *query_host = 0; *base_directory = 0; @@ -4444,27 +4463,10 @@ static void usage(char *pname) umask(myumask); if (getenv("USER")) - { - strcpy(username,getenv("USER")); - - /* modification to support userid%passwd syntax in the USER var - 25.Aug.97, jdblair@uab.edu */ - - if ((p=strchr(username,'%'))) { - *p = 0; - strcpy(password,p+1); - got_pass = True; - memset(strchr(getenv("USER"),'%')+1,'X',strlen(password)); + strcpy(username,getenv("USER")); + strupper(username); } - strupper(username); - } - - /* modification to support PASSWD environmental var - 25.Aug.97, jdblair@uab.edu */ - - if (getenv("PASSWD")) - strcpy(password,getenv("PASSWD")); if (*username == 0 && getenv("LOGNAME")) { @@ -4513,6 +4515,9 @@ static void usage(char *pname) } } +#ifdef KANJI + setup_term_code (KANJI); +#endif while ((opt = getopt(argc, argv,"s:B:O:M:i:Nn:d:Pp:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF) switch (opt) @@ -4608,7 +4613,13 @@ static void usage(char *pname) strcpy(servicesf, optarg); break; case 't': - strcpy(term_code, optarg); +#ifdef KANJI + if (!setup_term_code (optarg)) { + DEBUG(0, ("%s: unknown terminal code name\n", optarg)); + usage (pname); + exit (1); + } +#endif break; default: usage(pname); @@ -4633,23 +4644,11 @@ static void usage(char *pname) fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf); } - codepage_initialise(lp_client_code_page()); - - if(lp_client_code_page() == KANJI_CODEPAGE) - { - if (!setup_term_code (term_code)) - { - DEBUG(0, ("%s: unknown terminal code name\n", optarg)); - usage (pname); - exit (1); - } - } - if (*workgroup == 0) strcpy(workgroup,lp_workgroup()); load_interfaces(); - get_myname(*myname?NULL:myname,NULL); + get_myname((*myname)?NULL:myname,NULL); strupper(myname); if (tar_type) { @@ -4775,6 +4774,7 @@ err_code_struct dos_msgs[] = { {"ERRnofiles",18,"A File Search command can find no more files matching the specified criteria."}, {"ERRbadshare",32,"The sharing mode specified for an Open conflicts with existing FIDs on the file."}, {"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."}, + {"ERRnosuchshare", 67, "You specified an invalid share name"}, {"ERRfilexists",80,"The file named in a Create Directory, Make New File or Link request already exists."}, {"ERRbadpipe",230,"Pipe invalid."}, {"ERRpipebusy",231,"All instances of the requested pipe are busy."}, diff --git a/source/client/clientutil.c b/source/client/clientutil.c index d16e5a471fc..cb0a731480c 100644 --- a/source/client/clientutil.c +++ b/source/client/clientutil.c @@ -77,7 +77,7 @@ extern int Client; /**************************************************************************** setup basics in a outgoing packet ****************************************************************************/ -void cli_setup_pkt(char *outbuf) +static void cli_setup_pkt(char *outbuf) { SSVAL(outbuf,smb_pid,pid); SSVAL(outbuf,smb_uid,uid); @@ -89,11 +89,14 @@ void cli_setup_pkt(char *outbuf) } } + + /**************************************************************************** receive a SMB trans or trans2 response allocating the necessary memory ****************************************************************************/ -BOOL cli_receive_trans_response(char *inbuf,int trans,int *data_len, - int *param_len, char **data,char **param) +static BOOL cli_receive_trans_response(char *inbuf,int trans,int *data_len, + int *param_len, char **data, + char **param) { int total_data=0; int total_param=0; @@ -164,7 +167,7 @@ BOOL cli_receive_trans_response(char *inbuf,int trans,int *data_len, /**************************************************************************** send a session request ****************************************************************************/ -BOOL cli_send_session_request(char *inbuf, char *outbuf) +static BOOL cli_send_session_request(char *inbuf, char *outbuf) { fstring dest; char *p; @@ -441,11 +444,15 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu int passlen = strlen(pass)+1; fstrcpy(pword,pass); +#ifdef SMB_PASSWD if (doencrypt && *pass) { DEBUG(5,("Using encrypted passwords\n")); passlen = 24; SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword); } +#else + doencrypt = False; +#endif /* if in share level security then don't send a password now */ if (!(sec_mode & 1)) {fstrcpy(pword, "");passlen=1;} @@ -556,10 +563,12 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu fstring pword; fstrcpy(pword,pass); +#ifdef SMB_PASSWD if (doencrypt && *pass) { passlen=24; SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword); } +#endif /* if in user level security then don't send a password now */ if ((sec_mode & 1)) { @@ -655,35 +664,12 @@ void cli_send_logout(void) } - -/**************************************************************************** -call a remote api -****************************************************************************/ -BOOL cli_call_api(int prcnt,int drcnt,int mprcnt,int mdrcnt,int *rprcnt, - int *rdrcnt, char *param,char *data, char **rparam,char **rdata) -{ - static char *inbuf=NULL; - static char *outbuf=NULL; - - if (!inbuf) inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); - if (!outbuf) outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); - - cli_send_trans_request(outbuf,SMBtrans,"\\PIPE\\LANMAN",0,0, - data,param,NULL, - drcnt,prcnt,0, - mdrcnt,mprcnt,0); - - return (cli_receive_trans_response(inbuf,SMBtrans, - rdrcnt,rprcnt, - rdata,rparam)); -} - /**************************************************************************** send a SMB trans or trans2 request ****************************************************************************/ -BOOL cli_send_trans_request(char *outbuf, int trans, char *name, int fid, int flags, - char *data,char *param,uint16 *setup, int ldata,int lparam, - int lsetup,int mdata,int mparam,int msetup) +static BOOL cli_send_trans_request(char *outbuf, int trans, char *name, int fid, int flags, + char *data,char *param,uint16 *setup, int ldata,int lparam, + int lsetup,int mdata,int mparam,int msetup) { int i; int this_ldata,this_lparam; @@ -791,6 +777,31 @@ BOOL cli_send_trans_request(char *outbuf, int trans, char *name, int fid, int fl } + +/**************************************************************************** +call a remote api +****************************************************************************/ +BOOL cli_call_api(int prcnt,int drcnt,int mprcnt,int mdrcnt,int *rprcnt, + int *rdrcnt, char *param,char *data, + char **rparam, char **rdata) +{ + static char *inbuf=NULL; + static char *outbuf=NULL; + + if (!inbuf) inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); + if (!outbuf) outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); + + cli_send_trans_request(outbuf,SMBtrans,"\\PIPE\\LANMAN",0,0, + data,param,NULL, + drcnt,prcnt,0, + mdrcnt,mprcnt,0); + + return (cli_receive_trans_response(inbuf,SMBtrans, + rdrcnt,rprcnt, + rdata,rparam)); +} + + /**************************************************************************** open the client sockets ****************************************************************************/ diff --git a/source/client/clitar.c b/source/client/clitar.c index c085cd9e5a1..d5bca8c5bbb 100644 --- a/source/client/clitar.c +++ b/source/client/clitar.c @@ -90,7 +90,7 @@ static void unfixtarname(); Write a tar header to buffer ****************************************************************************/ static void writetarheader(int f, char *aname, int size, time_t mtime, - char *amode) + char *amode) { union hblock hb; int i, chk, l; @@ -99,21 +99,10 @@ static void writetarheader(int f, char *aname, int size, time_t mtime, memset(hb.dummy, 0, sizeof(hb.dummy)); l=strlen(aname); - if (l >= NAMSIZ) { - /* write a GNU tar style long header */ - char *b; - b = (char *)malloc(l+TBLOCK+100); - if (!b) { - DEBUG(0,("out of memory\n")); - exit(1); - } - writetarheader(f, "/./@LongLink", l+1, 0, " 0 \0"); - memset(b, 0, l+TBLOCK+100); - fixtarname(b, aname, l+1); - i = strlen(b)+1; - dotarbuf(f, b, TBLOCK*((i+(TBLOCK-1)/TBLOCK))); - free(b); - } + if (l >= NAMSIZ) + { + DEBUG(0, ("tar file %s name length exceeds NAMSIZ\n", aname)); + } /* use l + 1 to do the null too */ fixtarname(hb.dbuf.name, aname, (l >= NAMSIZ) ? NAMSIZ : l + 1); @@ -130,13 +119,8 @@ static void writetarheader(int f, char *aname, int size, time_t mtime, oct_it((long) size, 13, hb.dbuf.size); oct_it((long) mtime, 13, hb.dbuf.mtime); memcpy(hb.dbuf.chksum, " ", sizeof(hb.dbuf.chksum)); + hb.dbuf.linkflag='0'; memset(hb.dbuf.linkname, 0, NAMSIZ); - if (strcmp("/./@LongLink", aname) == 0) { - /* we're doing a GNU tar long filename */ - hb.dbuf.linkflag='L'; - } else { - hb.dbuf.linkflag='0'; - } for (chk=0, i=sizeof(hb.dummy), jp=hb.dummy; --i>=0;) chk+=(0xFF & *jp++); @@ -322,35 +306,27 @@ static void fixtarname(char *tptr, char *fp, int l) * to lovely unix /'s :-} */ *tptr++='.'; - if(lp_client_code_page() == KANJI_CODEPAGE) - { - while (l > 0) { - if (is_shift_jis (*fp)) { - *tptr++ = *fp++; - *tptr++ = *fp++; - l -= 2; - } else if (is_kana (*fp)) { - *tptr++ = *fp++; - l--; - } else if (*fp == '\\') { - *tptr++ = '/'; - fp++; - l--; - } else { - *tptr++ = *fp++; - l--; - } - } - } - else - { - while (l--) - { - *tptr=(*fp == '\\') ? '/' : *fp; - tptr++; +#ifdef KANJI + while (l > 0) { + if (is_shift_jis (*fp)) { + *tptr++ = *fp++; + *tptr++ = *fp++; + l -= 2; + } else if (is_kana (*fp)) { + *tptr++ = *fp++; + l--; + } else if (*fp == '\\') { + *tptr++ = '/'; fp++; + l--; + } else { + *tptr++ = *fp++; + l--; } } +#else + while (l--) { *tptr=(*fp == '\\') ? '/' : *fp; tptr++; fp++; } +#endif } /**************************************************************************** @@ -1074,7 +1050,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1) * write out in 512 byte intervals */ if (dotarbuf(tarhandle,dataptr,datalen) != datalen) { - DEBUG(0,("Error writing to tar file - %s\n", strerror(errno))); + DEBUG(0,("Error writing local file\n")); break; } @@ -1094,7 +1070,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1) { DEBUG(0, ("Didn't get entire file. size=%d, nread=%d\n", finfo.size, nread)); if (padit(inbuf, BUFFER_SIZE, finfo.size - nread)) - DEBUG(0,("Error writing tar file - %s\n", strerror(errno))); + DEBUG(0,("Error writing local file\n")); } /* round tar file to nearest block */ @@ -1227,35 +1203,27 @@ static void unfixtarname(char *tptr, char *fp, int l) if (*fp == '.') fp++; if (*fp == '\\' || *fp == '/') fp++; - if(lp_client_code_page() == KANJI_CODEPAGE) - { - while (l > 0) { - if (is_shift_jis (*fp)) { - *tptr++ = *fp++; - *tptr++ = *fp++; - l -= 2; - } else if (is_kana (*fp)) { - *tptr++ = *fp++; - l--; - } else if (*fp == '/') { - *tptr++ = '\\'; - fp++; - l--; - } else { - *tptr++ = *fp++; - l--; - } - } - } - else - { - while (l--) - { - *tptr=(*fp == '/') ? '\\' : *fp; - tptr++; +#ifdef KANJI + while (l > 0) { + if (is_shift_jis (*fp)) { + *tptr++ = *fp++; + *tptr++ = *fp++; + l -= 2; + } else if (is_kana (*fp)) { + *tptr++ = *fp++; + l--; + } else if (*fp == '/') { + *tptr++ = '\\'; fp++; + l--; + } else { + *tptr++ = *fp++; + l--; } } +#else + while (l--) { *tptr=(*fp == '/') ? '\\' : *fp; tptr++; fp++; } +#endif } static void do_tarput() @@ -1761,8 +1729,7 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind) if ((tar_type=='x' && (tarhandle = open(argv[Optind], O_RDONLY)) == -1) || (tar_type=='c' && (tarhandle=creat(argv[Optind], 0644)) < 0)) { - DEBUG(0,("Error opening local file %s - %s\n", - argv[Optind], strerror(errno))); + DEBUG(0,("Error opening local file %s\n",argv[Optind])); return(0); } } |