]> git.ipfire.org Git - thirdparty/squid.git/blame - src/acl/external/kerberos_ldap_group/support.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / acl / external / kerberos_ldap_group / support.h
CommitLineData
ca02e0ec 1/*
4ac4a490 2 * Copyright (C) 1996-2017 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;
b1218840
AJ
113};
114
115SQUIDCEXTERN int log_enabled;
116
117/* the macro overload style is really a gcc-ism */
118#ifdef __GNUC__
119
b1218840
AJ
120#define log(X...) \
121 if (log_enabled) { \
122 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
123 fprintf(stderr,X); \
124 } else (void)0
125
126#define error(X...) \
127 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
128 fprintf(stderr,X); \
f17a1766 129
b1218840
AJ
130#define warn(X...) \
131 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
132 fprintf(stderr,X); \
f17a1766 133
b1218840
AJ
134#else /* __GNUC__ */
135
136/* non-GCC compilers can't do the above macro define yet. */
137void log(char *format,...);
138void error(char *format,...);
139void warn(char *format,...);
140#endif
141
b1218840
AJ
142struct hstruct {
143 char *host;
144 int port;
145 int priority;
146 int weight;
147};
148
149struct ldap_creds {
150 char *dn;
151 char *pw;
152};
153
b1218840
AJ
154void init_args(struct main_args *margs);
155void clean_args(struct main_args *margs);
156const char *LogTime(void);
157
158int check_memberof(struct main_args *margs, char *user, char *domain);
159int get_memberof(struct main_args *margs, char *user, char *domain, char *group);
160
161char *get_netbios_name(struct main_args *margs, char *netbios);
162
163int create_gd(struct main_args *margs);
164int create_nd(struct main_args *margs);
f602c423 165int create_ls(struct main_args *margs);
b1218840 166
4ebcf1ce
MM
167size_t get_ldap_hostname_list(struct main_args *margs, struct hstruct **hlist, size_t nhosts, char *domain);
168size_t get_hostname_list(struct hstruct **hlist, size_t nhosts, char *name);
169size_t free_hostname_list(struct hstruct **hlist, size_t nhosts);
b1218840 170
1a22a39e 171#if HAVE_SASL_H || HAVE_SASL_SASL_H || HAVE_SASL_DARWIN
b1218840
AJ
172int tool_sasl_bind(LDAP * ld, char *binddn, char *ssl);
173#endif
174
7451e5ad
MM
175#if HAVE_KRB5
176#define MAX_DOMAINS 16
177#define MAX_SKEW 300
178struct kstruct {
179 krb5_context context;
180 krb5_ccache cc[MAX_DOMAINS];
181 char* mem_ccache[MAX_DOMAINS];
182 int ncache;
183};
184int krb5_create_cache(char *domain);
185void krb5_cleanup(void);
186#endif
187
b1218840 188#define PROGRAM "kerberos_ldap_group"
f53969cc 189