Squid Web Cache master
Loading...
Searching...
No Matches
support.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
29 *
30 * -----------------------------------------------------------------------------
31 */
32
33#ifndef SQUID_SRC_ACL_EXTERNAL_KERBEROS_LDAP_GROUP_SUPPORT_H
34#define SQUID_SRC_ACL_EXTERNAL_KERBEROS_LDAP_GROUP_SUPPORT_H
35
36#define KERBEROS_LDAP_GROUP_VERSION "1.4.0sq"
37
38#include "compat/krb5.h"
39
40#include <cstring>
41#if HAVE_COM_ERR_H
42#include <com_err.h>
43#endif /* HAVE_COM_ERR_H */
44#define LDAP_DEPRECATED 1
45#if HAVE_LDAP_REBIND_FUNCTION
46#define LDAP_REFERRALS
47#endif
48#if HAVE_LBER_H
49#include <lber.h>
50#endif
51#if HAVE_LDAP_H
52#include <ldap.h>
53#endif
54#if HAVE_MOZLDAP_LDAP_H
55#include <mozldap/ldap.h>
56#endif
57
58struct gdstruct {
59 char *group;
60 char *domain;
61 struct gdstruct *next;
62};
63struct ndstruct {
64 char *netbios;
65 char *domain;
66 struct ndstruct *next;
67};
68struct lsstruct {
69 char *lserver;
70 char *domain;
71 struct lsstruct *next;
72};
73
74struct main_args {
75 char *glist;
76 char *ulist;
77 char *tlist;
78 char *nlist;
79 char *llist;
80 char *luser;
81 char *lpass;
82 char *lbind;
83 char *lurl;
84 char *ssl;
86 int AD;
87 int mdepth;
89 char *ddomain;
91 struct ndstruct *ndoms;
93 char *principal;
94};
95
96extern int log_enabled;
97
98/* the macro overload style is really a gcc-ism */
99#ifdef __GNUC__
100
101#define log(X...) \
102 if (log_enabled) { \
103 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
104 fprintf(stderr,X); \
105 } else (void)0
106
107#define error(X...) \
108 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
109 fprintf(stderr,X); \
110
111#define warn(X...) \
112 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
113 fprintf(stderr,X); \
114
115#else /* __GNUC__ */
116
117/* non-GCC compilers can't do the above macro define yet. */
118void log(char *format,...);
119void error(char *format,...);
120void warn(char *format,...);
121#endif
122
123struct hstruct {
124 char *host;
125 int port;
128};
129
131 char *dn;
132 char *pw;
133};
134
135void init_args(struct main_args *margs);
136void clean_args(struct main_args *margs);
137const char *LogTime(void);
138
139int check_memberof(struct main_args *margs, char *user, char *domain);
140int get_memberof(struct main_args *margs, char *user, char *domain, char *group);
141
142char *get_netbios_name(struct main_args *margs, char *netbios);
143
144int create_gd(struct main_args *margs);
145int create_nd(struct main_args *margs);
146int create_ls(struct main_args *margs);
147
148size_t get_ldap_hostname_list(struct main_args *margs, struct hstruct **hlist, size_t nhosts, char *domain);
149size_t get_hostname_list(struct hstruct **hlist, size_t nhosts, char *name);
150size_t free_hostname_list(struct hstruct **hlist, size_t nhosts);
151
152#if HAVE_SASL_H || HAVE_SASL_SASL_H
153int tool_sasl_bind(LDAP * ld, char *binddn, char *ssl);
154#endif
155
156#if HAVE_KRB5
157#define MAX_DOMAINS 16
158#define MAX_SKEW 300
159struct kstruct {
160 krb5_context context;
161 krb5_ccache cc[MAX_DOMAINS];
162 char* mem_ccache[MAX_DOMAINS];
163 int ncache;
164};
165int krb5_create_cache(char *domain, char* princ);
166void krb5_cleanup(void);
167#endif
168
169#define PROGRAM "kerberos_ldap_group"
170
171#endif /* SQUID_SRC_ACL_EXTERNAL_KERBEROS_LDAP_GROUP_SUPPORT_H */
172
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:61
char * group
Definition support.h:59
char * domain
Definition support.h:60
int port
Definition support.h:125
char * host
Definition support.h:124
int priority
Definition support.h:126
int weight
Definition support.h:127
char * dn
Definition support.h:131
char * pw
Definition support.h:132
struct lsstruct * next
Definition support.h:71
char * domain
Definition support.h:70
char * lserver
Definition support.h:69
char * ulist
Definition support.h:76
struct lsstruct * lservs
Definition support.h:92
struct ndstruct * ndoms
Definition support.h:91
char * ddomain
Definition support.h:89
char * ssl
Definition support.h:84
char * nlist
Definition support.h:78
char * glist
Definition support.h:75
int AD
Definition support.h:86
int mdepth
Definition support.h:87
char * llist
Definition support.h:79
int rc_allow
Definition support.h:85
char * luser
Definition support.h:80
char * lpass
Definition support.h:81
char * principal
Definition support.h:93
char * lurl
Definition support.h:83
char * tlist
Definition support.h:77
struct gdstruct * groups
Definition support.h:90
char * lbind
Definition support.h:82
int nokerberos
Definition support.h:88
char * domain
Definition support.h:65
char * netbios
Definition support.h:64
struct ndstruct * next
Definition support.h:66