51 "MICROSOFT NETWORKS 1.03",
52 "MICROSOFT NETWORKS 3.0",
73 signal(SIGPIPE, SIG_IGN);
76#ifdef SMBLIB_INSTRUMENT
78 SMBlib_Instrument_Init();
102 const char *
server,
const char *NTdomain)
106 char called[80], calling[80], *address;
113 if (Con_Handle ==
NULL) {
125 strcpy(con -> service,
"");
126 strcpy(con -> username,
"");
127 strcpy(con -> password,
"");
128 strcpy(con -> sock_options,
"");
129 strcpy(con -> address,
"");
132 strncpy(con -> PDomain, NTdomain,
sizeof(con->
PDomain));
136 con -> first_tree = con -> last_tree =
NULL;
144 con ->
pid = getpid();
145 con -> mid = con ->
pid;
147 con -> gid = getgid();
152 for (i=0; i < strlen(con -> desthost); i++)
153 called[i] =
xtoupper(con -> desthost[i]);
155 called[strlen(con -> desthost)] = 0;
157 for (i=0; i < strlen(con -> myname); i++)
158 calling[i] =
xtoupper(con -> myname[i]);
160 calling[strlen(con -> myname)] = 0;
162 if (strlen(con -> address) == 0)
163 address = con -> desthost;
165 address = con -> address;
174 if (con -> Trans_Connect ==
NULL) {
176 if (Con_Handle ==
NULL) {
205 char *host, *address;
206 char temp[80], called[80], calling[80];
213 if (Con_Handle ==
NULL) {
225 strncpy(con -> service, service,
sizeof(con -> service));
226 con -> service[
sizeof(con -> service) - 1] =
'\0';
227 strncpy(con -> username, username,
sizeof(con -> username));
228 con -> username[
sizeof(con -> username) - 1] =
'\0';
229 strncpy(con -> password, password,
sizeof(con -> password));
230 con -> password[
sizeof(con -> password) - 1] =
'\0';
231 strcpy(con -> sock_options,
"");
232 strcpy(con -> address,
"");
236 con -> first_tree = con -> last_tree =
NULL;
244 con ->
pid = getpid();
245 con -> mid = con ->
pid;
247 con -> gid = getgid();
251 strncpy(temp, service,
sizeof(temp));
252 temp[
sizeof(temp) - 1] =
'\0';
253 host = strtok(temp,
"/\\");
255 if (Con_Handle ==
NULL) {
268 for (i=0; i < strlen(con -> desthost); i++)
269 called[i] =
xtoupper(con -> desthost[i]);
271 called[strlen(con -> desthost)] = 0;
273 for (i=0; i < strlen(con -> myname); i++)
274 calling[i] =
xtoupper(con -> myname[i]);
276 calling[strlen(con -> myname)] = 0;
278 if (strlen(con -> address) == 0)
279 address = con -> desthost;
281 address = con -> address;
290 if (con -> Trans_Connect ==
NULL) {
292 if (Con_Handle ==
NULL) {
305 if (Con_Handle ==
NULL) {
317 if (Con_Handle ==
NULL) {
333 char *PassWord,
const char *NtDomain,
int PreCrypted)
337 int param_len, pkt_len, pass_len;
353 memcpy(pword, PassWord, 24);
355 strncpy(pword, PassWord,
sizeof(pword));
356 pword[
sizeof(pword) - 1] =
'\0';
357#ifdef PAM_SMB_ENC_PASS
363 pass_len = strlen(pword);
368 if (Con_Handle -> protocol <
SMB_P_NT1) {
372 param_len = strlen(UserName) + 1 + pass_len + 1 +
373 (NtDomain!=
NULL ? strlen(NtDomain) : strlen(Con_Handle->
PDomain)) + 1 +
374 strlen(Con_Handle -> OSName) + 1;
412 memcpy(p, pword, pass_len);
414 p = p + pass_len + 1;
417 p = p + strlen(UserName);
422 if (NtDomain ==
NULL) {
423 strcpy(p, Con_Handle -> PDomain);
424 p = p + strlen(Con_Handle -> PDomain);
427 p = p + strlen(NtDomain);
432 strcpy(p, Con_Handle -> OSName);
433 p = p + strlen(Con_Handle -> OSName);
440 param_len = strlen(UserName) + 1 + pass_len +
441 strlen(Con_Handle -> PDomain) + 1 +
442 strlen(Con_Handle -> OSName) + 1 +
443 strlen(Con_Handle -> LMType) + 1;
483 memcpy(p, pword, pass_len);
488 p = p + strlen(UserName);
493 strcpy(p, Con_Handle -> PDomain);
494 p = p + strlen(Con_Handle -> PDomain);
498 strcpy(p, Con_Handle -> OSName);
499 p = p + strlen(Con_Handle -> OSName);
503 strcpy(p, Con_Handle -> LMType);
504 p = p + strlen(Con_Handle -> LMType);
511 if (
RFCNB_Send(Con_Handle -> Trans_Connect, pkt, pkt_len) < 0) {
514 fprintf(stderr,
"Error sending SessSetupX request\n");
525 if (
RFCNB_Recv(Con_Handle -> Trans_Connect, pkt, pkt_len) < 0) {
528 fprintf(stderr,
"Error receiving response to SessSetupAndX\n");
542 fprintf(stderr,
"SMB_SessSetupAndX failed with errorclass = %i, Error Code = %i\n",
562 fprintf(stderr,
"SessSetupAndX response. Action = %i\n",
static char server[MAXLINE]
#define SIVAL(buf, pos, val)
#define SSVAL(buf, pos, val)
struct RFCNB_Pkt * RFCNB_Alloc_Pkt(int n)
void RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt)
void * RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, int port)
int RFCNB_Send(struct RFCNB_Con *Con_Handle, struct RFCNB_Pkt *udata, int Length)
int RFCNB_Hangup(struct RFCNB_Con *con_Handle)
int RFCNB_Recv(void *Con_Handle, struct RFCNB_Pkt *Data, int Length)
void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24)
#define SMBlibE_SendFailed
#define SMBlibE_CallFailed
#define SMBlibE_NegNoProt
#define SMBlibE_RecvFailed
#define SMB_ssetpNTLM_mmc_offset
#define SMB_hdr_axc_offset
#define SMB_ssetpNTLM_res_offset
#define SMB_ssetpLM_bcc_offset
#define SMB_ssetpr_act_offset
#define SMB_hdr_rcls_offset
#define SMB_hdr_wct_offset
#define SMB_ssetpNTLM_cap_offset
#define SMB_ssetpNTLM_mbs_offset
#define SMBLIB_DEFAULT_OSNAME
#define SMBLIB_DEFAULT_DOMAIN
#define SMB_ssetpNTLM_snk_offset
#define SMB_ssetpLM_pwl_offset
#define SMB_ssetpNTLM_cipl_offset
#define SMB_hdr_err_offset
#define SMB_hdr_axo_offset
void SMB_Get_My_Name(char *name, int len)
#define SMBLIB_DEFAULT_LMTYPE
#define SMB_ssetpNTLM_cspl_offset
#define SMB_hdr_mid_offset
#define SMB_ssetpLM_mbs_offset
#define SMB_hdr_idf_offset
#define SMB_ssetpLM_buf_offset
#define SMB_hdr_uid_offset
#define SMB_ssetpNTLM_len
#define SMB_ssetpNTLM_vcn_offset
#define SMB_hdr_pid_offset
#define SMB_ssetpLM_res_offset
#define SMB_ssetpNTLM_buf_offset
#define SMB_ssetpLM_mmc_offset
#define SMB_hdr_tid_offset
#define SMB_ssetpNTLM_bcc_offset
#define SMB_hdr_com_offset
#define SMB_ssetpLM_snk_offset
#define SMB_ssetpLM_vcn_offset
SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type Con_Handle, SMB_Tree_Handle Tree_Handle, const char *path, const char *password, const char *device)
int SMB_Negotiate(SMB_Handle_Type Con_Handle, const char *Prots[])
int SMB_Discon(SMB_Handle_Type Con_Handle, BOOL KeepHandle)
int SMB_Logon_Server(SMB_Handle_Type Con_Handle, char *UserName, char *PassWord, const char *NtDomain, int PreCrypted)
const char * SMB_Prots_Restrict[]
SMB_State_Types SMBlib_State
SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle, const char *server, const char *NTdomain)
SMB_Handle_Type SMB_Connect(SMB_Handle_Type Con_Handle, SMB_Tree_Handle *tree, char *service, char *username, char *password)
SMB_Handle_Type SMB_Create_Con_Handle()