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

« back to all changes in this revision

Viewing changes to helpers/ntlm_auth/smb_lm/smbval/valid.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
#include "config.h"
 
2
 
 
3
#if HAVE_SYS_TYPES_H
 
4
#include <sys/types.h>
 
5
#endif
 
6
#if HAVE_UNISTD_H
 
7
#include <unistd.h>
 
8
#endif
 
9
#if HAVE_SYSLOG_H
 
10
#include <syslog.h>
 
11
#endif
 
12
#if HAVE_STRING_H
 
13
#include <string.h>
 
14
#endif
 
15
 
 
16
#include "smblib-priv.h"
 
17
#include "valid.h"
 
18
 
 
19
SMB_Handle_Type SMB_Connect_Server(void *, char *, char *);
 
20
 
 
21
int
 
22
Valid_User(char *username, char *password, char *server, char *backup, char *domain)
 
23
{
 
24
    int pass_is_precrypted_p = 0;
 
25
    char const *SMB_Prots[] = {
 
26
        /*              "PC NETWORK PROGRAM 1.0", */
 
27
        /*              "MICROSOFT NETWORKS 1.03", */
 
28
        /*              "MICROSOFT NETWORKS 3.0", */
 
29
        "LANMAN1.0",
 
30
        "LM1.2X002",
 
31
        "Samba",
 
32
        /*              "NT LM 0.12", */
 
33
        /*              "NT LANMAN 1.0", */
 
34
        NULL
 
35
    };
 
36
    SMB_Handle_Type con;
 
37
 
 
38
    SMB_Init();
 
39
    con = SMB_Connect_Server(NULL, server, domain);
 
40
    if (con == NULL) {          /* Error ... */
 
41
        con = SMB_Connect_Server(NULL, backup, domain);
 
42
        if (con == NULL) {
 
43
            return (NTV_SERVER_ERROR);
 
44
        }
 
45
    }
 
46
    if (SMB_Negotiate(con, SMB_Prots) < 0) {    /* An error */
 
47
        SMB_Discon(con, 0);
 
48
        return (NTV_PROTOCOL_ERROR);
 
49
    }
 
50
    /* Test for a server in share level mode do not authenticate against it */
 
51
    if (con->Security == 0) {
 
52
        SMB_Discon(con, 0);
 
53
        return (NTV_PROTOCOL_ERROR);
 
54
    }
 
55
    if (SMB_Logon_Server(con, username, password, domain, pass_is_precrypted_p) < 0) {
 
56
        SMB_Discon(con, 0);
 
57
        return (NTV_LOGON_ERROR);
 
58
    }
 
59
    SMB_Discon(con, 0);
 
60
    return (NTV_NO_ERROR);
 
61
}
 
62
 
 
63
void *
 
64
NTLM_Connect(char *server, char *backup, char *domain, char *nonce)
 
65
{
 
66
    char const *SMB_Prots[] = {
 
67
        /*              "PC NETWORK PROGRAM 1.0", */
 
68
        /*              "MICROSOFT NETWORKS 1.03", */
 
69
        /*              "MICROSOFT NETWORKS 3.0", */
 
70
        "LANMAN1.0",
 
71
        "LM1.2X002",
 
72
        "Samba",
 
73
        /*              "NT LM 0.12", */
 
74
        /*              "NT LANMAN 1.0", */
 
75
        NULL
 
76
    };
 
77
    SMB_Handle_Type con;
 
78
 
 
79
    SMB_Init();
 
80
    con = SMB_Connect_Server(NULL, server, domain);
 
81
    if (con == NULL) {          /* Error ... */
 
82
        con = SMB_Connect_Server(NULL, backup, domain);
 
83
        if (con == NULL) {
 
84
            return (NULL);
 
85
        }
 
86
    }
 
87
    if (SMB_Negotiate(con, SMB_Prots) < 0) {    /* An error */
 
88
        SMB_Discon(con, 0);
 
89
        return (NULL);
 
90
    }
 
91
    /* Test for a server in share level mode do not authenticate against it */
 
92
    if (con->Security == 0) {
 
93
        SMB_Discon(con, 0);
 
94
        return (NULL);
 
95
    }
 
96
    memcpy(nonce, con->Encrypt_Key, 8);
 
97
 
 
98
    return (con);
 
99
}
 
100
 
 
101
int
 
102
NTLM_Auth(void *handle, char *username, char *password, int flag)
 
103
{
 
104
    SMB_Handle_Type con = handle;
 
105
 
 
106
    if (SMB_Logon_Server(con, username, password, NULL, flag) < 0) {
 
107
        return (NTV_LOGON_ERROR);
 
108
    }
 
109
    return (NTV_NO_ERROR);
 
110
}
 
111
 
 
112
void
 
113
NTLM_Disconnect(void *handle)
 
114
{
 
115
    SMB_Handle_Type con = handle;
 
116
    SMB_Discon(con, 0);
 
117
}