]> jfr.im git - solanum.git/blob - include/s_newconf.h
Add tests for valid_temp_time
[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 struct Client;
44 struct ConfItem;
45
46 extern rb_dlink_list cluster_conf_list;
47 extern rb_dlink_list oper_conf_list;
48 extern rb_dlink_list server_conf_list;
49 extern rb_dlink_list xline_conf_list;
50 extern rb_dlink_list resv_conf_list;
51 extern rb_dlink_list nd_list;
52 extern rb_dlink_list tgchange_list;
53
54 extern struct _rb_patricia_tree_t *tgchange_tree;
55
56 extern void init_s_newconf(void);
57 extern void clear_s_newconf(void);
58 extern void clear_s_newconf_bans(void);
59
60 typedef struct
61 {
62 char *ip;
63 time_t expiry;
64 rb_patricia_node_t *pnode;
65 rb_dlink_node node;
66 } tgchange;
67
68 void add_tgchange(const char *host);
69 tgchange *find_tgchange(const char *host);
70
71 /* cluster confs */
72 struct remote_conf
73 {
74 char *username;
75 char *host;
76 char *server;
77 int flags;
78 rb_dlink_node node;
79 };
80
81 /* flags used in shared/cluster */
82 #define SHARED_TKLINE 0x00001
83 #define SHARED_PKLINE 0x00002
84 #define SHARED_UNKLINE 0x00004
85 #define SHARED_LOCOPS 0x00008
86 #define SHARED_TXLINE 0x00010
87 #define SHARED_PXLINE 0x00020
88 #define SHARED_UNXLINE 0x00040
89 #define SHARED_TRESV 0x00080
90 #define SHARED_PRESV 0x00100
91 #define SHARED_UNRESV 0x00200
92 #define SHARED_REHASH 0x00400
93 #define SHARED_TDLINE 0x00800
94 #define SHARED_PDLINE 0x01000
95 #define SHARED_UNDLINE 0x02000
96 #define SHARED_GRANT 0x04000
97 #define SHARED_DIE 0x08000
98 #define SHARED_MODULE 0x10000
99
100 #define SHARED_ALL (SHARED_TKLINE | SHARED_PKLINE | SHARED_UNKLINE |\
101 SHARED_PXLINE | SHARED_TXLINE | SHARED_UNXLINE |\
102 SHARED_TRESV | SHARED_PRESV | SHARED_UNRESV | SHARED_GRANT)
103 #define CLUSTER_ALL (SHARED_ALL | SHARED_LOCOPS)
104
105 struct oper_conf
106 {
107 char *name;
108 char *username;
109 char *host;
110 char *passwd;
111 char *certfp;
112
113 int flags;
114 int umodes;
115
116 unsigned int snomask;
117
118 struct PrivilegeSet *privset;
119
120 #ifdef HAVE_LIBCRYPTO
121 char *rsa_pubkey_file;
122 RSA *rsa_pubkey;
123 #endif
124 };
125
126 extern struct remote_conf *make_remote_conf(void);
127 extern void free_remote_conf(struct remote_conf *);
128
129 extern void propagate_generic(struct Client *source_p, const char *command,
130 const char *target, int cap, const char *format, ...);
131 extern void cluster_generic(struct Client *, const char *, int cltype,
132 int cap, const char *format, ...);
133
134 #define OPER_ENCRYPTED 0x00001
135 #define OPER_NEEDSSL 0x80000
136
137 #define OPER_FLAGS 0 /* no oper privs in Client.flags/oper_conf.flags currently */
138
139 #define IsOperConfEncrypted(x) ((x)->flags & OPER_ENCRYPTED)
140 #define IsOperConfNeedSSL(x) ((x)->flags & OPER_NEEDSSL)
141
142 #define HasPrivilege(x, y) ((x)->user != NULL && (x)->user->privset != NULL && privilegeset_in_set((x)->user->privset, (y)))
143 #define MayHavePrivilege(x, y) (HasPrivilege((x), (y)) || (IsOper((x)) && (x)->user != NULL && (x)->user->privset == NULL))
144
145 #define IsOperKill(x) (HasPrivilege((x), "oper:kill"))
146 #define IsOperRemote(x) (HasPrivilege((x), "oper:routing"))
147 #define IsOperUnkline(x) (HasPrivilege((x), "oper:unkline"))
148 #define IsOperN(x) (HasPrivilege((x), "snomask:nick_changes"))
149 #define IsOperK(x) (HasPrivilege((x), "oper:kline"))
150 #define IsOperXline(x) (HasPrivilege((x), "oper:xline"))
151 #define IsOperResv(x) (HasPrivilege((x), "oper:resv"))
152 #define IsOperDie(x) (HasPrivilege((x), "oper:die"))
153 #define IsOperRehash(x) (HasPrivilege((x), "oper:rehash"))
154 #define IsOperHiddenAdmin(x) (HasPrivilege((x), "oper:hidden_admin"))
155 #define IsOperAdmin(x) (HasPrivilege((x), "oper:admin") || HasPrivilege((x), "oper:hidden_admin"))
156 #define IsOperOperwall(x) (HasPrivilege((x), "oper:operwall"))
157 #define IsOperSpy(x) (HasPrivilege((x), "oper:spy"))
158 #define IsOperInvis(x) (HasPrivilege((x), "oper:hidden"))
159 #define IsOperRemoteBan(x) (HasPrivilege((x), "oper:remoteban"))
160 #define IsOperMassNotice(x) (HasPrivilege((x), "oper:mass_notice"))
161 #define IsOperGeneral(x) (MayHavePrivilege((x), "oper:general"))
162
163 #define SeesOper(target, source) (IsOper((target)) && ((!ConfigFileEntry.hide_opers && !HasPrivilege((target), "oper:hidden")) || HasPrivilege((source), "auspex:oper")))
164
165 extern struct oper_conf *make_oper_conf(void);
166 extern void free_oper_conf(struct oper_conf *);
167 extern void clear_oper_conf(void);
168
169 extern struct oper_conf *find_oper_conf(const char *username, const char *host,
170 const char *locip, const char *oname);
171
172 extern const char *get_oper_privs(int flags);
173
174 struct server_conf
175 {
176 char *name;
177 char *connect_host;
178 struct rb_sockaddr_storage connect4;
179 uint16_t dns_query_connect4;
180 struct rb_sockaddr_storage connect6;
181 uint16_t dns_query_connect6;
182 char *passwd;
183 char *spasswd;
184 char *certfp;
185 int port;
186 int flags;
187 int servers;
188 time_t hold;
189
190 int aftype;
191 char *bind_host;
192 struct rb_sockaddr_storage bind4;
193 uint16_t dns_query_bind4;
194 struct rb_sockaddr_storage bind6;
195 uint16_t dns_query_bind6;
196
197 char *class_name;
198 struct Class *class;
199 rb_dlink_node node;
200 };
201
202 #define SERVER_ILLEGAL 0x0001
203 #define SERVER_ENCRYPTED 0x0004
204 #define SERVER_COMPRESSED 0x0008
205 #define SERVER_TB 0x0010
206 #define SERVER_AUTOCONN 0x0020
207 #define SERVER_SSL 0x0040
208 #define SERVER_NO_EXPORT 0x0080
209 #define SERVER_SCTP 0x0100
210
211 #define ServerConfIllegal(x) ((x)->flags & SERVER_ILLEGAL)
212 #define ServerConfEncrypted(x) ((x)->flags & SERVER_ENCRYPTED)
213 #define ServerConfCompressed(x) ((x)->flags & SERVER_COMPRESSED)
214 #define ServerConfTb(x) ((x)->flags & SERVER_TB)
215 #define ServerConfAutoconn(x) ((x)->flags & SERVER_AUTOCONN)
216 #define ServerConfSCTP(x) ((x)->flags & SERVER_SCTP)
217 #define ServerConfSSL(x) ((x)->flags & SERVER_SSL)
218 #define ServerConfNoExport(x) ((x)->flags & SERVER_NO_EXPORT)
219
220 extern struct server_conf *make_server_conf(void);
221 extern void free_server_conf(struct server_conf *);
222 extern void clear_server_conf(void);
223 extern void add_server_conf(struct server_conf *);
224
225 extern struct server_conf *find_server_conf(const char *name);
226
227 extern void attach_server_conf(struct Client *, struct server_conf *);
228 extern void detach_server_conf(struct Client *);
229 extern void set_server_conf_autoconn(struct Client *source_p, const char *name,
230 int newval);
231 extern void disable_server_conf_autoconn(const char *name);
232
233
234 extern struct ConfItem *find_xline(const char *, int);
235 extern struct ConfItem *find_xline_mask(const char *);
236 extern struct ConfItem *find_nick_resv(const char *name);
237 extern struct ConfItem *find_nick_resv_mask(const char *name);
238
239 extern int valid_wild_card_simple(const char *);
240 extern int clean_resv_nick(const char *);
241 time_t valid_temp_time(const char *p);
242
243 struct nd_entry
244 {
245 char name[NICKLEN+1];
246 time_t expire;
247 rb_dlink_node lnode; /* node in ll */
248 };
249
250 extern void add_nd_entry(const char *name);
251 extern void free_nd_entry(struct nd_entry *);
252 extern unsigned long get_nd_count(void);
253
254 #endif
255