ext_edirectory_userip_acl.cc File Reference
#include "squid.h"
#include "helper/protocol_defines.h"
#include "rfc1738.h"
#include "util.h"
#include <cctype>
#include <cerrno>
#include <csignal>
#include <cstdlib>
#include <cstring>
#include <ctime>
Include dependency graph for ext_edirectory_userip_acl.cc:

Go to the source code of this file.

Classes

struct  edui_conf_t
 
struct  edui_ldap_t
 

Macros

#define EDUI_PROGRAM_NAME   "ext_edirectory_userip_acl"
 
#define EDUI_PROGRAM_VERSION   "2.1"
 
#define _GNU_SOURCE
 
#define __USE_GNU
 
#define LDAP_DEPRECATED   1 /* Set flag for enabling classic ldap functions */
 
#define EDUI_MAXLEN   4096 /* Modified to improve performance, unless HELPER_INPUT_BUFFER exists */
 
#define USE_LDAP_INIT
 
#define NETSCAPE_SSL
 
#define LDAP_AUTH_TLS   ((ber_tag_t) 0xb3U)
 
#define EDUI_MODE_INIT   0x01
 
#define EDUI_MODE_DEBUG   0x02 /* Replace with Squid's debug system */
 
#define EDUI_MODE_TLS   0x04
 
#define EDUI_MODE_IPV4   0x08
 
#define EDUI_MODE_IPV6   0x10
 
#define EDUI_MODE_GROUP   0x20 /* Group is REQUIRED */
 
#define EDUI_MODE_PERSIST   0x40 /* Persistent LDAP connections */
 
#define EDUI_MODE_KILL   0x80
 
#define LDAP_INIT_S   0x0001
 
#define LDAP_OPEN_S   0x0002
 
#define LDAP_BIND_S   0x0004
 
#define LDAP_SEARCH_S   0x0008 /* We got data */
 
#define LDAP_VAL_S   0x0010 /* Data has been copied to l->val */
 
#define LDAP_CLOSE_S   0x0020
 
#define LDAP_PERSIST_S   0x0040 /* Persistent connection */
 
#define LDAP_IDLE_S   0x0080 /* Connection is idle */
 
#define LDAP_SSL_S   0x0100
 
#define LDAP_TLS_S   0x0200
 
#define LDAP_IPV4_S   0x0400 /* Search IP is IPv4 */
 
#define LDAP_IPV6_S   0x0800 /* Search IP is IPv6 */
 
#define LDAP_ERR_NULL   -1 /* Null edui_ldap_t pointer */
 
#define LDAP_ERR_POINTER   -2 /* Null l->lp pointer */
 
#define LDAP_ERR_PARAM   -3 /* Null or Missing parameters */
 
#define LDAP_ERR_INIT   -4 /* Not initialized */
 
#define LDAP_ERR_OPEN   -5 /* Not open */
 
#define LDAP_ERR_CONNECT   -6 /* Unable to connect */
 
#define LDAP_ERR_BIND   -7 /* Not bound */
 
#define LDAP_ERR_SEARCHED   -8 /* Already Searched */
 
#define LDAP_ERR_NOT_SEARCHED   -9 /* Not searching */
 
#define LDAP_ERR_INVALID   -10 /* Invalid parameter */
 
#define LDAP_ERR_OOB   -11 /* Out of bounds value */
 
#define LDAP_ERR_PERSIST   -12 /* Persistent mode is not active */
 
#define LDAP_ERR_DATA   -13 /* Required data missing */
 
#define LDAP_ERR_NOTFOUND   -14 /* Item not found */
 
#define LDAP_ERR_OTHER   -15 /* Other Generic Error condition */
 
#define LDAP_ERR_FAILED   -16 /* Operation failed */
 
#define LDAP_ERR_SUCCESS   -17 /* Operation successful */
 

Functions

static void local_printfx (const char *,...)
 
static int StringSplit (char *, char, char *, size_t)
 
static int BinarySplit (void *, size_t, char, void *, size_t)
 
static void DisplayVersion ()
 
static void DisplayUsage ()
 
static void InitConf ()
 
static void DisplayConf ()
 
static void InitLDAP (edui_ldap_t *)
 
static int OpenLDAP (edui_ldap_t *, char *, unsigned int)
 
static int CloseLDAP (edui_ldap_t *)
 
static int SetVerLDAP (edui_ldap_t *, int)
 
static int BindLDAP (edui_ldap_t *, char *, char *, unsigned int)
 
static int ConvertIP (edui_ldap_t *, char *)
 
static int ResetLDAP (edui_ldap_t *)
 
static int SearchFilterLDAP (edui_ldap_t *, char *)
 
static int SearchLDAP (edui_ldap_t *, int, char *, char **)
 
static int SearchIPLDAP (edui_ldap_t *)
 
const char * ErrLDAP (int)
 
void SigTrap (int)
 
static struct addrinfo * makeIpBinary (const char *src)
 
static int makeHexString (char *dst, const int dstSize, const char *src, const int srcLen)
 
static int MainSafe (int argc, char **argv)
 
int main (int argc, char **argv)
 

Variables

const char * search_attrib [] = { "cn", "uid", "networkAddress", "groupMembership", nullptr }
 
static edui_conf_t edui_conf
 
static edui_ldap_t edui_ldap
 
time_t edui_now
 
time_t edui_elap
 

Macro Definition Documentation

◆ __USE_GNU

#define __USE_GNU

Definition at line 51 of file ext_edirectory_userip_acl.cc.

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 48 of file ext_edirectory_userip_acl.cc.

◆ EDUI_MAXLEN

#define EDUI_MAXLEN   4096 /* Modified to improve performance, unless HELPER_INPUT_BUFFER exists */

Definition at line 82 of file ext_edirectory_userip_acl.cc.

◆ EDUI_MODE_DEBUG

#define EDUI_MODE_DEBUG   0x02 /* Replace with Squid's debug system */

Definition at line 102 of file ext_edirectory_userip_acl.cc.

◆ EDUI_MODE_GROUP

#define EDUI_MODE_GROUP   0x20 /* Group is REQUIRED */

Definition at line 106 of file ext_edirectory_userip_acl.cc.

◆ EDUI_MODE_INIT

#define EDUI_MODE_INIT   0x01

Definition at line 101 of file ext_edirectory_userip_acl.cc.

◆ EDUI_MODE_IPV4

#define EDUI_MODE_IPV4   0x08

Definition at line 104 of file ext_edirectory_userip_acl.cc.

◆ EDUI_MODE_IPV6

#define EDUI_MODE_IPV6   0x10

Definition at line 105 of file ext_edirectory_userip_acl.cc.

◆ EDUI_MODE_KILL

#define EDUI_MODE_KILL   0x80

Definition at line 108 of file ext_edirectory_userip_acl.cc.

◆ EDUI_MODE_PERSIST

#define EDUI_MODE_PERSIST   0x40 /* Persistent LDAP connections */

Definition at line 107 of file ext_edirectory_userip_acl.cc.

◆ EDUI_MODE_TLS

#define EDUI_MODE_TLS   0x04

Definition at line 103 of file ext_edirectory_userip_acl.cc.

◆ EDUI_PROGRAM_NAME

#define EDUI_PROGRAM_NAME   "ext_edirectory_userip_acl"

Definition at line 43 of file ext_edirectory_userip_acl.cc.

◆ EDUI_PROGRAM_VERSION

#define EDUI_PROGRAM_VERSION   "2.1"

Definition at line 44 of file ext_edirectory_userip_acl.cc.

◆ LDAP_AUTH_TLS

#define LDAP_AUTH_TLS   ((ber_tag_t) 0xb3U)

Definition at line 96 of file ext_edirectory_userip_acl.cc.

◆ LDAP_BIND_S

#define LDAP_BIND_S   0x0004

Definition at line 129 of file ext_edirectory_userip_acl.cc.

◆ LDAP_CLOSE_S

#define LDAP_CLOSE_S   0x0020

Definition at line 132 of file ext_edirectory_userip_acl.cc.

◆ LDAP_DEPRECATED

#define LDAP_DEPRECATED   1 /* Set flag for enabling classic ldap functions */

Definition at line 62 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_BIND

#define LDAP_ERR_BIND   -7 /* Not bound */

Definition at line 147 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_CONNECT

#define LDAP_ERR_CONNECT   -6 /* Unable to connect */

Definition at line 146 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_DATA

#define LDAP_ERR_DATA   -13 /* Required data missing */

Definition at line 153 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_FAILED

#define LDAP_ERR_FAILED   -16 /* Operation failed */

Definition at line 156 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_INIT

#define LDAP_ERR_INIT   -4 /* Not initialized */

Definition at line 144 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_INVALID

#define LDAP_ERR_INVALID   -10 /* Invalid parameter */

Definition at line 150 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_NOT_SEARCHED

#define LDAP_ERR_NOT_SEARCHED   -9 /* Not searching */

Definition at line 149 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_NOTFOUND

#define LDAP_ERR_NOTFOUND   -14 /* Item not found */

Definition at line 154 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_NULL

#define LDAP_ERR_NULL   -1 /* Null edui_ldap_t pointer */

Definition at line 141 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_OOB

#define LDAP_ERR_OOB   -11 /* Out of bounds value */

Definition at line 151 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_OPEN

#define LDAP_ERR_OPEN   -5 /* Not open */

Definition at line 145 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_OTHER

#define LDAP_ERR_OTHER   -15 /* Other Generic Error condition */

Definition at line 155 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_PARAM

#define LDAP_ERR_PARAM   -3 /* Null or Missing parameters */

Definition at line 143 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_PERSIST

#define LDAP_ERR_PERSIST   -12 /* Persistent mode is not active */

Definition at line 152 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_POINTER

#define LDAP_ERR_POINTER   -2 /* Null l->lp pointer */

Definition at line 142 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_SEARCHED

#define LDAP_ERR_SEARCHED   -8 /* Already Searched */

Definition at line 148 of file ext_edirectory_userip_acl.cc.

◆ LDAP_ERR_SUCCESS

#define LDAP_ERR_SUCCESS   -17 /* Operation successful */

Definition at line 157 of file ext_edirectory_userip_acl.cc.

◆ LDAP_IDLE_S

#define LDAP_IDLE_S   0x0080 /* Connection is idle */

Definition at line 134 of file ext_edirectory_userip_acl.cc.

◆ LDAP_INIT_S

#define LDAP_INIT_S   0x0001

Definition at line 127 of file ext_edirectory_userip_acl.cc.

◆ LDAP_IPV4_S

#define LDAP_IPV4_S   0x0400 /* Search IP is IPv4 */

Definition at line 137 of file ext_edirectory_userip_acl.cc.

◆ LDAP_IPV6_S

#define LDAP_IPV6_S   0x0800 /* Search IP is IPv6 */

Definition at line 138 of file ext_edirectory_userip_acl.cc.

◆ LDAP_OPEN_S

#define LDAP_OPEN_S   0x0002

Definition at line 128 of file ext_edirectory_userip_acl.cc.

◆ LDAP_PERSIST_S

#define LDAP_PERSIST_S   0x0040 /* Persistent connection */

Definition at line 133 of file ext_edirectory_userip_acl.cc.

◆ LDAP_SEARCH_S

#define LDAP_SEARCH_S   0x0008 /* We got data */

Definition at line 130 of file ext_edirectory_userip_acl.cc.

◆ LDAP_SSL_S

#define LDAP_SSL_S   0x0100

Definition at line 135 of file ext_edirectory_userip_acl.cc.

◆ LDAP_TLS_S

#define LDAP_TLS_S   0x0200

Definition at line 136 of file ext_edirectory_userip_acl.cc.

◆ LDAP_VAL_S

#define LDAP_VAL_S   0x0010 /* Data has been copied to l->val */

Definition at line 131 of file ext_edirectory_userip_acl.cc.

◆ NETSCAPE_SSL

#define NETSCAPE_SSL

Definition at line 88 of file ext_edirectory_userip_acl.cc.

◆ USE_LDAP_INIT

#define USE_LDAP_INIT

Definition at line 86 of file ext_edirectory_userip_acl.cc.

Function Documentation

◆ BinarySplit()

static int BinarySplit ( void *  In_Obj,
size_t  In_Sz,
char  chr,
void *  Out_Obj,
size_t  Out_Sz 
)
static

Definition at line 311 of file ext_edirectory_userip_acl.cc.

Referenced by SearchIPLDAP().

◆ BindLDAP()

◆ CloseLDAP()

◆ ConvertIP()

◆ DisplayConf()

◆ DisplayUsage()

static void DisplayUsage ( )
static

Definition at line 365 of file ext_edirectory_userip_acl.cc.

References DisplayVersion(), edui_conf, local_printfx(), and edui_conf_t::program.

Referenced by MainSafe().

◆ DisplayVersion()

static void DisplayVersion ( )
static

Definition at line 358 of file ext_edirectory_userip_acl.cc.

References EDUI_PROGRAM_VERSION, and local_printfx().

Referenced by DisplayConf(), DisplayUsage(), and MainSafe().

◆ ErrLDAP()

◆ InitConf()

◆ InitLDAP()

◆ local_printfx()

static void local_printfx ( const char *  msg,
  ... 
)
static

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 1766 of file ext_edirectory_userip_acl.cc.

References MainSafe().

◆ MainSafe()

◆ makeHexString()

static int makeHexString ( char *  dst,
const int  dstSize,
const char *  src,
const int  srcLen 
)
static

Convert srcLen bytes from src into HEX and store into dst, which has a maximum content size of dstSize including c-string terminator. The dst value produced will be a 0-terminated c-string.

Return values
Nlength of dst written (excluding c-string terminator)
-11(LDAP_ERR_OOB) buffer overflow detected

Definition at line 771 of file ext_edirectory_userip_acl.cc.

References LDAP_ERR_OOB.

Referenced by ConvertIP(), and SearchIPLDAP().

◆ makeIpBinary()

static struct addrinfo * makeIpBinary ( const char *  src)
static

Convert the IP address string representation in src to its binary representation.

Returns
binary representation of the src IP address. Must be free'd using freeaddrinfo().

Definition at line 744 of file ext_edirectory_userip_acl.cc.

Referenced by ConvertIP().

◆ OpenLDAP()

◆ ResetLDAP()

◆ SearchFilterLDAP()

◆ SearchIPLDAP()

◆ SearchLDAP()

◆ SetVerLDAP()

◆ SigTrap()

void SigTrap ( int  s)

◆ StringSplit()

static int StringSplit ( char *  In_Str,
char  chr,
char *  Out_Str,
size_t  Out_Sz 
)
static

Definition at line 260 of file ext_edirectory_userip_acl.cc.

Referenced by MainSafe().

Variable Documentation

◆ edui_conf

◆ edui_elap

time_t edui_elap

Definition at line 208 of file ext_edirectory_userip_acl.cc.

Referenced by MainSafe().

◆ edui_ldap

edui_ldap_t edui_ldap
static

Definition at line 206 of file ext_edirectory_userip_acl.cc.

Referenced by MainSafe(), and SigTrap().

◆ edui_now

time_t edui_now

Definition at line 207 of file ext_edirectory_userip_acl.cc.

Referenced by MainSafe().

◆ search_attrib

const char* search_attrib[] = { "cn", "uid", "networkAddress", "groupMembership", nullptr }

Definition at line 204 of file ext_edirectory_userip_acl.cc.

Referenced by MainSafe().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors