support.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 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
48 KRB5INT_BEGIN_DECLS
49 #endif
50 #endif /* HAVE_BROKEN_SOLARIS_KRB5_H */
51 #if HAVE_BROKEN_HEIMDAL_KRB5_H
52 extern "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 
78 struct gdstruct {
79  char *group;
80  char *domain;
81  struct gdstruct *next;
82 };
83 struct ndstruct {
84  char *netbios;
85  char *domain;
86  struct ndstruct *next;
87 };
88 struct lsstruct {
89  char *lserver;
90  char *domain;
91  struct lsstruct *next;
92 };
93 
94 struct 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;
105  int rc_allow;
106  int AD;
107  int mdepth;
109  char *ddomain;
110  struct gdstruct *groups;
111  struct ndstruct *ndoms;
112  struct lsstruct *lservs;
113  char *principal;
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. */
138 void log(char *format,...);
139 void error(char *format,...);
140 void warn(char *format,...);
141 #endif
142 
143 struct hstruct {
144  char *host;
145  int port;
146  int priority;
147  int weight;
148 };
149 
150 struct ldap_creds {
151  char *dn;
152  char *pw;
153 };
154 
155 void init_args(struct main_args *margs);
156 void clean_args(struct main_args *margs);
157 const char *LogTime(void);
158 
159 int check_memberof(struct main_args *margs, char *user, char *domain);
160 int get_memberof(struct main_args *margs, char *user, char *domain, char *group);
161 
162 char *get_netbios_name(struct main_args *margs, char *netbios);
163 
164 int create_gd(struct main_args *margs);
165 int create_nd(struct main_args *margs);
166 int create_ls(struct main_args *margs);
167 
168 size_t get_ldap_hostname_list(struct main_args *margs, struct hstruct **hlist, size_t nhosts, char *domain);
169 size_t get_hostname_list(struct hstruct **hlist, size_t nhosts, char *name);
170 size_t free_hostname_list(struct hstruct **hlist, size_t nhosts);
171 
172 #if HAVE_SASL_H || HAVE_SASL_SASL_H || HAVE_SASL_DARWIN
173 int 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
179 struct kstruct {
180  krb5_context context;
181  krb5_ccache cc[MAX_DOMAINS];
182  char* mem_ccache[MAX_DOMAINS];
183  int ncache;
184 };
185 int krb5_create_cache(char *domain, char* princ);
186 void krb5_cleanup(void);
187 #endif
188 
189 #define PROGRAM "kerberos_ldap_group"
190 
char * tlist
Definition: support.h:97
const char * LogTime(void)
char * netbios
Definition: support.h:84
static LDAP * ld
Definition: ldap_backend.cc:56
void init_args(struct main_args *margs)
int mdepth
Definition: support.h:107
char * principal
Definition: support.h:113
#define SQUIDCEXTERN
Definition: squid.h:26
void error(char *format,...)
void log(char *format,...)
struct ndstruct * next
Definition: support.h:86
int get_memberof(struct main_args *margs, char *user, char *domain, char *group)
int create_gd(struct main_args *margs)
char * get_netbios_name(struct main_args *margs, char *netbios)
int priority
Definition: support.h:146
char * lserver
Definition: support.h:89
int weight
Definition: support.h:147
size_t get_hostname_list(struct hstruct **hlist, size_t nhosts, char *name)
char * lbind
Definition: support.h:102
char * luser
Definition: support.h:100
void clean_args(struct main_args *margs)
char * glist
Definition: support.h:95
int create_ls(struct main_args *margs)
int create_nd(struct main_args *margs)
static const char * binddn
size_t get_ldap_hostname_list(struct main_args *margs, struct hstruct **hlist, size_t nhosts, char *domain)
int check_memberof(struct main_args *margs, char *user, char *domain)
char * domain
Definition: support.h:90
char * ssl
Definition: support.h:104
struct gdstruct * groups
Definition: support.h:110
char * host
Definition: support.h:144
struct gdstruct * next
Definition: support.h:81
void warn(char *format,...)
int rc_allow
Definition: support.h:105
int AD
Definition: support.h:106
struct lsstruct * next
Definition: support.h:91
char * ddomain
Definition: support.h:109
int nokerberos
Definition: support.h:108
char * domain
Definition: support.h:85
char * lpass
Definition: support.h:101
char * group
Definition: support.h:79
struct ndstruct * ndoms
Definition: support.h:111
char * domain
Definition: support.h:80
SQUIDCEXTERN int log_enabled
Definition: support.h:116
int port
Definition: support.h:145
char * lurl
Definition: support.h:103
struct lsstruct * lservs
Definition: support.h:112
char * nlist
Definition: support.h:98
char * dn
Definition: support.h:151
char * llist
Definition: support.h:99
char * pw
Definition: support.h:152
size_t free_hostname_list(struct hstruct **hlist, size_t nhosts)
char * ulist
Definition: support.h:96

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors