50 const char *
SMB_Prots[] = {
"PC NETWORK PROGRAM 1.0",
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",