]> jfr.im git - solanum.git/blob - include/s_newconf.h
ircd/authproc.c: avoid crash on lack of any configured DNSBLs
[solanum.git] / include / s_newconf.h
1 /*
2 * ircd-ratbox: an advanced Internet Relay Chat Daemon(ircd).
3 * s_newconf.h: code for dealing with conf stuff
4 *
5 * Copyright (C) 2004 Lee Hardy <lee@leeh.co.uk>
6 * Copyright (C) 2004 ircd-ratbox development team
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * 1.Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 * 2.Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3.The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #ifndef INCLUDED_s_newconf_h
34 #define INCLUDED_s_newconf_h
35
36 #include "setup.h"
37 #include "privilege.h"
38
39 #ifdef HAVE_LIBCRYPTO
40 #include <openssl/rsa.h>
41 #endif
42
43 #define MAX_TEMP_TIME (52 * 7 * 24 * 60 * 60)
44
45 struct Client;
46 struct ConfItem;
47
48 extern rb_dlink_list cluster_conf_list;
49 extern rb_dlink_list oper_conf_list;
50 extern rb_dlink_list server_conf_list;
51 extern rb_dlink_list xline_conf_list;
52 extern rb_dlink_list resv_conf_list;
53 extern rb_dlink_list nd_list;
54 extern rb_dlink_list tgchange_list;
55
56 extern struct _rb_patricia_tree_t *tgchange_tree;
57
58 extern void init_s_newconf(void);
59 extern void clear_s_newconf(void);
60 extern void clear_s_newconf_bans(void);
61
62 typedef struct
63 {
64 char *ip;
65 time_t expiry;
66 rb_patricia_node_t *pnode;
67 rb_dlink_node node;
68 } tgchange;
69
70 void add_tgchange(const char *host);
71 tgchange *find_tgchange(const char *host);
72
73 /* cluster confs */
74 struct remote_conf
75 {
76 char *username;
77 char *host;
78 char *server;
79 int flags;
80 rb_dlink_node node;
81 };
82
83 /* flags used in shared/cluster */
84 #define SHARED_TKLINE 0x00001
85 #define SHARED_PKLINE 0x00002
86 #define SHARED_UNKLINE 0x00004
87 #define SHARED_LOCOPS 0x00008
88 #define SHARED_TXLINE 0x00010
89 #define SHARED_PXLINE 0x00020
90 #define SHARED_UNXLINE 0x00040
91 #define SHARED_TRESV 0x00080
92 #define SHARED_PRESV 0x00100
93 #define SHARED_UNRESV 0x00200
94 #define SHARED_REHASH 0x00400
95 #define SHARED_TDLINE 0x00800
96 #define SHARED_PDLINE 0x01000
97 #define SHARED_UNDLINE 0x02000
98 #define SHARED_GRANT 0x04000
99 #define SHARED_DIE 0x08000
100 #define SHARED_MODULE 0x10000
101
102 #define SHARED_ALL (SHARED_TKLINE | SHARED_PKLINE | SHARED_UNKLINE |\
103 SHARED_PXLINE | SHARED_TXLINE | SHARED_UNXLINE |\
104 SHARED_TRESV | SHARED_PRESV | SHARED_UNRESV | SHARED_GRANT)
105 #define CLUSTER_ALL (SHARED_ALL | SHARED_LOCOPS)
106
107 struct oper_conf
108 {
109 char *name;
110 char *username;
111 char *host;
112 char *passwd;
113 char *certfp;
114
115 int flags;
116 int umodes;
117
118 unsigned int snomask;
119
120 struct PrivilegeSet *privset;
121
122 #ifdef HAVE_LIBCRYPTO
123 char *rsa_pubkey_file;
124 #if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
125 EVP_PKEY *rsa_pubkey;
126 #else
127 RSA *rsa_pubkey;
128 #endif
129 #endif
130 };
131
132 extern struct remote_conf *make_remote_conf(void);
133 extern void free_remote_conf(struct remote_conf *);
134
135 extern void propagate_generic(struct Client *source_p, const char *command,
136 const char *target, int cap, const char *format, ...);
137 extern void cluster_generic(struct Client *, const char *, int cltype,
138 int cap, const char *format, ...);
139
140 #define OPER_ENCRYPTED 0x00001
141 #define OPER_NEEDSSL 0x80000
142
143 #define OPER_FLAGS 0 /* no oper privs in Client.flags/oper_conf.flags currently */
144
145 #define IsOperConfEncrypted(x) ((x)->flags & OPER_ENCRYPTED)
146 #define IsOperConfNeedSSL(x) ((x)->flags & OPER_NEEDSSL)
147
148 #define HasPrivilege(x, y) ((x)->user != NULL && (x)->user->privset != NULL && privilegeset_in_set((x)->user->privset, (y)))
149 #define MayHavePrivilege(x, y) (HasPrivilege((x), (y)) || (IsOper((x)) && (x)->user != NULL && (x)->user->privset == NULL))
150
151 #define IsOperKill(x) (HasPrivilege((x), "oper:kill"))
152 #define IsOperRemote(x) (HasPrivilege((x), "oper:routing"))
153 #define IsOperUnkline(x) (HasPrivilege((x), "oper:unkline"))
154 #define IsOperN(x) (HasPrivilege((x), "snomask:nick_changes"))
155 #define IsOperK(x) (HasPrivilege((x), "oper:kline"))
156 #define IsOperXline(x) (HasPrivilege((x), "oper:xline"))
157 #define IsOperResv(x) (HasPrivilege((x), "oper:resv"))
158 #define IsOperDie(x) (HasPrivilege((x), "oper:die"))
159 #define IsOperRehash(x) (HasPrivilege((x), "oper:rehash"))
160 #define IsOperHiddenAdmin(x) (HasPrivilege((x), "oper:hidden_admin"))
161 #define IsOperAdmin(x) (HasPrivilege((x), "oper:admin") || HasPrivilege((x), "oper:hidden_admin"))
162 #define IsOperOperwall(x) (HasPrivilege((x), "oper:operwall"))
163 #define IsOperSpy(x) (HasPrivilege((x), "oper:spy"))
164 #define IsOperInvis(x) (HasPrivilege((x), "oper:hidden"))
165 #define IsOperRemoteBan(x) (HasPrivilege((x), "oper:remoteban"))
166 #define IsOperMassNotice(x) (HasPrivilege((x), "oper:mass_notice"))
167 #define IsOperGeneral(x) (MayHavePrivilege((x), "oper:general"))
168
169 #define SeesOper(target, source) (IsOper((target)) && ((!ConfigFileEntry.hide_opers && !HasPrivilege((target), "oper:hidden")) || HasPrivilege((source), "auspex:oper")))
170
171 extern struct oper_conf *make_oper_conf(void);
172 extern void free_oper_conf(struct oper_conf *);
173 extern void clear_oper_conf(void);
174
175 extern struct oper_conf *find_oper_conf(const char *username, const char *host,
176 const char *locip, const char *oname);
177
178 extern const char *get_oper_privs(int flags);
179
180 struct server_conf
181 {
182 char *name;
183 char *connect_host;
184 struct rb_sockaddr_storage connect4;
185 uint16_t dns_query_connect4;
186 struct rb_sockaddr_storage connect6;
187 uint16_t dns_query_connect6;
188 char *passwd;
189 char *spasswd;
190 char *certfp;
191 int port;
192 int flags;
193 int servers;
194 time_t hold;
195
196 int aftype;
197 char *bind_host;
198 struct rb_sockaddr_storage bind4;
199 uint16_t dns_query_bind4;
200 struct rb_sockaddr_storage bind6;
201 uint16_t dns_query_bind6;
202
203 char *class_name;
204 struct Class *class;
205 rb_dlink_node node;
206 };
207
208 #define SERVER_ILLEGAL 0x0001
209 #define SERVER_ENCRYPTED 0x0004
210 #define SERVER_TB 0x0010
211 #define SERVER_AUTOCONN 0x0020
212 #define SERVER_SSL 0x0040
213 #define SERVER_NO_EXPORT 0x0080
214 #define SERVER_SCTP 0x0100
215
216 #define ServerConfIllegal(x) ((x)->flags & SERVER_ILLEGAL)
217 #define ServerConfEncrypted(x) ((x)->flags & SERVER_ENCRYPTED)
218 #define ServerConfTb(x) ((x)->flags & SERVER_TB)
219 #define ServerConfAutoconn(x) ((x)->flags & SERVER_AUTOCONN)
220 #define ServerConfSCTP(x) ((x)->flags & SERVER_SCTP)
221 #define ServerConfSSL(x) ((x)->flags & SERVER_SSL)
222 #define ServerConfNoExport(x) ((x)->flags & SERVER_NO_EXPORT)
223
224 extern struct server_conf *make_server_conf(void);
225 extern void free_server_conf(struct server_conf *);
226 extern void clear_server_conf(void);
227 extern void add_server_conf(struct server_conf *);
228
229 extern struct server_conf *find_server_conf(const char *name);
230
231 extern void attach_server_conf(struct Client *, struct server_conf *);
232 extern void detach_server_conf(struct Client *);
233 extern void set_server_conf_autoconn(struct Client *source_p, const char *name,
234 int newval);
235 extern void disable_server_conf_autoconn(const char *name);
236
237
238 extern struct ConfItem *find_xline(const char *, int);
239 extern struct ConfItem *find_xline_mask(const char *);
240 extern struct ConfItem *find_nick_resv(const char *name);
241 extern struct ConfItem *find_nick_resv_mask(const char *name);
242
243 extern int valid_wild_card_simple(const char *);
244 extern int clean_resv_nick(const char *);
245 time_t valid_temp_time(const char *p);
246
247 struct nd_entry
248 {
249 char name[NICKLEN+1];
250 time_t expire;
251 rb_dlink_node lnode; /* node in ll */
252 };
253
254 extern void add_nd_entry(const char *name);
255 extern void free_nd_entry(struct nd_entry *);
256 extern unsigned long get_nd_count(void);
257
258 #endif
259