ntlm_smb_lm_auth.cc File Reference
#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>
Include dependency graph for ntlm_smb_lm_auth.cc:

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
 
dccontrollers = nullptr
 
int numcontrollers = 0
 
dccurrent_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

typedef struct _dc dc

Definition at line 67 of file ntlm_smb_lm_auth.cc.

Function Documentation

◆ dc_disconnect()

static void dc_disconnect ( void  )
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()

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ make_challenge()

◆ manage_request()

◆ ntlm_check_auth()

◆ obtain_challenge()

static const char * 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 void process_options ( int  argc,
char *  argv[] 
)
static

◆ 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 void usage ( void  )
static

Definition at line 367 of file ntlm_smb_lm_auth.cc.

References my_program_name.

Referenced by process_options().

Variable Documentation

◆ challenge

unsigned char challenge[NTLM_NONCE_LEN]
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

char credentials[MAX_USERNAME_LEN+MAX_DOMAIN_LEN+2]
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

char errstr[1001]
static

Definition at line 96 of file ntlm_smb_lm_auth.cc.

Referenced by init_challenge(), and main().

◆ got_timeout

char got_timeout = 0
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

unsigned char lmencoded_empty_pass[ENCODED_PASS_LEN]
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

char my_domain[100]
static

Definition at line 95 of file ntlm_smb_lm_auth.cc.

Referenced by make_challenge().

◆ my_domain_controller

char my_domain_controller[100]
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.

Referenced by main(), and usage().

◆ ntencoded_empty_pass

unsigned char ntencoded_empty_pass[ENCODED_PASS_LEN]
static

Definition at line 91 of file ntlm_smb_lm_auth.cc.

Referenced by init_challenge(), and ntlm_check_auth().

◆ ntlm_errno

NtlmError 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

Documentation

Support

Miscellaneous