support.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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#define KERBEROS_LDAP_GROUP_VERSION "1.4.0sq"
34
35#include <cstring>
36
37#if USE_APPLE_KRB5
38#define KERBEROS_APPLE_DEPRECATED(x)
39#endif
40
41#if HAVE_KRB5_H
42#if HAVE_BROKEN_SOLARIS_KRB5_H
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"
45#if defined(__cplusplus)
46#define KRB5INT_BEGIN_DECLS extern "C" {
47#define KRB5INT_END_DECLS
48KRB5INT_BEGIN_DECLS
49#endif
50#endif /* HAVE_BROKEN_SOLARIS_KRB5_H */
51#if HAVE_BROKEN_HEIMDAL_KRB5_H
52extern "C" {
53#include <krb5.h>
54}
55#else
56#include <krb5.h>
57#endif
58#endif /* HAVE_KRB5_H */
59
60#if HAVE_COM_ERR_H
61#include <com_err.h>
62#endif /* HAVE_COM_ERR_H */
63
64#define LDAP_DEPRECATED 1
65#if HAVE_LDAP_REBIND_FUNCTION
66#define LDAP_REFERRALS
67#endif
68#if HAVE_LBER_H
69#include <lber.h>
70#endif
71#if HAVE_LDAP_H
72#include <ldap.h>
73#endif
74#if HAVE_MOZLDAP_LDAP_H
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};
88struct lsstruct {
89 char *lserver;
90 char *domain;
91 struct lsstruct *next;
92};
93
94struct main_args {
95 char *glist;
96 char *ulist;
97 char *tlist;
98 char *nlist;
99 char *llist;
100 char *luser;
101 char *lpass;
102 char *lbind;
103 char *lurl;
104 char *ssl;
106 int AD;
109 char *ddomain;
114};
115
117
118/* the macro overload style is really a gcc-ism */
119#ifdef __GNUC__
120
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); \
130
131#define warn(X...) \
132 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
133 fprintf(stderr,X); \
134
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
143struct hstruct {
144 char *host;
145 int port;
148};
149
151 char *dn;
152 char *pw;
153};
154
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);
166int create_ls(struct main_args *margs);
167
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);
171
172#if HAVE_SASL_H || HAVE_SASL_SASL_H || HAVE_SASL_DARWIN
173int tool_sasl_bind(LDAP * ld, char *binddn, char *ssl);
174#endif
175
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};
185int krb5_create_cache(char *domain, char* princ);
186void krb5_cleanup(void);
187#endif
188
189#define PROGRAM "kerberos_ldap_group"
190
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 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)
SQUIDCEXTERN int log_enabled
Definition: support.h:116
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
Definition: ldap_backend.cc:57
static const char * binddn
#define SQUIDCEXTERN
Definition: squid.h:21
struct gdstruct * next
Definition: support.h:81
char * group
Definition: support.h:79
char * domain
Definition: support.h:80
int port
Definition: support.h:145
char * host
Definition: support.h:144
int priority
Definition: support.h:146
int weight
Definition: support.h:147
char * dn
Definition: support.h:151
char * pw
Definition: support.h:152
struct lsstruct * next
Definition: support.h:91
char * domain
Definition: support.h:90
char * lserver
Definition: support.h:89
char * ulist
Definition: support.h:96
struct lsstruct * lservs
Definition: support.h:112
struct ndstruct * ndoms
Definition: support.h:111
char * ddomain
Definition: support.h:109
char * ssl
Definition: support.h:104
char * nlist
Definition: support.h:98
char * glist
Definition: support.h:95
int AD
Definition: support.h:106
int mdepth
Definition: support.h:107
char * llist
Definition: support.h:99
int rc_allow
Definition: support.h:105
char * luser
Definition: support.h:100
char * lpass
Definition: support.h:101
char * principal
Definition: support.h:113
char * lurl
Definition: support.h:103
char * tlist
Definition: support.h:97
struct gdstruct * groups
Definition: support.h:110
char * lbind
Definition: support.h:102
int nokerberos
Definition: support.h:108
char * domain
Definition: support.h:85
char * netbios
Definition: support.h:84
struct ndstruct * next
Definition: support.h:86

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors