Squid Web Cache v8/master
Loading...
Searching...
No Matches
support.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2026 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/*
10 * -----------------------------------------------------------------------------
11 *
12 * Author: Markus Moeller (markus_moeller at compuserve.com)
13 *
14 * Copyright (C) 2007 Markus Moeller. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, see <https://www.gnu.org/licenses/>.
28 *
29 * -----------------------------------------------------------------------------
30 */
31
32#ifndef SQUID_SRC_ACL_EXTERNAL_KERBEROS_LDAP_GROUP_SUPPORT_H
33#define SQUID_SRC_ACL_EXTERNAL_KERBEROS_LDAP_GROUP_SUPPORT_H
34
35#define KERBEROS_LDAP_GROUP_VERSION "1.4.0sq"
36
37#include "compat/krb5.h"
38
39#include <cstring>
40#if HAVE_COM_ERR_H
41#include <com_err.h>
42#endif /* HAVE_COM_ERR_H */
43#define LDAP_DEPRECATED 1
44#if HAVE_LDAP_REBIND_FUNCTION
45#define LDAP_REFERRALS
46#endif
47#if HAVE_LBER_H
48#include <lber.h>
49#endif
50#if HAVE_LDAP_H
51#include <ldap.h>
52#endif
53#if HAVE_MOZLDAP_LDAP_H
54#include <mozldap/ldap.h>
55#endif
56
57struct gdstruct {
58 char *group;
59 char *domain;
60 struct gdstruct *next;
61};
62struct ndstruct {
63 char *netbios;
64 char *domain;
65 struct ndstruct *next;
66};
67struct lsstruct {
68 char *lserver;
69 char *domain;
70 struct lsstruct *next;
71};
72
73struct main_args {
74 char *glist;
75 char *ulist;
76 char *tlist;
77 char *nlist;
78 char *llist;
79 char *luser;
80 char *lpass;
81 char *lbind;
82 char *lurl;
83 char *ssl;
85 int AD;
86 int mdepth;
88 char *ddomain;
90 struct ndstruct *ndoms;
92 char *principal;
93};
94
95extern int log_enabled;
96
97/* the macro overload style is really a gcc-ism */
98#ifdef __GNUC__
99
100#define log(X...) \
101 if (log_enabled) { \
102 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
103 fprintf(stderr,X); \
104 } else (void)0
105
106#define error(X...) \
107 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
108 fprintf(stderr,X); \
109
110#define warn(X...) \
111 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
112 fprintf(stderr,X); \
113
114#else /* __GNUC__ */
115
116/* non-GCC compilers can't do the above macro define yet. */
117void log(char *format,...);
118void error(char *format,...);
119void warn(char *format,...);
120#endif
121
122struct hstruct {
123 char *host;
124 int port;
127};
128
130 char *dn;
131 char *pw;
132};
133
134void init_args(struct main_args *margs);
135void clean_args(struct main_args *margs);
136const char *LogTime(void);
137
138int check_memberof(struct main_args *margs, char *user, char *domain);
139int get_memberof(struct main_args *margs, char *user, char *domain, char *group);
140
141char *get_netbios_name(struct main_args *margs, char *netbios);
142
143int create_gd(struct main_args *margs);
144int create_nd(struct main_args *margs);
145int create_ls(struct main_args *margs);
146
147size_t get_ldap_hostname_list(struct main_args *margs, struct hstruct **hlist, size_t nhosts, char *domain);
148size_t get_hostname_list(struct hstruct **hlist, size_t nhosts, char *name);
149size_t free_hostname_list(struct hstruct **hlist, size_t nhosts);
150
151#if HAVE_SASL_H || HAVE_SASL_SASL_H
152int tool_sasl_bind(LDAP * ld, char *binddn, char *ssl);
153#endif
154
155#if HAVE_KRB5
156#define MAX_DOMAINS 16
157#define MAX_SKEW 300
158struct kstruct {
159 krb5_context context;
160 krb5_ccache cc[MAX_DOMAINS];
161 char* mem_ccache[MAX_DOMAINS];
162 int ncache;
163};
164int krb5_create_cache(char *domain, char* princ);
165void krb5_cleanup(void);
166#endif
167
168#define PROGRAM "kerberos_ldap_group"
169
170#endif /* SQUID_SRC_ACL_EXTERNAL_KERBEROS_LDAP_GROUP_SUPPORT_H */
171
int create_gd(struct main_args *margs)
void log(char *format,...)
void error(char *format,...)
size_t get_hostname_list(struct hstruct **hlist, size_t nhosts, char *name)
void warn(char *format,...)
int log_enabled
int get_memberof(struct main_args *margs, char *user, char *domain, char *group)
int create_nd(struct main_args *margs)
const char * LogTime(void)
void clean_args(struct main_args *margs)
size_t free_hostname_list(struct hstruct **hlist, size_t nhosts)
int create_ls(struct main_args *margs)
size_t get_ldap_hostname_list(struct main_args *margs, struct hstruct **hlist, size_t nhosts, char *domain)
char * get_netbios_name(struct main_args *margs, char *netbios)
int check_memberof(struct main_args *margs, char *user, char *domain)
void init_args(struct main_args *margs)
static LDAP * ld
static const char * binddn
struct gdstruct * next
Definition support.h:60
char * group
Definition support.h:58
char * domain
Definition support.h:59
int port
Definition support.h:124
char * host
Definition support.h:123
int priority
Definition support.h:125
int weight
Definition support.h:126
char * dn
Definition support.h:130
char * pw
Definition support.h:131
struct lsstruct * next
Definition support.h:70
char * domain
Definition support.h:69
char * lserver
Definition support.h:68
char * ulist
Definition support.h:75
struct lsstruct * lservs
Definition support.h:91
struct ndstruct * ndoms
Definition support.h:90
char * ddomain
Definition support.h:88
char * ssl
Definition support.h:83
char * nlist
Definition support.h:77
char * glist
Definition support.h:74
int AD
Definition support.h:85
int mdepth
Definition support.h:86
char * llist
Definition support.h:78
int rc_allow
Definition support.h:84
char * luser
Definition support.h:79
char * lpass
Definition support.h:80
char * principal
Definition support.h:92
char * lurl
Definition support.h:82
char * tlist
Definition support.h:76
struct gdstruct * groups
Definition support.h:89
char * lbind
Definition support.h:81
int nokerberos
Definition support.h:87
char * domain
Definition support.h:64
char * netbios
Definition support.h:63
struct ndstruct * next
Definition support.h:65