~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to helpers/ntlm_auth/SMB/smbval/smblib.c

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2009-09-24 14:51:06 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (20.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090924145106-38jgrzmj0d73pha5
Tags: 3.1.0.13-1
* Upload to experimental

* New upstream release
  - Fixes Follow-X-Forwarded-For support (Closes: #523943)
  - Adds IPv6 support (Closes: #432351)

* debian/rules
  - Removed obsolete configuration options
  - Enable db and radius basic authentication modules

* debian/patches/01-cf.data.debian
  - Adapted to new upstream version

* debian/patches/02-makefile-defaults
  - Adapted to new upstream version

* debian/{squid.postinst,squid.rc,README.Debian,watch}
  - Updated references to squid 3.1

* debian/squid3.install
  - Install CSS file for error pages
  - Install manual pages for new authentication modules

* debian/squid3-common.install
  - Install documented version of configuration file in /usr/share/doc/squid3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
/* UNIX SMBlib NetBIOS implementation
3
 
 * 
4
 
 * Version 1.0
5
 
 * SMBlib Routines
6
 
 * 
7
 
 * Copyright (C) Richard Sharpe 1996
8
 
 * 
9
 
 */
10
 
 
11
 
/*
12
 
 * This program is free software; you can redistribute it and/or modify
13
 
 * it under the terms of the GNU General Public License as published by
14
 
 * the Free Software Foundation; either version 2 of the License, or
15
 
 * (at your option) any later version.
16
 
 * 
17
 
 * This program is distributed in the hope that it will be useful,
18
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 
 * GNU General Public License for more details.
21
 
 * 
22
 
 * You should have received a copy of the GNU General Public License
23
 
 * along with this program; if not, write to the Free Software
24
 
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
 
 */
26
 
 
27
 
#include "config.h"
28
 
#include <stdlib.h>
29
 
#include <ctype.h>
30
 
#include <string.h>
31
 
 
32
 
int SMBlib_errno;
33
 
int SMBlib_SMB_Error;
34
 
#define SMBLIB_ERRNO
35
 
#define uchar unsigned char
36
 
#include "smblib-priv.h"
37
 
 
38
 
#include "rfcnb.h"
39
 
#include "smbencrypt.h"
40
 
 
41
 
#include <signal.h>
42
 
 
43
 
/* #define DEBUG */
44
 
 
45
 
SMB_State_Types SMBlib_State;
46
 
 
47
 
/* Initialize the SMBlib package     */
48
 
 
49
 
int
50
 
SMB_Init()
51
 
{
52
 
 
53
 
    SMBlib_State = SMB_State_Started;
54
 
 
55
 
    signal(SIGPIPE, SIG_IGN);   /* Ignore these ... */
56
 
 
57
 
/* If SMBLIB_Instrument is defines, turn on the instrumentation stuff */
58
 
#ifdef SMBLIB_INSTRUMENT
59
 
 
60
 
    SMBlib_Instrument_Init();
61
 
 
62
 
#endif
63
 
 
64
 
    return 0;
65
 
 
66
 
}
67
 
 
68
 
int
69
 
SMB_Term()
70
 
{
71
 
 
72
 
#ifdef SMBLIB_INSTRUMENT
73
 
 
74
 
    SMBlib_Instrument_Term();   /* Clean up and print results */
75
 
 
76
 
#endif
77
 
 
78
 
    return 0;
79
 
 
80
 
}
81
 
 
82
 
/* SMB_Create: Create a connection structure and return for later use */
83
 
/* We have other helper routines to set variables                     */
84
 
 
85
 
SMB_Handle_Type
86
 
SMB_Create_Con_Handle()
87
 
{
88
 
 
89
 
    SMBlib_errno = SMBlibE_NotImpl;
90
 
    return (NULL);
91
 
 
92
 
}
93
 
 
94
 
int
95
 
SMBlib_Set_Sock_NoDelay(SMB_Handle_Type Con_Handle, BOOL yn)
96
 
{
97
 
 
98
 
 
99
 
    if (RFCNB_Set_Sock_NoDelay(Con_Handle->Trans_Connect, yn) < 0) {
100
 
 
101
 
#ifdef DEBUG
102
 
#endif
103
 
 
104
 
        fprintf(stderr, "Setting no-delay on TCP socket failed ...\n");
105
 
 
106
 
    }
107
 
    return (0);
108
 
 
109
 
}
110
 
 
111
 
/* SMB_Connect_Server: Connect to a server, but don't negotiate protocol */
112
 
/* or anything else ...                                                  */
113
 
 
114
 
SMB_Handle_Type
115
 
SMB_Connect_Server(SMB_Handle_Type Con_Handle,
116
 
    char *server, char *NTdomain)
117
 
{
118
 
    SMB_Handle_Type con;
119
 
    char called[80], calling[80], *address;
120
 
    int i;
121
 
 
122
 
    /* Get a connection structure if one does not exist */
123
 
 
124
 
    con = Con_Handle;
125
 
 
126
 
    if (Con_Handle == NULL) {
127
 
 
128
 
        if ((con = (struct SMB_Connect_Def *) malloc(sizeof(struct SMB_Connect_Def))) == NULL) {
129
 
 
130
 
 
131
 
            SMBlib_errno = SMBlibE_NoSpace;
132
 
            return NULL;
133
 
        }
134
 
    }
135
 
    /* Init some things ... */
136
 
 
137
 
    strcpy(con->service, "");
138
 
    strcpy(con->username, "");
139
 
    strcpy(con->password, "");
140
 
    strcpy(con->sock_options, "");
141
 
    strcpy(con->address, "");
142
 
    strcpy(con->desthost, server);
143
 
    strcpy(con->PDomain, NTdomain);
144
 
    strcpy(con->OSName, SMBLIB_DEFAULT_OSNAME);
145
 
    strcpy(con->LMType, SMBLIB_DEFAULT_LMTYPE);
146
 
    con->first_tree = con->last_tree = NULL;
147
 
 
148
 
    /* ugh. This is horribly broken. */
149
 
/*   SMB_Get_My_Name(con -> myname, sizeof(con -> myname)); */
150
 
    /* hacked by Kinkie */
151
 
    i = gethostname(con->myname, sizeof(con->myname));
152
 
    if (i == -1) {
153
 
        strcpy(con->myname, "unknown");
154
 
    } else {
155
 
        if (NULL != (address = strchr(con->myname, '.'))) {
156
 
            *address = '\0';    /* truncate at first '.' */
157
 
        }
158
 
    }
159
 
 
160
 
 
161
 
    con->port = 0;              /* No port selected */
162
 
 
163
 
    /* Get some things we need for the SMB Header */
164
 
 
165
 
    con->pid = getpid();
166
 
    con->mid = con->pid;        /* This will do for now ... */
167
 
    con->uid = 0;               /* Until we have done a logon, no uid ... */
168
 
    con->gid = getgid();
169
 
 
170
 
    /* Now connect to the remote end, but first upper case the name of the
171
 
     * service we are going to call, sine some servers want it in uppercase */
172
 
 
173
 
    for (i = 0; i < strlen(server); i++)
174
 
        called[i] = xtoupper(server[i]);
175
 
 
176
 
    called[strlen(server)] = 0; /* Make it a string */
177
 
 
178
 
    for (i = 0; i < strlen(con->myname); i++)
179
 
        calling[i] = xtoupper(con->myname[i]);
180
 
 
181
 
    calling[strlen(con->myname)] = 0;   /* Make it a string */
182
 
 
183
 
    if (strcmp(con->address, "") == 0)
184
 
        address = con->desthost;
185
 
    else
186
 
        address = con->address;
187
 
 
188
 
    con->Trans_Connect = RFCNB_Call(called,
189
 
        calling,
190
 
        address,                /* Protocol specific */
191
 
        con->port);
192
 
 
193
 
    /* Did we get one? */
194
 
 
195
 
    if (con->Trans_Connect == NULL) {
196
 
 
197
 
        if (Con_Handle == NULL) {
198
 
            Con_Handle = NULL;
199
 
            free(con);
200
 
        }
201
 
        SMBlib_errno = -SMBlibE_CallFailed;
202
 
        return NULL;
203
 
 
204
 
    }
205
 
    return (con);
206
 
 
207
 
}
208
 
 
209
 
/* SMB_Connect: Connect to the indicated server                       */
210
 
/* If Con_Handle == NULL then create a handle and connect, otherwise  */
211
 
/* use the handle passed                                              */
212
 
 
213
 
char *SMB_Prots_Restrict[] =
214
 
{"PC NETWORK PROGRAM 1.0",
215
 
    NULL};
216
 
 
217
 
 
218
 
SMB_Handle_Type
219
 
SMB_Connect(SMB_Handle_Type Con_Handle,
220
 
    SMB_Tree_Handle * tree,
221
 
    char *service,
222
 
    char *username,
223
 
    char *password)
224
 
{
225
 
    SMB_Handle_Type con;
226
 
    char *host, *address;
227
 
    char temp[80], called[80], calling[80];
228
 
    int i;
229
 
 
230
 
    /* Get a connection structure if one does not exist */
231
 
 
232
 
    con = Con_Handle;
233
 
 
234
 
    if (Con_Handle == NULL) {
235
 
 
236
 
        if ((con = (struct SMB_Connect_Def *) malloc(sizeof(struct SMB_Connect_Def))) == NULL) {
237
 
 
238
 
            SMBlib_errno = SMBlibE_NoSpace;
239
 
            return NULL;
240
 
        }
241
 
    }
242
 
    /* Init some things ... */
243
 
 
244
 
    strcpy(con->service, service);
245
 
    strcpy(con->username, username);
246
 
    strcpy(con->password, password);
247
 
    strcpy(con->sock_options, "");
248
 
    strcpy(con->address, "");
249
 
    strcpy(con->PDomain, SMBLIB_DEFAULT_DOMAIN);
250
 
    strcpy(con->OSName, SMBLIB_DEFAULT_OSNAME);
251
 
    strcpy(con->LMType, SMBLIB_DEFAULT_LMTYPE);
252
 
    con->first_tree = con->last_tree = NULL;
253
 
 
254
 
    SMB_Get_My_Name(con->myname, sizeof(con->myname));
255
 
 
256
 
    con->port = 0;              /* No port selected */
257
 
 
258
 
    /* Get some things we need for the SMB Header */
259
 
 
260
 
    con->pid = getpid();
261
 
    con->mid = con->pid;        /* This will do for now ... */
262
 
    con->uid = 0;               /* Until we have done a logon, no uid */
263
 
    con->gid = getgid();
264
 
 
265
 
    /* Now figure out the host portion of the service */
266
 
 
267
 
    strcpy(temp, service);
268
 
    host = (char *) strtok(temp, "/\\");        /* Separate host name portion */
269
 
    strcpy(con->desthost, host);
270
 
 
271
 
    /* Now connect to the remote end, but first upper case the name of the
272
 
     * service we are going to call, sine some servers want it in uppercase */
273
 
 
274
 
    for (i = 0; i < strlen(host); i++)
275
 
        called[i] = xtoupper(host[i]);
276
 
 
277
 
    called[strlen(host)] = 0;   /* Make it a string */
278
 
 
279
 
    for (i = 0; i < strlen(con->myname); i++)
280
 
        calling[i] = xtoupper(con->myname[i]);
281
 
 
282
 
    calling[strlen(con->myname)] = 0;   /* Make it a string */
283
 
 
284
 
    if (strcmp(con->address, "") == 0)
285
 
        address = con->desthost;
286
 
    else
287
 
        address = con->address;
288
 
 
289
 
    con->Trans_Connect = RFCNB_Call(called,
290
 
        calling,
291
 
        address,                /* Protocol specific */
292
 
        con->port);
293
 
 
294
 
    /* Did we get one? */
295
 
 
296
 
    if (con->Trans_Connect == NULL) {
297
 
 
298
 
        if (Con_Handle == NULL) {
299
 
            free(con);
300
 
            Con_Handle = NULL;
301
 
        }
302
 
        SMBlib_errno = -SMBlibE_CallFailed;
303
 
        return NULL;
304
 
 
305
 
    }
306
 
    /* Now, negotiate the protocol */
307
 
 
308
 
    if (SMB_Negotiate(con, SMB_Prots_Restrict) < 0) {
309
 
 
310
 
        /* Hmmm what should we do here ... We have a connection, but could not
311
 
         * negotiate ...                                                      */
312
 
 
313
 
        return NULL;
314
 
 
315
 
    }
316
 
    /* Now connect to the service ... */
317
 
 
318
 
    if ((*tree = SMB_TreeConnect(con, NULL, service, password, "A:")) == NULL) {
319
 
 
320
 
        return NULL;
321
 
 
322
 
    }
323
 
    return (con);
324
 
 
325
 
}
326
 
 
327
 
/* Logon to the server. That is, do a session setup if we can. We do not do */
328
 
/* Unicode yet!                                                             */
329
 
 
330
 
int
331
 
SMB_Logon_Server(SMB_Handle_Type Con_Handle, char *UserName,
332
 
    char *PassWord, char *UserDomain, int precrypted)
333
 
{
334
 
    struct RFCNB_Pkt *pkt;
335
 
    int param_len, pkt_len, pass_len;
336
 
    char *p, pword[128];
337
 
 
338
 
    /* First we need a packet etc ... but we need to know what protocol has  */
339
 
    /* been negotiated to figure out if we can do it and what SMB format to  */
340
 
    /* use ...                                                               */
341
 
 
342
 
    if (Con_Handle->protocol < SMB_P_LanMan1) {
343
 
 
344
 
        SMBlib_errno = SMBlibE_ProtLow;
345
 
        return (SMBlibE_BAD);
346
 
 
347
 
    }
348
 
    if (precrypted) {
349
 
        pass_len = 24;
350
 
        memcpy(pword, PassWord, 24);
351
 
    } else {
352
 
        strcpy(pword, PassWord);
353
 
        if (Con_Handle->encrypt_passwords) {
354
 
            pass_len = 24;
355
 
            SMBencrypt((uchar *) PassWord, (uchar *) Con_Handle->Encrypt_Key, (uchar *) pword);
356
 
        } else
357
 
            pass_len = strlen(pword);
358
 
    }
359
 
 
360
 
    /* Now build the correct structure */
361
 
 
362
 
    if (Con_Handle->protocol < SMB_P_NT1) {
363
 
 
364
 
        param_len = strlen(UserName) + 1 + pass_len + 1 +
365
 
            strlen(UserDomain) + 1 +
366
 
            strlen(Con_Handle->OSName) + 1;
367
 
 
368
 
        pkt_len = SMB_ssetpLM_len + param_len;
369
 
 
370
 
        pkt = (struct RFCNB_Pkt *) RFCNB_Alloc_Pkt(pkt_len);
371
 
 
372
 
        if (pkt == NULL) {
373
 
 
374
 
            SMBlib_errno = SMBlibE_NoSpace;
375
 
            fprintf(stderr, "SMB_Logon_server: Couldn't allocate packet\n");
376
 
            return (SMBlibE_BAD);       /* Should handle the error */
377
 
        }
378
 
        memset(SMB_Hdr(pkt), 0, SMB_ssetpLM_len);
379
 
        SIVAL(SMB_Hdr(pkt), SMB_hdr_idf_offset, SMB_DEF_IDF);   /* Plunk in IDF */
380
 
        *(SMB_Hdr(pkt) + SMB_hdr_com_offset) = SMBsesssetupX;
381
 
        SSVAL(SMB_Hdr(pkt), SMB_hdr_pid_offset, Con_Handle->pid);
382
 
        SSVAL(SMB_Hdr(pkt), SMB_hdr_tid_offset, 0);
383
 
        SSVAL(SMB_Hdr(pkt), SMB_hdr_mid_offset, Con_Handle->mid);
384
 
        SSVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset, Con_Handle->uid);
385
 
        *(SMB_Hdr(pkt) + SMB_hdr_wct_offset) = 10;
386
 
        *(SMB_Hdr(pkt) + SMB_hdr_axc_offset) = 0xFF;    /* No extra command */
387
 
        SSVAL(SMB_Hdr(pkt), SMB_hdr_axo_offset, 0);
388
 
 
389
 
        SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_mbs_offset, SMBLIB_MAX_XMIT);
390
 
        SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_mmc_offset, 2);
391
 
        SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_vcn_offset, Con_Handle->pid);
392
 
        SIVAL(SMB_Hdr(pkt), SMB_ssetpLM_snk_offset, 0);
393
 
        SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_pwl_offset, pass_len + 1);
394
 
        SIVAL(SMB_Hdr(pkt), SMB_ssetpLM_res_offset, 0);
395
 
        SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_bcc_offset, param_len);
396
 
 
397
 
        /* Now copy the param strings in with the right stuff */
398
 
 
399
 
        p = (char *) (SMB_Hdr(pkt) + SMB_ssetpLM_buf_offset);
400
 
 
401
 
        /* Copy  in password, then the rest. Password has a null at end */
402
 
 
403
 
        memcpy(p, pword, pass_len);
404
 
 
405
 
        p = p + pass_len + 1;
406
 
 
407
 
        strcpy(p, UserName);
408
 
        p = p + strlen(UserName);
409
 
        *p = 0;
410
 
 
411
 
        p = p + 1;
412
 
 
413
 
        strcpy(p, UserDomain);
414
 
        p = p + strlen(UserDomain);
415
 
        *p = 0;
416
 
        p = p + 1;
417
 
 
418
 
        strcpy(p, Con_Handle->OSName);
419
 
        p = p + strlen(Con_Handle->OSName);
420
 
        *p = 0;
421
 
 
422
 
    } else {
423
 
 
424
 
        /* We don't admit to UNICODE support ... */
425
 
 
426
 
        param_len = strlen(UserName) + 1 + pass_len +
427
 
            strlen(UserDomain) + 1 +
428
 
            strlen(Con_Handle->OSName) + 1 +
429
 
            strlen(Con_Handle->LMType) + 1;
430
 
 
431
 
        pkt_len = SMB_ssetpNTLM_len + param_len;
432
 
 
433
 
        pkt = (struct RFCNB_Pkt *) RFCNB_Alloc_Pkt(pkt_len);
434
 
 
435
 
        if (pkt == NULL) {
436
 
 
437
 
            SMBlib_errno = SMBlibE_NoSpace;
438
 
            fprintf(stderr, "SMB_Logon_server: Couldn't allocate packet\n");
439
 
            return (-1);        /* Should handle the error */
440
 
        }
441
 
        memset(SMB_Hdr(pkt), 0, SMB_ssetpNTLM_len);
442
 
        SIVAL(SMB_Hdr(pkt), SMB_hdr_idf_offset, SMB_DEF_IDF);   /* Plunk in IDF */
443
 
        *(SMB_Hdr(pkt) + SMB_hdr_com_offset) = SMBsesssetupX;
444
 
        SSVAL(SMB_Hdr(pkt), SMB_hdr_pid_offset, Con_Handle->pid);
445
 
        SSVAL(SMB_Hdr(pkt), SMB_hdr_tid_offset, 0);
446
 
        SSVAL(SMB_Hdr(pkt), SMB_hdr_mid_offset, Con_Handle->mid);
447
 
        SSVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset, Con_Handle->uid);
448
 
        *(SMB_Hdr(pkt) + SMB_hdr_wct_offset) = 13;
449
 
        *(SMB_Hdr(pkt) + SMB_hdr_axc_offset) = 0xFF;    /* No extra command */
450
 
        SSVAL(SMB_Hdr(pkt), SMB_hdr_axo_offset, 0);
451
 
 
452
 
        SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_mbs_offset, SMBLIB_MAX_XMIT);
453
 
        SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_mmc_offset, 0);
454
 
        SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_vcn_offset, 1); /* Thanks Tridge! */
455
 
        SIVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_snk_offset, 0);
456
 
        SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_cipl_offset, pass_len);
457
 
        SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_cspl_offset, 0);
458
 
        SIVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_res_offset, 0);
459
 
        SIVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_cap_offset, 0);
460
 
        SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_bcc_offset, param_len);
461
 
 
462
 
        /* Now copy the param strings in with the right stuff */
463
 
 
464
 
        p = (char *) (SMB_Hdr(pkt) + SMB_ssetpNTLM_buf_offset);
465
 
 
466
 
        /* Copy  in password, then the rest. Password has no null at end */
467
 
 
468
 
        memcpy(p, pword, pass_len);
469
 
 
470
 
        p = p + pass_len;
471
 
 
472
 
        strcpy(p, UserName);
473
 
        p = p + strlen(UserName);
474
 
        *p = 0;
475
 
 
476
 
        p = p + 1;
477
 
 
478
 
        strcpy(p, UserDomain);
479
 
        p = p + strlen(UserDomain);
480
 
        *p = 0;
481
 
        p = p + 1;
482
 
 
483
 
        strcpy(p, Con_Handle->OSName);
484
 
        p = p + strlen(Con_Handle->OSName);
485
 
        *p = 0;
486
 
        p = p + 1;
487
 
 
488
 
        strcpy(p, Con_Handle->LMType);
489
 
        p = p + strlen(Con_Handle->LMType);
490
 
        *p = 0;
491
 
 
492
 
    }
493
 
 
494
 
    /* Now send it and get a response */
495
 
 
496
 
    if (RFCNB_Send(Con_Handle->Trans_Connect, pkt, pkt_len) < 0) {
497
 
 
498
 
#ifdef DEBUG
499
 
        fprintf(stderr, "Error sending SessSetupX request\n");
500
 
#endif
501
 
 
502
 
        RFCNB_Free_Pkt(pkt);
503
 
        SMBlib_errno = SMBlibE_SendFailed;
504
 
        return (SMBlibE_BAD);
505
 
 
506
 
    }
507
 
    /* Now get the response ... */
508
 
 
509
 
    if (RFCNB_Recv(Con_Handle->Trans_Connect, pkt, pkt_len) < 0) {
510
 
 
511
 
#ifdef DEBUG
512
 
        fprintf(stderr, "Error receiving response to SessSetupAndX\n");
513
 
#endif
514
 
 
515
 
        RFCNB_Free_Pkt(pkt);
516
 
        SMBlib_errno = SMBlibE_RecvFailed;
517
 
        return (SMBlibE_BAD);
518
 
 
519
 
    }
520
 
    /* Check out the response type ... */
521
 
 
522
 
    if (CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset) != SMBC_SUCCESS) {      /* Process error */
523
 
 
524
 
#ifdef DEBUG
525
 
        fprintf(stderr, "SMB_SessSetupAndX failed with errorclass = %i, Error Code = %i\n",
526
 
            CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset),
527
 
            SVAL(SMB_Hdr(pkt), SMB_hdr_err_offset));
528
 
#endif
529
 
 
530
 
        SMBlib_SMB_Error = IVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset);
531
 
        RFCNB_Free_Pkt(pkt);
532
 
        SMBlib_errno = SMBlibE_Remote;
533
 
        return (SMBlibE_BAD);
534
 
 
535
 
    }
536
 
/** @@@ mdz: check for guest login { **/
537
 
    if (SVAL(SMB_Hdr(pkt), SMB_ssetpr_act_offset) & 0x1) {
538
 
        /* do we allow guest login? NO! */
539
 
        return (SMBlibE_BAD);
540
 
 
541
 
    }
542
 
/** @@@ mdz: } **/
543
 
 
544
 
 
545
 
#ifdef DEBUG
546
 
    fprintf(stderr, "SessSetupAndX response. Action = %i\n",
547
 
        SVAL(SMB_Hdr(pkt), SMB_ssetpr_act_offset));
548
 
#endif
549
 
 
550
 
    /* Now pick up the UID for future reference ... */
551
 
 
552
 
    Con_Handle->uid = SVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset);
553
 
    RFCNB_Free_Pkt(pkt);
554
 
 
555
 
    return (0);
556
 
 
557
 
}
558
 
 
559
 
 
560
 
/* Disconnect from the server, and disconnect all tree connects */
561
 
 
562
 
int
563
 
SMB_Discon(SMB_Handle_Type Con_Handle, BOOL KeepHandle)
564
 
{
565
 
 
566
 
    /* We just disconnect the connection for now ... */
567
 
    if (Con_Handle != NULL)
568
 
        RFCNB_Hangup(Con_Handle->Trans_Connect);
569
 
 
570
 
    if (!KeepHandle)
571
 
        free(Con_Handle);
572
 
 
573
 
    return (0);
574
 
 
575
 
}