]> git.ipfire.org Git - thirdparty/squid.git/blob - src/auth/basic/SMB_LM/valid.cc
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / auth / basic / SMB_LM / valid.cc
1 /*
2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #include "squid.h"
10 #include "auth/basic/SMB_LM/valid.h"
11 #include "smblib/smblib.h"
12
13 #if HAVE_SYS_TYPES_H
14 #include <sys/types.h>
15 #endif
16 #if HAVE_UNISTD_H
17 #include <unistd.h>
18 #endif
19 #if HAVE_SYSLOG_H
20 #include <syslog.h>
21 #endif
22
23 // BACKUP is unused
24 int
25 Valid_User(char *USERNAME, char *PASSWORD, const char *SERVER, char *, const char *DOMAIN)
26 {
27 const char *supportedDialects[] = {"PC NETWORK PROGRAM 1.0",
28 "MICROSOFT NETWORKS 1.03",
29 "MICROSOFT NETWORKS 3.0",
30 "LANMAN1.0",
31 "LM1.2X002",
32 "Samba",
33 "NT LM 0.12",
34 "NT LANMAN 1.0",
35 NULL
36 };
37 SMB_Handle_Type con;
38
39 SMB_Init();
40 con = SMB_Connect_Server(NULL, SERVER, DOMAIN);
41 if (con == NULL) {
42 return (NTV_SERVER_ERROR);
43 }
44 if (SMB_Negotiate(con, supportedDialects) < 0) { /* An error */
45 SMB_Discon(con, 0);
46 return (NTV_PROTOCOL_ERROR);
47 }
48 if (SMB_Logon_Server(con, USERNAME, PASSWORD, NULL, 0) < 0) {
49 SMB_Discon(con, 0);
50 return (NTV_LOGON_ERROR);
51 }
52 SMB_Discon(con, 0);
53 return (NTV_NO_ERROR);
54 }
55