]> git.ipfire.org Git - thirdparty/squid.git/blame - helpers/external_acl/kerberos_ldap_group/support.h
SourceFormat Enforcement
[thirdparty/squid.git] / helpers / external_acl / kerberos_ldap_group / support.h
CommitLineData
b1218840
AJ
1/*
2 * -----------------------------------------------------------------------------
3 *
4 * Author: Markus Moeller (markus_moeller at compuserve.com)
5 *
6 * Copyright (C) 2007 Markus Moeller. All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
21 *
22 * -----------------------------------------------------------------------------
23 */
24
f602c423 25#define KERBEROS_LDAP_GROUP_VERSION "1.3.0sq"
b1218840 26
a05af879 27#if HAVE_STRING_H
b1218840
AJ
28#include <string.h>
29#endif
30
ffe4ffd8 31#if HAVE_KRB5_H
b1218840 32#if HAVE_BROKEN_SOLARIS_KRB5_H
ffe4ffd8
AJ
33#warn "Warning! You have a broken Solaris <krb5.h> system header"
34#warn "http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6837512"
b1218840
AJ
35#if defined(__cplusplus)
36#define KRB5INT_BEGIN_DECLS extern "C" {
37#define KRB5INT_END_DECLS
38KRB5INT_BEGIN_DECLS
39#endif
ffe4ffd8
AJ
40#endif /* HAVE_BROKEN_SOLARIS_KRB5_H */
41#if HAVE_BROKEN_HEIMDAL_KRB5_H
42extern "C" {
43#include <krb5.h>
44}
45#else
b1218840
AJ
46#include <krb5.h>
47#endif
ffe4ffd8
AJ
48#endif /* HAVE_KRB5_H */
49
50#if HAVE_COM_ERR_H
b1218840 51#include <com_err.h>
ffe4ffd8
AJ
52#elif HAVE_HEIMDAL_KERBEROS
53#define error_message(code) krb5_get_err_text(kparam.context,code)
54#endif /* HAVE_COM_ERR_H */
55
b1218840
AJ
56#define LDAP_DEPRECATED 1
57#ifdef HAVE_LDAP_REBIND_FUNCTION
58#define LDAP_REFERRALS
59#endif
60#ifdef HAVE_LBER_H
61#include <lber.h>
62#endif
63#ifdef HAVE_LDAP_H
64#include <ldap.h>
65#endif
66#ifdef HAVE_MOZLDAP_LDAP_H
67#include <mozldap/ldap.h>
68#endif
69
70struct gdstruct {
71 char *group;
72 char *domain;
73 struct gdstruct *next;
74};
75struct ndstruct {
76 char *netbios;
77 char *domain;
78 struct ndstruct *next;
79};
f602c423
MM
80struct lsstruct {
81 char *lserver;
82 char *domain;
83 struct lsstruct *next;
84};
b1218840
AJ
85
86struct main_args {
87 char *glist;
88 char *ulist;
89 char *tlist;
90 char *nlist;
f602c423 91 char *llist;
b1218840
AJ
92 char *luser;
93 char *lpass;
94 char *lbind;
95 char *lurl;
96 char *ssl;
97 int rc_allow;
98 int AD;
99 int mdepth;
100 char *ddomain;
101 struct gdstruct *groups;
102 struct ndstruct *ndoms;
f602c423 103 struct lsstruct *lservs;
b1218840
AJ
104};
105
106SQUIDCEXTERN int log_enabled;
107
108/* the macro overload style is really a gcc-ism */
109#ifdef __GNUC__
110
b1218840
AJ
111#define log(X...) \
112 if (log_enabled) { \
113 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
114 fprintf(stderr,X); \
115 } else (void)0
116
117#define error(X...) \
118 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
119 fprintf(stderr,X); \
2e881a6f 120
b1218840
AJ
121#define warn(X...) \
122 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
123 fprintf(stderr,X); \
2e881a6f 124
b1218840
AJ
125#else /* __GNUC__ */
126
127/* non-GCC compilers can't do the above macro define yet. */
128void log(char *format,...);
129void error(char *format,...);
130void warn(char *format,...);
131#endif
132
b1218840
AJ
133struct hstruct {
134 char *host;
135 int port;
136 int priority;
137 int weight;
138};
139
140struct ldap_creds {
141 char *dn;
142 char *pw;
143};
144
b1218840
AJ
145void init_args(struct main_args *margs);
146void clean_args(struct main_args *margs);
147const char *LogTime(void);
148
149int check_memberof(struct main_args *margs, char *user, char *domain);
150int get_memberof(struct main_args *margs, char *user, char *domain, char *group);
151
152char *get_netbios_name(struct main_args *margs, char *netbios);
153
154int create_gd(struct main_args *margs);
155int create_nd(struct main_args *margs);
f602c423 156int create_ls(struct main_args *margs);
b1218840 157
bec91ba0 158#ifdef HAVE_KRB5
b1218840
AJ
159int krb5_create_cache(struct main_args *margs, char *domain);
160void krb5_cleanup(void);
bec91ba0 161#endif
b1218840
AJ
162
163int get_ldap_hostname_list(struct main_args *margs, struct hstruct **hlist, int nhosts, char *domain);
164int get_hostname_list(struct main_args *margs, struct hstruct **hlist, int nhosts, char *name);
165int free_hostname_list(struct hstruct **hlist, int nhosts);
166
167#if defined(HAVE_SASL_H) || defined(HAVE_SASL_SASL_H) || defined(HAVE_SASL_DARWIN)
168int tool_sasl_bind(LDAP * ld, char *binddn, char *ssl);
169#endif
170
171#define PROGRAM "kerberos_ldap_group"