]> git.ipfire.org Git - thirdparty/squid.git/blame - src/acl/external/kerberos_ldap_group/support.h
Remove custom global new/delete operators (#839)
[thirdparty/squid.git] / src / acl / external / kerberos_ldap_group / support.h
CommitLineData
ca02e0ec 1/*
f70aedc4 2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
ca02e0ec
AJ
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
b1218840
AJ
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
7451e5ad 33#define KERBEROS_LDAP_GROUP_VERSION "1.4.0sq"
b1218840 34
074d6a40 35#include <cstring>
b1218840 36
75f3c557
MM
37#if USE_APPLE_KRB5
38#define KERBEROS_APPLE_DEPRECATED(x)
39#endif
40
ffe4ffd8 41#if HAVE_KRB5_H
b1218840 42#if HAVE_BROKEN_SOLARIS_KRB5_H
ffe4ffd8
AJ
43#warn "Warning! You have a broken Solaris <krb5.h> system header"
44#warn "http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6837512"
b1218840
AJ
45#if defined(__cplusplus)
46#define KRB5INT_BEGIN_DECLS extern "C" {
47#define KRB5INT_END_DECLS
48KRB5INT_BEGIN_DECLS
49#endif
ffe4ffd8
AJ
50#endif /* HAVE_BROKEN_SOLARIS_KRB5_H */
51#if HAVE_BROKEN_HEIMDAL_KRB5_H
52extern "C" {
53#include <krb5.h>
54}
55#else
b1218840
AJ
56#include <krb5.h>
57#endif
ffe4ffd8
AJ
58#endif /* HAVE_KRB5_H */
59
60#if HAVE_COM_ERR_H
b1218840 61#include <com_err.h>
ffe4ffd8
AJ
62#endif /* HAVE_COM_ERR_H */
63
b1218840 64#define LDAP_DEPRECATED 1
7451e5ad 65#if HAVE_LDAP_REBIND_FUNCTION
b1218840
AJ
66#define LDAP_REFERRALS
67#endif
7451e5ad 68#if HAVE_LBER_H
b1218840
AJ
69#include <lber.h>
70#endif
7451e5ad 71#if HAVE_LDAP_H
b1218840
AJ
72#include <ldap.h>
73#endif
7451e5ad 74#if HAVE_MOZLDAP_LDAP_H
b1218840
AJ
75#include <mozldap/ldap.h>
76#endif
77
78struct gdstruct {
79 char *group;
80 char *domain;
81 struct gdstruct *next;
82};
83struct ndstruct {
84 char *netbios;
85 char *domain;
86 struct ndstruct *next;
87};
f602c423
MM
88struct lsstruct {
89 char *lserver;
90 char *domain;
91 struct lsstruct *next;
92};
b1218840
AJ
93
94struct main_args {
95 char *glist;
96 char *ulist;
97 char *tlist;
98 char *nlist;
f602c423 99 char *llist;
b1218840
AJ
100 char *luser;
101 char *lpass;
102 char *lbind;
103 char *lurl;
104 char *ssl;
105 int rc_allow;
106 int AD;
107 int mdepth;
7451e5ad 108 int nokerberos;
b1218840
AJ
109 char *ddomain;
110 struct gdstruct *groups;
111 struct ndstruct *ndoms;
f602c423 112 struct lsstruct *lservs;
40f1fd09 113 char *principal;
b1218840
AJ
114};
115
116SQUIDCEXTERN int log_enabled;
117
118/* the macro overload style is really a gcc-ism */
119#ifdef __GNUC__
120
b1218840
AJ
121#define log(X...) \
122 if (log_enabled) { \
123 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
124 fprintf(stderr,X); \
125 } else (void)0
126
127#define error(X...) \
128 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
129 fprintf(stderr,X); \
f17a1766 130
b1218840
AJ
131#define warn(X...) \
132 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
133 fprintf(stderr,X); \
f17a1766 134
b1218840
AJ
135#else /* __GNUC__ */
136
137/* non-GCC compilers can't do the above macro define yet. */
138void log(char *format,...);
139void error(char *format,...);
140void warn(char *format,...);
141#endif
142
b1218840
AJ
143struct hstruct {
144 char *host;
145 int port;
146 int priority;
147 int weight;
148};
149
150struct ldap_creds {
151 char *dn;
152 char *pw;
153};
154
b1218840
AJ
155void init_args(struct main_args *margs);
156void clean_args(struct main_args *margs);
157const char *LogTime(void);
158
159int check_memberof(struct main_args *margs, char *user, char *domain);
160int get_memberof(struct main_args *margs, char *user, char *domain, char *group);
161
162char *get_netbios_name(struct main_args *margs, char *netbios);
163
164int create_gd(struct main_args *margs);
165int create_nd(struct main_args *margs);
f602c423 166int create_ls(struct main_args *margs);
b1218840 167
4ebcf1ce
MM
168size_t get_ldap_hostname_list(struct main_args *margs, struct hstruct **hlist, size_t nhosts, char *domain);
169size_t get_hostname_list(struct hstruct **hlist, size_t nhosts, char *name);
170size_t free_hostname_list(struct hstruct **hlist, size_t nhosts);
b1218840 171
1a22a39e 172#if HAVE_SASL_H || HAVE_SASL_SASL_H || HAVE_SASL_DARWIN
b1218840
AJ
173int tool_sasl_bind(LDAP * ld, char *binddn, char *ssl);
174#endif
175
7451e5ad
MM
176#if HAVE_KRB5
177#define MAX_DOMAINS 16
178#define MAX_SKEW 300
179struct kstruct {
180 krb5_context context;
181 krb5_ccache cc[MAX_DOMAINS];
182 char* mem_ccache[MAX_DOMAINS];
183 int ncache;
184};
40f1fd09 185int krb5_create_cache(char *domain, char* princ);
7451e5ad
MM
186void krb5_cleanup(void);
187#endif
188
b1218840 189#define PROGRAM "kerberos_ldap_group"
f53969cc 190