#include "squid.h"
#include "base64.h"
#include "compat/debug.h"
#include "helper/protocol_defines.h"
#include "ntlmauth/ntlmauth.h"
#include "ntlmauth/support_bits.cci"
#include "rfcnb/rfcnb.h"
#include "smblib/smblib.h"
#include <cassert>
#include <cctype>
#include <cerrno>
#include <csignal>
#include <cstdlib>
#include <cstring>
#include <ctime>
![](ntlm__smb__lm__auth_8cc__incl.png)
Go to the source code of this file.
Classes | |
struct | _dc |
Macros | |
#define | DEAD_DC_RETRY_INTERVAL 30 |
#define | SEND(X) debug("sending '%s' to squid\n",X); printf(X "\n"); |
#define | SEND2 printf |
#define | SEND3 printf |
#define | ENCODED_PASS_LEN 24 |
#define | MAX_USERNAME_LEN 255 |
#define | MAX_DOMAIN_LEN 255 |
#define | MAX_PASSWD_LEN 31 |
Typedefs | |
typedef struct _dc | dc |
Functions | |
static void | usage (void) |
static void | process_options (int argc, char *argv[]) |
static const char * | obtain_challenge (void) |
static void | manage_request (void) |
static const char * | make_challenge (char *domain, char *controller) |
static char * | ntlm_check_auth (ntlm_authenticate *auth, int auth_length) |
static void | dc_disconnect (void) |
static int | init_challenge (char *domain, char *domain_controller) |
void | timeout_during_auth (int) |
int | main (int argc, char *argv[]) |
Variables | |
static unsigned char | challenge [NTLM_NONCE_LEN] |
static unsigned char | lmencoded_empty_pass [ENCODED_PASS_LEN] |
static unsigned char | ntencoded_empty_pass [ENCODED_PASS_LEN] |
SMB_Handle_Type | handle = nullptr |
static NtlmError | ntlm_errno |
static char | credentials [MAX_USERNAME_LEN+MAX_DOMAIN_LEN+2] |
static char | my_domain [100] |
static char | my_domain_controller [100] |
static char | errstr [1001] |
char | load_balance = 0 |
char | protocol_pedantic = 0 |
dc * | controllers = nullptr |
int | numcontrollers = 0 |
dc * | current_dc |
char | smb_error_buffer [1000] |
static char | got_timeout = 0 |
char * | my_program_name = nullptr |
Macro Definition Documentation
◆ DEAD_DC_RETRY_INTERVAL
#define DEAD_DC_RETRY_INTERVAL 30 |
Definition at line 52 of file ntlm_smb_lm_auth.cc.
◆ ENCODED_PASS_LEN
#define ENCODED_PASS_LEN 24 |
Definition at line 84 of file ntlm_smb_lm_auth.cc.
◆ MAX_DOMAIN_LEN
#define MAX_DOMAIN_LEN 255 |
Definition at line 86 of file ntlm_smb_lm_auth.cc.
◆ MAX_PASSWD_LEN
#define MAX_PASSWD_LEN 31 |
Definition at line 87 of file ntlm_smb_lm_auth.cc.
◆ MAX_USERNAME_LEN
#define MAX_USERNAME_LEN 255 |
Definition at line 85 of file ntlm_smb_lm_auth.cc.
◆ SEND
#define SEND | ( | X | ) | debug("sending '%s' to squid\n",X); printf(X "\n"); |
Definition at line 57 of file ntlm_smb_lm_auth.cc.
◆ SEND2
#define SEND2 printf |
Definition at line 63 of file ntlm_smb_lm_auth.cc.
◆ SEND3
#define SEND3 printf |
Definition at line 64 of file ntlm_smb_lm_auth.cc.
Typedef Documentation
◆ dc
Definition at line 67 of file ntlm_smb_lm_auth.cc.
Function Documentation
◆ dc_disconnect()
|
static |
Definition at line 109 of file ntlm_smb_lm_auth.cc.
References handle, NULL, and SMB_Discon().
Referenced by manage_request(), and timeout_during_auth().
◆ init_challenge()
|
static |
Definition at line 118 of file ntlm_smb_lm_auth.cc.
References challenge, debug(), SMB_Connect_Def::Encrypt_Key, errstr, handle, lmencoded_empty_pass, ntencoded_empty_pass, NTLM_NONCE_LEN, NULL, SMB_Connect_Def::Security, SMB_Connect_Server(), SMB_Discon(), SMB_Get_Error_Msg(), SMB_Get_Last_Error(), SMB_Negotiate(), SMB_Prots, SMBencrypt(), and SMBNTencrypt().
Referenced by make_challenge().
◆ main()
Definition at line 671 of file ntlm_smb_lm_auth.cc.
References controllers, current_dc, debug(), load_balance, manage_request(), my_program_name, _dc::next, numcontrollers, pid, process_options(), and VERSION.
◆ make_challenge()
|
static |
Definition at line 153 of file ntlm_smb_lm_auth.cc.
References base64_encode_final(), base64_encode_init(), base64_encode_len, base64_encode_update(), challenge, debug(), HELPER_INPUT_BUFFER, init_challenge(), le16toh, _strhdr::maxlen, my_domain, my_domain_controller, NTLM_CHALLENGE_TARGET_IS_DOMAIN, ntlm_make_challenge(), NTLM_NEGOTIATE_ALWAYS_SIGN, NTLM_NEGOTIATE_ASCII, NTLM_NEGOTIATE_USE_LM, NTLM_NEGOTIATE_USE_NTLM, NTLM_NONCE_LEN, NTLM_REQUEST_NON_NT_SESSION_KEY, _ntlm_challenge::payload, and _ntlm_challenge::target.
Referenced by obtain_challenge().
◆ manage_request()
|
static |
Definition at line 500 of file ntlm_smb_lm_auth.cc.
References base64_decode_final(), base64_decode_init(), base64_decode_update(), dc_disconnect(), debug(), got_timeout, lc(), le32toh, LoginEror, NTLM_ANY, NTLM_AUTHENTICATE, NTLM_BLOB_BUFFER_SIZE, NTLM_CHALLENGE, ntlm_check_auth(), ntlm_errno, NTLM_NEGOTIATE, ntlm_validate_packet(), NULL, obtain_challenge(), RFCNB_Error_Strings, RFCNB_Get_Last_Error(), SEND, SEND2, SMB_Get_Last_Error(), SMB_Get_Last_SMB_Err(), SMBC_ERRCMD, SMBC_ERRDOS, SMBC_ERRHRD, SMBC_ERRSRV, SMBC_SUCCESS, SMBD_badaccess, SMBD_baddata, SMBD_badformat, SMBD_noaccess, SMBlib_Error_Class, SMBlib_Error_Code, SMBV_access, SMBV_badpw, strerror(), timeout_during_auth(), and _ntlmhdr::type.
Referenced by main().
◆ ntlm_check_auth()
|
static |
Definition at line 199 of file ntlm_smb_lm_auth.cc.
References BlobError, credentials, debug(), _ntlm_authenticate::domain, ENCODED_PASS_LEN, _ntlm_authenticate::flags, handle, _ntlm_authenticate::hdr, _lstring::l, le16toh, le32toh, _strhdr::len, lmencoded_empty_pass, _ntlm_authenticate::lmresponse, LoginEror, MAX_DOMAIN_LEN, MAX_PASSWD_LEN, MAX_USERNAME_LEN, min(), None, NotConnected, ntencoded_empty_pass, ntlm_errno, ntlm_fetch_string(), _ntlm_authenticate::ntresponse, NULL, _strhdr::offset, ProtocolError, ServerError, SMB_Logon_Server(), SMBlibE_BAD, SMBlibE_BadParam, SMBlibE_CallFailed, SMBlibE_GuestOnly, SMBlibE_LowerLayer, SMBlibE_NegNoProt, SMBlibE_NoSpace, SMBlibE_NoSuchMsg, SMBlibE_NotImpl, SMBlibE_ProtLow, SMBlibE_ProtUnknown, SMBlibE_RecvFailed, SMBlibE_Remote, SMBlibE_SendFailed, SMBlibE_Success, _lstring::str, and _ntlm_authenticate::user.
Referenced by manage_request().
◆ obtain_challenge()
|
static |
tries connecting to the domain controllers in the "controllers" ring, with failover if the adequate option is specified.
Definition at line 463 of file ntlm_smb_lm_auth.cc.
References _dc::controller, current_dc, _dc::dead, DEAD_DC_RETRY_INTERVAL, debug(), _dc::domain, make_challenge(), _dc::next, NULL, and numcontrollers.
Referenced by manage_request().
◆ process_options()
|
static |
Definition at line 383 of file ntlm_smb_lm_auth.cc.
References _dc::controller, controllers, _dc::dead, debug(), debug_enabled, _dc::domain, getopt(), load_balance, _dc::next, NULL, numcontrollers, optind, uc(), usage(), and xmalloc.
Referenced by main().
◆ timeout_during_auth()
void timeout_during_auth | ( | int | ) |
signal handler to be invoked when the authentication operation times out
Definition at line 351 of file ntlm_smb_lm_auth.cc.
References dc_disconnect().
Referenced by manage_request().
◆ usage()
|
static |
Definition at line 367 of file ntlm_smb_lm_auth.cc.
References my_program_name.
Referenced by process_options().
Variable Documentation
◆ challenge
|
static |
Definition at line 89 of file ntlm_smb_lm_auth.cc.
Referenced by init_challenge(), and make_challenge().
◆ controllers
dc* controllers = nullptr |
Definition at line 101 of file ntlm_smb_lm_auth.cc.
Referenced by main(), and process_options().
◆ credentials
|
static |
Definition at line 94 of file ntlm_smb_lm_auth.cc.
Referenced by GenServerContext(), and ntlm_check_auth().
◆ current_dc
dc* current_dc |
Definition at line 103 of file ntlm_smb_lm_auth.cc.
Referenced by main(), and obtain_challenge().
◆ errstr
|
static |
Definition at line 96 of file ntlm_smb_lm_auth.cc.
Referenced by init_challenge(), and main().
◆ got_timeout
|
static |
Definition at line 347 of file ntlm_smb_lm_auth.cc.
Referenced by manage_request().
◆ handle
SMB_Handle_Type handle = nullptr |
Definition at line 92 of file ntlm_smb_lm_auth.cc.
Referenced by dc_disconnect(), file_write(), init_challenge(), and ntlm_check_auth().
◆ lmencoded_empty_pass
|
static |
Definition at line 90 of file ntlm_smb_lm_auth.cc.
Referenced by init_challenge(), and ntlm_check_auth().
◆ load_balance
char load_balance = 0 |
Definition at line 100 of file ntlm_smb_lm_auth.cc.
Referenced by main(), and process_options().
◆ my_domain
|
static |
Definition at line 95 of file ntlm_smb_lm_auth.cc.
Referenced by make_challenge().
◆ my_domain_controller
|
static |
Definition at line 95 of file ntlm_smb_lm_auth.cc.
Referenced by make_challenge().
◆ my_program_name
char* my_program_name = nullptr |
Definition at line 364 of file ntlm_smb_lm_auth.cc.
◆ ntencoded_empty_pass
|
static |
Definition at line 91 of file ntlm_smb_lm_auth.cc.
Referenced by init_challenge(), and ntlm_check_auth().
◆ ntlm_errno
|
static |
Definition at line 93 of file ntlm_smb_lm_auth.cc.
Referenced by manage_request(), and ntlm_check_auth().
◆ numcontrollers
int numcontrollers = 0 |
Definition at line 102 of file ntlm_smb_lm_auth.cc.
Referenced by main(), obtain_challenge(), and process_options().
◆ protocol_pedantic
char protocol_pedantic = 0 |
Definition at line 100 of file ntlm_smb_lm_auth.cc.
◆ smb_error_buffer
char smb_error_buffer[1000] |
Definition at line 104 of file ntlm_smb_lm_auth.cc.
Introduction
- About Squid
- Why Squid?
- Squid Developers
- How to Donate
- How to Help Out
- Getting Squid
- Squid Source Packages
- Squid Deployment Case-Studies
- Squid Software Foundation
Documentation
- Quick Setup
- Configuration:
- FAQ and Wiki
- Guide Books:
- Non-English
- More...
Support
- Security Advisories
- Bugzilla Database
- Mailing lists
- Contacting us
- Commercial services
- Project Sponsors
- Squid-based products