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