Unix SMB/Netbios implementation.
Version 1.9.
SMB client
- Copyright (C) Andrew Tridgell 1994-1997
+ Copyright (C) Andrew Tridgell 1994-1998
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
extern pstring workgroup;
char *cmdstr="";
extern BOOL got_pass;
+extern BOOL no_pass;
extern BOOL connect_as_printer;
extern BOOL connect_as_ipc;
extern struct in_addr ipzero;
#define USENMB
-extern int coding_system;
-static BOOL setup_term_code (char *code)
+static BOOL setup_term_code(char *code)
{
- int new;
- new = interpret_coding_system (code, UNKNOWN_CODE);
- if (new != UNKNOWN_CODE) {
- coding_system = new;
+ interpret_coding_system(code);
return True;
- }
- return False;
}
#define CNV_LANG(s) dos2unix_format(s,False)
#define CNV_INPUT(s) unix2dos_format(s,True)
SIVALS(outbuf,smb_vwv1, -1);
send_smb(clnt_fd, outbuf);
- receive_smb(clnt_fd,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(clnt_fd,inbuf,CLIENT_TIMEOUT);
}
/****************************************************************************
#endif
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (report && CVAL(inbuf,smb_rcls) != 0)
DEBUG(2,("chkpath: %s\n",smb_errstr(inbuf)));
send_smb(Client,outbuf);
- if (!receive_smb(Client,inbuf,SHORT_TIMEOUT) || CVAL(inbuf,smb_rcls) != 0)
+ if (!client_receive_smb(Client,inbuf,SHORT_TIMEOUT) || CVAL(inbuf,smb_rcls) != 0)
{
printf("SMBsendstrt failed. (%s)\n",smb_errstr(inbuf));
return;
send_smb(Client,outbuf);
- if (!receive_smb(Client,inbuf,SHORT_TIMEOUT) || CVAL(inbuf,smb_rcls) != 0)
+ if (!client_receive_smb(Client,inbuf,SHORT_TIMEOUT) || CVAL(inbuf,smb_rcls) != 0)
{
printf("SMBsendtxt failed (%s)\n",smb_errstr(inbuf));
return;
send_smb(Client,outbuf);
- if (!receive_smb(Client,inbuf,SHORT_TIMEOUT) || CVAL(inbuf,smb_rcls) != 0)
+ if (!client_receive_smb(Client,inbuf,SHORT_TIMEOUT) || CVAL(inbuf,smb_rcls) != 0)
{
printf("SMBsendend failed (%s)\n",smb_errstr(inbuf));
return;
cli_setup_pkt(outbuf);
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
DEBUG(0,("Error in dskattr: %s\n",smb_errstr(inbuf)));
}
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
received = SVAL(inbuf,smb_vwv0);
memcpy(p,status,21);
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
DEBUG(0,("Error closing search: %s\n",smb_errstr(inbuf)));
}
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
{
}
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
{
SSVAL(outbuf,smb_vwv4,finfo.size - nread);
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
{
*p++ = 4;
*p = 0;
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
}
{
strcpy(p,name);
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
{
send_smb(Client,outbuf);
- if (!receive_smb(Client,inbuf,CLIENT_TIMEOUT) || CVAL(inbuf,smb_rcls) != 0)
+ if (!client_receive_smb(Client,inbuf,CLIENT_TIMEOUT) || CVAL(inbuf,smb_rcls) != 0)
return(0);
_smb_setlen(buf-4,n); /* HACK! XXXX */
if (write_socket(Client,buf-4,n+4) != n+4)
return(0);
- if (!receive_smb(Client,inbuf,CLIENT_TIMEOUT) || CVAL(inbuf,smb_rcls) != 0) {
+ if (!client_receive_smb(Client,inbuf,CLIENT_TIMEOUT) || CVAL(inbuf,smb_rcls) != 0) {
DEBUG(0,("Error writing remote file (2)\n"));
return(0);
}
memcpy(smb_buf(outbuf)+3,buf,n);
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0) {
DEBUG(0,("%s writing remote file\n",smb_errstr(inbuf)));
strcpy(p,rname);
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
{
put_dos_date3(outbuf,smb_vwv1,close_time);
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
{
}
-/****************************************************************************
- get info on a file
- ****************************************************************************/
-static void cmd_stat(char *inbuf,char *outbuf)
-{
- fstring buf;
- pstring param;
- char *resp_data=NULL;
- char *resp_param=NULL;
- int resp_data_len = 0;
- int resp_param_len=0;
- char *p;
- uint16 setup = TRANSACT2_QPATHINFO;
-
- if (!next_token(NULL,buf,NULL)) {
- printf("stat <file>\n");
- return;
- }
-
- bzero(param,6);
- SSVAL(param,0,4); /* level */
- p = param+6;
- strcpy(p,cur_dir);
- strcat(p,buf);
-
- cli_send_trans_request(outbuf,SMBtrans2,NULL,0,FID_UNUSED,0,
- NULL,param,&setup,
- 0,6 + strlen(p)+1,1,
- BUFFER_SIZE,2,0);
-
- cli_receive_trans_response(inbuf,SMBtrans2,
- &resp_data_len,&resp_param_len,
- &resp_data,&resp_param);
-
- if (resp_data) free(resp_data); resp_data = NULL;
- if (resp_param) free(resp_param); resp_param = NULL;
-}
/****************************************************************************
strcpy(p,rname);
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
{
SSVAL(smb_buf(outbuf),1,n);
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
{
SSVAL(outbuf,smb_vwv0,fnum);
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
{
SSVAL(outbuf,smb_vwv1,0); /* the index into the queue */
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
{
p = skip_string(p,1);
DEBUG(1,("Calling DosPrintJobEnum()...\n"));
- if( cli_call_api(PIPE_LANMAN, 0,PTR_DIFF(p,param), 0,
- 10, 0, 4096,
+ if( cli_call_api(PIPE_LANMAN, 0,PTR_DIFF(p,param), 0, 0,
+ 10, 4096,
&rprcnt, &rdrcnt,
param, NULL, NULL,
&rparam, &rdata) )
strcpy(p,mask);
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
DEBUG(0,("%s deleting remote file %s\n",smb_errstr(inbuf),CNV_LANG(mask)));
strcpy(p,mask);
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
{
strcpy(p,dest);
send_smb(Client,outbuf);
- receive_smb(Client,inbuf,CLIENT_TIMEOUT);
+ client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
if (CVAL(inbuf,smb_rcls) != 0)
{
{"queue",cmd_queue,"show the print queue"},
{"qinfo",cmd_qinfo,"show print queue information"},
{"cancel",cmd_cancel,"<jobid> cancel a print queue entry"},
- {"stat",cmd_stat,"<file> get info on a file (experimental!)"},
{"quit",cli_send_logout,"logoff the server"},
{"q",cli_send_logout,"logoff the server"},
{"exit",cli_send_logout,"logoff the server"},
cmd = i;
break;
}
- else if (strnequal(commands[i].name, tok, tok_len+1))
+ else if (strnequal(commands[i].name, tok, tok_len))
{
matches++;
cmd = i;
}
}
#endif
+
+ /* We deliberately use receive_smb instead of
+ client_receive_smb as we want to receive
+ session keepalives and then drop them here.
+ */
if (FD_ISSET(Client,&fds))
receive_smb(Client,buffer,0);
bzero(OutBuffer,smb_size);
- if (!cli_send_login(InBuffer,OutBuffer,True,True))
+ if (!cli_send_login(InBuffer,OutBuffer,True,True,NULL))
return(False);
if (*base_directory) do_cd(base_directory);
pname));
DEBUG(0,("\nVersion %s\n",VERSION));
- DEBUG(0,("\t-p port listen on the specified port\n"));
+ DEBUG(0,("\t-p port connect to the specified port\n"));
DEBUG(0,("\t-d debuglevel set the debuglevel\n"));
DEBUG(0,("\t-l log basename. Basename for log/debug files\n"));
DEBUG(0,("\t-n netbios name. Use this name as my netbios name\n"));
break;
case 'N':
got_pass = True;
+ no_pass = True;
break;
case 'P':
connect_as_printer = True;
return(1);
bzero(OutBuffer,smb_size);
- if (!cli_send_login(InBuffer,OutBuffer,True,True))
+ if (!cli_send_login(InBuffer,OutBuffer,True,True,NULL))
return(False);
if (*base_directory) do_cd(base_directory);
#if 0
*username = 0;
#endif
- if (!cli_send_login(NULL,NULL,True,True))
+ if (!cli_send_login(NULL,NULL,True,True,NULL))
return(1);
server_info();
if (cli_open_sockets(port))
{
- if (!cli_send_login(NULL,NULL,True,True)) return(1);
+ if (!cli_send_login(NULL,NULL,True,True,NULL)) return(1);
do_nt_login(desthost, myhostname, Client, cnum);