1 |
|
/* |
2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
< |
* conf.c: Configuration file functions. |
2 |
> |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
4 |
> |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
|
* USA |
20 |
< |
* |
21 |
< |
* $Id$ |
20 |
> |
*/ |
21 |
> |
|
22 |
> |
/*! \file conf.c |
23 |
> |
* \brief Configuration file functions. |
24 |
> |
* \version $Id$ |
25 |
|
*/ |
26 |
|
|
27 |
|
#include "stdinc.h" |
28 |
|
#include "list.h" |
29 |
|
#include "ircd_defs.h" |
30 |
|
#include "conf.h" |
31 |
< |
#include "s_serv.h" |
31 |
> |
#include "server.h" |
32 |
|
#include "resv.h" |
33 |
|
#include "channel.h" |
34 |
|
#include "client.h" |
35 |
|
#include "event.h" |
34 |
– |
#include "hook.h" |
36 |
|
#include "irc_string.h" |
37 |
|
#include "s_bsd.h" |
38 |
|
#include "ircd.h" |
43 |
|
#include "fdlist.h" |
44 |
|
#include "log.h" |
45 |
|
#include "send.h" |
45 |
– |
#include "s_gline.h" |
46 |
|
#include "memory.h" |
47 |
|
#include "mempool.h" |
48 |
< |
#include "irc_res.h" |
48 |
> |
#include "res.h" |
49 |
|
#include "userhost.h" |
50 |
< |
#include "s_user.h" |
50 |
> |
#include "user.h" |
51 |
|
#include "channel_mode.h" |
52 |
|
#include "parse.h" |
53 |
< |
#include "s_misc.h" |
53 |
> |
#include "misc.h" |
54 |
|
#include "conf_db.h" |
55 |
|
#include "conf_class.h" |
56 |
+ |
#include "motd.h" |
57 |
|
|
57 |
– |
struct config_server_hide ConfigServerHide; |
58 |
|
|
59 |
|
/* general conf items link list root, other than k lines etc. */ |
60 |
|
dlink_list service_items = { NULL, NULL, 0 }; |
64 |
|
dlink_list uconf_items = { NULL, NULL, 0 }; |
65 |
|
dlink_list xconf_items = { NULL, NULL, 0 }; |
66 |
|
dlink_list nresv_items = { NULL, NULL, 0 }; |
67 |
< |
dlink_list temporary_resv = { NULL, NULL, 0 }; |
67 |
> |
dlink_list cresv_items = { NULL, NULL, 0 }; |
68 |
|
|
69 |
|
extern unsigned int lineno; |
70 |
|
extern char linebuf[]; |
71 |
|
extern char conffilebuf[IRCD_BUFSIZE]; |
72 |
|
extern int yyparse(); /* defined in y.tab.c */ |
73 |
|
|
74 |
– |
struct conf_parser_context conf_parser_ctx = { 0, 0, NULL }; |
75 |
– |
|
74 |
|
/* internally defined functions */ |
75 |
|
static void read_conf(FILE *); |
76 |
|
static void clear_out_old_conf(void); |
93 |
|
struct ip_entry |
94 |
|
{ |
95 |
|
struct irc_ssaddr ip; |
96 |
< |
unsigned int count; |
97 |
< |
time_t last_attempt; |
96 |
> |
unsigned int count; /**< Number of registered users using this IP */ |
97 |
> |
unsigned int connection_count; /**< Number of connections from this IP in the last throttle_time duration */ |
98 |
> |
time_t last_attempt; /**< The last time someone connected from this IP */ |
99 |
|
struct ip_entry *next; |
100 |
|
}; |
101 |
|
|
121 |
|
|
122 |
|
conf->dns_pending = 0; |
123 |
|
|
124 |
< |
if (addr != NULL) |
124 |
> |
if (addr) |
125 |
|
memcpy(&conf->addr, addr, sizeof(conf->addr)); |
126 |
|
else |
127 |
|
conf->dns_failed = 1; |
146 |
|
struct MaskItem * |
147 |
|
conf_make(enum maskitem_type type) |
148 |
|
{ |
149 |
< |
struct MaskItem *conf = MyMalloc(sizeof(*conf)); |
149 |
> |
struct MaskItem *conf = MyCalloc(sizeof(*conf)); |
150 |
|
dlink_list *list = NULL; |
151 |
|
|
152 |
|
conf->type = type; |
172 |
|
|
173 |
|
if (conf->dns_pending) |
174 |
|
delete_resolver_queries(conf); |
175 |
< |
if (conf->passwd != NULL) |
175 |
> |
if (conf->passwd) |
176 |
|
memset(conf->passwd, 0, strlen(conf->passwd)); |
177 |
< |
if (conf->spasswd != NULL) |
177 |
> |
if (conf->spasswd) |
178 |
|
memset(conf->spasswd, 0, strlen(conf->spasswd)); |
179 |
|
|
180 |
|
conf->class = NULL; |
182 |
|
MyFree(conf->passwd); |
183 |
|
MyFree(conf->spasswd); |
184 |
|
MyFree(conf->reason); |
185 |
+ |
MyFree(conf->certfp); |
186 |
|
MyFree(conf->user); |
187 |
|
MyFree(conf->host); |
188 |
|
#ifdef HAVE_LIBCRYPTO |
194 |
|
DLINK_FOREACH_SAFE(ptr, ptr_next, conf->hub_list.head) |
195 |
|
{ |
196 |
|
MyFree(ptr->data); |
197 |
+ |
dlinkDelete(ptr, &conf->hub_list); |
198 |
|
free_dlink_node(ptr); |
199 |
|
} |
200 |
|
|
201 |
|
DLINK_FOREACH_SAFE(ptr, ptr_next, conf->leaf_list.head) |
202 |
|
{ |
203 |
|
MyFree(ptr->data); |
204 |
+ |
dlinkDelete(ptr, &conf->leaf_list); |
205 |
|
free_dlink_node(ptr); |
206 |
|
} |
207 |
|
|
209 |
|
{ |
210 |
|
struct exempt *exptr = ptr->data; |
211 |
|
|
212 |
+ |
dlinkDelete(ptr, &conf->exempt_list); |
213 |
|
MyFree(exptr->name); |
214 |
|
MyFree(exptr->user); |
215 |
|
MyFree(exptr->host); |
219 |
|
MyFree(conf); |
220 |
|
} |
221 |
|
|
219 |
– |
static const struct shared_flags |
220 |
– |
{ |
221 |
– |
const unsigned int type; |
222 |
– |
const unsigned char letter; |
223 |
– |
} flag_table[] = { |
224 |
– |
{ SHARED_KLINE, 'K' }, |
225 |
– |
{ SHARED_UNKLINE, 'U' }, |
226 |
– |
{ SHARED_XLINE, 'X' }, |
227 |
– |
{ SHARED_UNXLINE, 'Y' }, |
228 |
– |
{ SHARED_RESV, 'Q' }, |
229 |
– |
{ SHARED_UNRESV, 'R' }, |
230 |
– |
{ SHARED_LOCOPS, 'L' }, |
231 |
– |
{ SHARED_DLINE, 'D' }, |
232 |
– |
{ SHARED_UNDLINE, 'E' }, |
233 |
– |
{ 0, '\0' } |
234 |
– |
}; |
235 |
– |
|
236 |
– |
/* |
237 |
– |
* inputs - pointer to client requesting confitem report |
238 |
– |
* - ConfType to report |
239 |
– |
* output - none |
240 |
– |
* side effects - |
241 |
– |
*/ |
242 |
– |
void |
243 |
– |
report_confitem_types(struct Client *source_p, enum maskitem_type type) |
244 |
– |
{ |
245 |
– |
dlink_node *ptr = NULL, *dptr = NULL; |
246 |
– |
struct MaskItem *conf = NULL; |
247 |
– |
const struct ClassItem *class = NULL; |
248 |
– |
const struct shared_flags *shared = NULL; |
249 |
– |
char buf[12]; |
250 |
– |
char *p = NULL; |
251 |
– |
|
252 |
– |
switch (type) |
253 |
– |
{ |
254 |
– |
case CONF_XLINE: |
255 |
– |
DLINK_FOREACH(ptr, xconf_items.head) |
256 |
– |
{ |
257 |
– |
conf = ptr->data; |
258 |
– |
|
259 |
– |
sendto_one(source_p, form_str(RPL_STATSXLINE), |
260 |
– |
me.name, source_p->name, |
261 |
– |
conf->until ? 'x': 'X', conf->count, |
262 |
– |
conf->name, conf->reason); |
263 |
– |
} |
264 |
– |
break; |
265 |
– |
|
266 |
– |
case CONF_ULINE: |
267 |
– |
shared = flag_table; |
268 |
– |
DLINK_FOREACH(ptr, uconf_items.head) |
269 |
– |
{ |
270 |
– |
conf = ptr->data; |
271 |
– |
|
272 |
– |
p = buf; |
273 |
– |
|
274 |
– |
*p++ = 'c'; |
275 |
– |
for (; shared->type; ++shared) |
276 |
– |
if (shared->type & conf->flags) |
277 |
– |
*p++ = shared->letter; |
278 |
– |
else |
279 |
– |
*p++ = ToLower(shared->letter); |
280 |
– |
|
281 |
– |
sendto_one(source_p, form_str(RPL_STATSULINE), |
282 |
– |
me.name, source_p->name, conf->name, |
283 |
– |
conf->user?conf->user: "*", |
284 |
– |
conf->host?conf->host: "*", buf); |
285 |
– |
} |
286 |
– |
|
287 |
– |
shared = flag_table; |
288 |
– |
DLINK_FOREACH(ptr, cluster_items.head) |
289 |
– |
{ |
290 |
– |
conf = ptr->data; |
291 |
– |
|
292 |
– |
p = buf; |
293 |
– |
|
294 |
– |
*p++ = 'C'; |
295 |
– |
for (; shared->type; ++shared) |
296 |
– |
if (shared->type & conf->flags) |
297 |
– |
*p++ = shared->letter; |
298 |
– |
else |
299 |
– |
*p++ = ToLower(shared->letter); |
300 |
– |
|
301 |
– |
sendto_one(source_p, form_str(RPL_STATSULINE), |
302 |
– |
me.name, source_p->name, conf->name, |
303 |
– |
"*", "*", buf); |
304 |
– |
} |
305 |
– |
|
306 |
– |
break; |
307 |
– |
|
308 |
– |
case CONF_OPER: |
309 |
– |
DLINK_FOREACH(ptr, oconf_items.head) |
310 |
– |
{ |
311 |
– |
conf = ptr->data; |
312 |
– |
|
313 |
– |
/* Don't allow non opers to see oper privs */ |
314 |
– |
if (HasUMode(source_p, UMODE_OPER)) |
315 |
– |
sendto_one(source_p, form_str(RPL_STATSOLINE), |
316 |
– |
me.name, source_p->name, 'O', conf->user, conf->host, |
317 |
– |
conf->name, oper_privs_as_string(conf->port), |
318 |
– |
conf->class ? conf->class->name : "<default>"); |
319 |
– |
else |
320 |
– |
sendto_one(source_p, form_str(RPL_STATSOLINE), |
321 |
– |
me.name, source_p->name, 'O', conf->user, conf->host, |
322 |
– |
conf->name, "0", |
323 |
– |
conf->class ? conf->class->name : "<default>"); |
324 |
– |
} |
325 |
– |
break; |
326 |
– |
|
327 |
– |
case CONF_CLASS: |
328 |
– |
DLINK_FOREACH(ptr, class_get_list()->head) |
329 |
– |
{ |
330 |
– |
class = ptr->data; |
331 |
– |
sendto_one(source_p, form_str(RPL_STATSYLINE), |
332 |
– |
me.name, source_p->name, 'Y', |
333 |
– |
class->name, class->ping_freq, |
334 |
– |
class->con_freq, |
335 |
– |
class->max_total, class->max_sendq, |
336 |
– |
class->max_recvq, |
337 |
– |
class->ref_count, |
338 |
– |
class->number_per_cidr, class->cidr_bitlen_ipv4, |
339 |
– |
class->number_per_cidr, class->cidr_bitlen_ipv6, |
340 |
– |
class->active ? "active" : "disabled"); |
341 |
– |
} |
342 |
– |
break; |
343 |
– |
|
344 |
– |
case CONF_SERVICE: |
345 |
– |
DLINK_FOREACH(ptr, service_items.head) |
346 |
– |
{ |
347 |
– |
conf = ptr->data; |
348 |
– |
sendto_one(source_p, form_str(RPL_STATSSERVICE), |
349 |
– |
me.name, source_p->name, 'S', "*", conf->name, 0, 0); |
350 |
– |
} |
351 |
– |
break; |
352 |
– |
|
353 |
– |
case CONF_SERVER: |
354 |
– |
DLINK_FOREACH(ptr, server_items.head) |
355 |
– |
{ |
356 |
– |
p = buf; |
357 |
– |
conf = ptr->data; |
358 |
– |
|
359 |
– |
buf[0] = '\0'; |
360 |
– |
|
361 |
– |
if (IsConfAllowAutoConn(conf)) |
362 |
– |
*p++ = 'A'; |
363 |
– |
if (IsConfSSL(conf)) |
364 |
– |
*p++ = 'S'; |
365 |
– |
if (buf[0] == '\0') |
366 |
– |
*p++ = '*'; |
367 |
– |
|
368 |
– |
*p = '\0'; |
369 |
– |
|
370 |
– |
/* |
371 |
– |
* Allow admins to see actual ips unless hide_server_ips is enabled |
372 |
– |
*/ |
373 |
– |
if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN)) |
374 |
– |
sendto_one(source_p, form_str(RPL_STATSCLINE), |
375 |
– |
me.name, source_p->name, 'C', conf->host, |
376 |
– |
buf, conf->name, conf->port, |
377 |
– |
conf->class ? conf->class->name : "<default>"); |
378 |
– |
else |
379 |
– |
sendto_one(source_p, form_str(RPL_STATSCLINE), |
380 |
– |
me.name, source_p->name, 'C', |
381 |
– |
"*@127.0.0.1", buf, conf->name, conf->port, |
382 |
– |
conf->class ? conf->class->name : "<default>"); |
383 |
– |
} |
384 |
– |
break; |
385 |
– |
|
386 |
– |
case CONF_HUB: |
387 |
– |
DLINK_FOREACH(ptr, server_items.head) |
388 |
– |
{ |
389 |
– |
conf = ptr->data; |
390 |
– |
|
391 |
– |
DLINK_FOREACH(dptr, conf->hub_list.head) |
392 |
– |
sendto_one(source_p, form_str(RPL_STATSHLINE), me.name, |
393 |
– |
source_p->name, 'H', dptr->data, conf->name, 0, "*"); |
394 |
– |
} |
395 |
– |
|
396 |
– |
DLINK_FOREACH(ptr, server_items.head) |
397 |
– |
{ |
398 |
– |
conf = ptr->data; |
399 |
– |
|
400 |
– |
DLINK_FOREACH(dptr, conf->leaf_list.head) |
401 |
– |
sendto_one(source_p, form_str(RPL_STATSLLINE), me.name, |
402 |
– |
source_p->name, 'L', dptr->data, conf->name, 0, "*"); |
403 |
– |
} |
404 |
– |
|
405 |
– |
break; |
406 |
– |
|
407 |
– |
default: |
408 |
– |
break; |
409 |
– |
} |
410 |
– |
} |
411 |
– |
|
222 |
|
/* check_client() |
223 |
|
* |
224 |
|
* inputs - pointer to client |
236 |
|
check_client(struct Client *source_p) |
237 |
|
{ |
238 |
|
int i; |
239 |
< |
|
239 |
> |
|
240 |
|
if ((i = verify_access(source_p))) |
241 |
< |
ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]", |
241 |
> |
ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]", |
242 |
|
source_p->name, source_p->sockhost); |
243 |
|
|
244 |
|
switch (i) |
246 |
|
case TOO_MANY: |
247 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE, |
248 |
|
"Too many on IP for %s (%s).", |
249 |
< |
get_client_name(source_p, SHOW_IP), |
250 |
< |
source_p->sockhost); |
249 |
> |
get_client_name(source_p, SHOW_IP), |
250 |
> |
source_p->sockhost); |
251 |
|
ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.", |
252 |
< |
get_client_name(source_p, SHOW_IP)); |
252 |
> |
get_client_name(source_p, SHOW_IP)); |
253 |
|
++ServerStats.is_ref; |
254 |
< |
exit_client(source_p, &me, "No more connections allowed on that IP"); |
254 |
> |
exit_client(source_p, "No more connections allowed on that IP"); |
255 |
|
break; |
256 |
|
|
257 |
|
case I_LINE_FULL: |
258 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE, |
259 |
|
"auth{} block is full for %s (%s).", |
260 |
< |
get_client_name(source_p, SHOW_IP), |
261 |
< |
source_p->sockhost); |
260 |
> |
get_client_name(source_p, SHOW_IP), |
261 |
> |
source_p->sockhost); |
262 |
|
ilog(LOG_TYPE_IRCD, "Too many connections from %s.", |
263 |
< |
get_client_name(source_p, SHOW_IP)); |
263 |
> |
get_client_name(source_p, SHOW_IP)); |
264 |
|
++ServerStats.is_ref; |
265 |
< |
exit_client(source_p, &me, |
456 |
< |
"No more connections allowed in your connection class"); |
265 |
> |
exit_client(source_p, "No more connections allowed in your connection class"); |
266 |
|
break; |
267 |
|
|
268 |
|
case NOT_AUTHORIZED: |
270 |
|
/* jdc - lists server name & port connections are on */ |
271 |
|
/* a purely cosmetical change */ |
272 |
|
sendto_realops_flags(UMODE_UNAUTH, L_ALL, SEND_NOTICE, |
273 |
< |
"Unauthorized client connection from %s [%s] on [%s/%u].", |
274 |
< |
get_client_name(source_p, SHOW_IP), |
275 |
< |
source_p->sockhost, |
276 |
< |
source_p->localClient->listener->name, |
277 |
< |
source_p->localClient->listener->port); |
273 |
> |
"Unauthorized client connection from %s [%s] on [%s/%u].", |
274 |
> |
get_client_name(source_p, SHOW_IP), |
275 |
> |
source_p->sockhost, |
276 |
> |
source_p->localClient->listener->name, |
277 |
> |
source_p->localClient->listener->port); |
278 |
|
ilog(LOG_TYPE_IRCD, |
279 |
< |
"Unauthorized client connection from %s on [%s/%u].", |
280 |
< |
get_client_name(source_p, SHOW_IP), |
281 |
< |
source_p->localClient->listener->name, |
282 |
< |
source_p->localClient->listener->port); |
279 |
> |
"Unauthorized client connection from %s on [%s/%u].", |
280 |
> |
get_client_name(source_p, SHOW_IP), |
281 |
> |
source_p->localClient->listener->name, |
282 |
> |
source_p->localClient->listener->port); |
283 |
|
|
284 |
< |
exit_client(source_p, &me, "You are not authorized to use this server"); |
284 |
> |
exit_client(source_p, "You are not authorized to use this server"); |
285 |
|
break; |
286 |
|
|
287 |
|
case BANNED_CLIENT: |
288 |
< |
exit_client(source_p, &me, "Banned"); |
288 |
> |
exit_client(source_p, "Banned"); |
289 |
|
++ServerStats.is_ref; |
290 |
|
break; |
291 |
|
|
306 |
|
static int |
307 |
|
verify_access(struct Client *client_p) |
308 |
|
{ |
309 |
< |
struct MaskItem *conf = NULL, *rkconf = NULL; |
310 |
< |
char non_ident[USERLEN + 1] = { '~', '\0' }; |
309 |
> |
struct MaskItem *conf = NULL; |
310 |
> |
char non_ident[USERLEN + 1] = "~"; |
311 |
|
|
312 |
|
if (IsGotId(client_p)) |
313 |
|
{ |
314 |
|
conf = find_address_conf(client_p->host, client_p->username, |
315 |
< |
&client_p->localClient->ip, |
316 |
< |
client_p->localClient->aftype, |
315 |
> |
&client_p->localClient->ip, |
316 |
> |
client_p->localClient->aftype, |
317 |
|
client_p->localClient->passwd); |
318 |
|
} |
319 |
|
else |
320 |
|
{ |
321 |
< |
strlcpy(non_ident+1, client_p->username, sizeof(non_ident)-1); |
321 |
> |
strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1); |
322 |
|
conf = find_address_conf(client_p->host,non_ident, |
323 |
< |
&client_p->localClient->ip, |
324 |
< |
client_p->localClient->aftype, |
325 |
< |
client_p->localClient->passwd); |
323 |
> |
&client_p->localClient->ip, |
324 |
> |
client_p->localClient->aftype, |
325 |
> |
client_p->localClient->passwd); |
326 |
|
} |
327 |
|
|
328 |
< |
if (conf != NULL) |
328 |
> |
if (conf) |
329 |
|
{ |
330 |
|
if (IsConfClient(conf)) |
331 |
|
{ |
332 |
|
if (IsConfRedir(conf)) |
333 |
|
{ |
334 |
< |
sendto_one(client_p, form_str(RPL_REDIR), |
335 |
< |
me.name, client_p->name, |
336 |
< |
conf->name ? conf->name : "", |
337 |
< |
conf->port); |
529 |
< |
return(NOT_AUTHORIZED); |
334 |
> |
sendto_one_numeric(client_p, &me, RPL_REDIR, |
335 |
> |
conf->name ? conf->name : "", |
336 |
> |
conf->port); |
337 |
> |
return NOT_AUTHORIZED; |
338 |
|
} |
339 |
|
|
340 |
|
if (IsConfDoIdentd(conf)) |
341 |
< |
SetNeedId(client_p); |
341 |
> |
SetNeedId(client_p); |
342 |
|
|
343 |
|
/* Thanks for spoof idea amm */ |
344 |
|
if (IsConfDoSpoofIp(conf)) |
348 |
|
"%s spoofing: %s as %s", |
349 |
|
client_p->name, client_p->host, conf->name); |
350 |
|
strlcpy(client_p->host, conf->name, sizeof(client_p->host)); |
351 |
< |
SetIPSpoof(client_p); |
351 |
> |
AddFlag(client_p, FLAGS_IP_SPOOFING | FLAGS_AUTH_SPOOF); |
352 |
|
} |
353 |
|
|
354 |
< |
return(attach_iline(client_p, conf)); |
354 |
> |
return attach_iline(client_p, conf); |
355 |
|
} |
356 |
|
else if (IsConfKill(conf) || (ConfigFileEntry.glines && IsConfGline(conf))) |
357 |
|
{ |
358 |
|
if (IsConfGline(conf)) |
359 |
< |
sendto_one(client_p, ":%s NOTICE %s :*** G-lined", me.name, |
360 |
< |
client_p->name); |
361 |
< |
sendto_one(client_p, ":%s NOTICE %s :*** Banned: %s", |
554 |
< |
me.name, client_p->name, conf->reason); |
555 |
< |
return(BANNED_CLIENT); |
359 |
> |
sendto_one_notice(client_p, &me, ":*** G-lined"); |
360 |
> |
sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason); |
361 |
> |
return BANNED_CLIENT; |
362 |
|
} |
363 |
|
} |
364 |
|
|
365 |
< |
return(NOT_AUTHORIZED); |
365 |
> |
return NOT_AUTHORIZED; |
366 |
|
} |
367 |
|
|
368 |
|
/* attach_iline() |
380 |
|
int a_limit_reached = 0; |
381 |
|
unsigned int local = 0, global = 0, ident = 0; |
382 |
|
|
383 |
+ |
assert(conf->class); |
384 |
+ |
|
385 |
|
ip_found = find_or_add_ip(&client_p->localClient->ip); |
386 |
|
ip_found->count++; |
387 |
|
SetIpHash(client_p); |
388 |
|
|
581 |
– |
if (conf->class == NULL) |
582 |
– |
return NOT_AUTHORIZED; /* If class is missing, this is best */ |
583 |
– |
|
389 |
|
class = conf->class; |
390 |
|
|
391 |
|
count_user_host(client_p->username, client_p->host, |
395 |
|
* setting a_limit_reached if any limit is reached. |
396 |
|
* - Dianora |
397 |
|
*/ |
398 |
< |
if (class->max_total != 0 && class->ref_count >= class->max_total) |
398 |
> |
if (class->max_total && class->ref_count >= class->max_total) |
399 |
|
a_limit_reached = 1; |
400 |
< |
else if (class->max_perip != 0 && ip_found->count > class->max_perip) |
400 |
> |
else if (class->max_perip && ip_found->count > class->max_perip) |
401 |
|
a_limit_reached = 1; |
402 |
< |
else if (class->max_local != 0 && local >= class->max_local) |
402 |
> |
else if (class->max_local && local >= class->max_local) |
403 |
|
a_limit_reached = 1; |
404 |
< |
else if (class->max_global != 0 && global >= class->max_global) |
404 |
> |
else if (class->max_global && global >= class->max_global) |
405 |
|
a_limit_reached = 1; |
406 |
< |
else if (class->max_ident != 0 && ident >= class->max_ident && |
406 |
> |
else if (class->max_ident && ident >= class->max_ident && |
407 |
|
client_p->username[0] != '~') |
408 |
|
a_limit_reached = 1; |
409 |
|
|
412 |
|
if (!IsConfExemptLimits(conf)) |
413 |
|
return TOO_MANY; /* Already at maximum allowed */ |
414 |
|
|
415 |
< |
sendto_one(client_p, |
416 |
< |
":%s NOTICE %s :*** Your connection class is full, " |
612 |
< |
"but you have exceed_limit = yes;", me.name, client_p->name); |
415 |
> |
sendto_one_notice(client_p, &me, ":*** Your connection class is full, " |
416 |
> |
"but you have exceed_limit = yes;"); |
417 |
|
} |
418 |
|
|
419 |
|
return attach_conf(client_p, conf); |
429 |
|
void |
430 |
|
init_ip_hash_table(void) |
431 |
|
{ |
432 |
< |
ip_entry_pool = mp_pool_new(sizeof(struct ip_entry), |
629 |
< |
2 * hard_fdlimit); |
432 |
> |
ip_entry_pool = mp_pool_new(sizeof(struct ip_entry), MP_CHUNK_SIZE_IP_ENTRY); |
433 |
|
memset(ip_hash_table, 0, sizeof(ip_hash_table)); |
434 |
|
} |
435 |
|
|
479 |
|
garbage_collect_ip_entries(); |
480 |
|
|
481 |
|
newptr = mp_pool_get(ip_entry_pool); |
482 |
< |
memset(newptr, 0, sizeof(*newptr)); |
482 |
> |
|
483 |
|
ip_entries_count++; |
484 |
|
memcpy(&newptr->ip, ip_in, sizeof(struct irc_ssaddr)); |
485 |
|
|
530 |
|
if (ptr->count > 0) |
531 |
|
ptr->count--; |
532 |
|
if (ptr->count == 0 && |
533 |
< |
(CurrentTime-ptr->last_attempt) >= ConfigFileEntry.throttle_time) |
533 |
> |
(CurrentTime-ptr->last_attempt) >= ConfigFileEntry.throttle_time) |
534 |
|
{ |
535 |
|
if (last_ptr != NULL) |
536 |
< |
last_ptr->next = ptr->next; |
536 |
> |
last_ptr->next = ptr->next; |
537 |
|
else |
538 |
< |
ip_hash_table[hash_index] = ptr->next; |
538 |
> |
ip_hash_table[hash_index] = ptr->next; |
539 |
|
|
540 |
|
mp_pool_release(ptr); |
541 |
|
ip_entries_count--; |
572 |
|
uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr; |
573 |
|
|
574 |
|
hash = ip[0] ^ ip[3]; |
575 |
< |
hash ^= hash >> 16; |
576 |
< |
hash ^= hash >> 8; |
575 |
> |
hash ^= hash >> 16; |
576 |
> |
hash ^= hash >> 8; |
577 |
|
hash = hash & (IP_HASH_SIZE - 1); |
578 |
|
return hash; |
579 |
|
} |
584 |
|
|
585 |
|
/* count_ip_hash() |
586 |
|
* |
587 |
< |
* inputs - pointer to counter of number of ips hashed |
587 |
> |
* inputs - pointer to counter of number of ips hashed |
588 |
|
* - pointer to memory used for ip hash |
589 |
|
* output - returned via pointers input |
590 |
|
* side effects - NONE |
596 |
|
count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored) |
597 |
|
{ |
598 |
|
struct ip_entry *ptr; |
796 |
– |
int i; |
599 |
|
|
600 |
|
*number_ips_stored = 0; |
601 |
|
*mem_ips_stored = 0; |
602 |
|
|
603 |
< |
for (i = 0; i < IP_HASH_SIZE; i++) |
603 |
> |
for (unsigned int i = 0; i < IP_HASH_SIZE; ++i) |
604 |
|
{ |
605 |
|
for (ptr = ip_hash_table[i]; ptr; ptr = ptr->next) |
606 |
|
{ |
622 |
|
struct ip_entry *ptr; |
623 |
|
struct ip_entry *last_ptr; |
624 |
|
struct ip_entry *next_ptr; |
823 |
– |
int i; |
625 |
|
|
626 |
< |
for (i = 0; i < IP_HASH_SIZE; i++) |
626 |
> |
for (unsigned int i = 0; i < IP_HASH_SIZE; ++i) |
627 |
|
{ |
628 |
|
last_ptr = NULL; |
629 |
|
|
658 |
|
void |
659 |
|
detach_conf(struct Client *client_p, enum maskitem_type type) |
660 |
|
{ |
661 |
< |
dlink_node *ptr = NULL, *next_ptr = NULL; |
661 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
662 |
|
|
663 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->confs.head) |
663 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, client_p->localClient->confs.head) |
664 |
|
{ |
665 |
|
struct MaskItem *conf = ptr->data; |
666 |
|
|
701 |
|
int |
702 |
|
attach_conf(struct Client *client_p, struct MaskItem *conf) |
703 |
|
{ |
704 |
< |
if (dlinkFind(&client_p->localClient->confs, conf) != NULL) |
704 |
> |
if (dlinkFind(&client_p->localClient->confs, conf)) |
705 |
|
return 1; |
706 |
|
|
707 |
|
if (conf->type == CONF_CLIENT) |
770 |
|
DLINK_FOREACH(ptr, list->head) |
771 |
|
{ |
772 |
|
conf = ptr->data; |
773 |
< |
|
773 |
> |
|
774 |
|
if (conf->type == type) |
775 |
|
{ |
776 |
< |
if (conf->name && (irccmp(conf->name, name) == 0 || |
776 |
> |
if (conf->name && (!irccmp(conf->name, name) || |
777 |
|
!match(conf->name, name))) |
778 |
|
return conf; |
779 |
|
} |
803 |
|
return(&nresv_items); |
804 |
|
break; |
805 |
|
case CONF_CRESV: |
806 |
< |
return(&resv_channel_list); |
806 |
> |
return(&cresv_items); |
807 |
|
case CONF_OPER: |
808 |
|
return(&oconf_items); |
809 |
|
break; |
862 |
|
conf = ptr->data; |
863 |
|
|
864 |
|
if (EmptyString(conf->name)) |
865 |
< |
continue; |
865 |
> |
continue; |
866 |
|
if ((name != NULL) && !match(conf->name, name)) |
867 |
|
{ |
868 |
< |
if ((user == NULL && (host == NULL))) |
869 |
< |
return conf; |
870 |
< |
if ((conf->flags & flags) != flags) |
868 |
> |
if ((user == NULL && (host == NULL))) |
869 |
> |
return conf; |
870 |
> |
if ((conf->flags & flags) != flags) |
871 |
|
continue; |
872 |
< |
if (EmptyString(conf->user) || EmptyString(conf->host)) |
873 |
< |
return conf; |
874 |
< |
if (!match(conf->user, user) && !match(conf->host, host)) |
875 |
< |
return conf; |
872 |
> |
if (EmptyString(conf->user) || EmptyString(conf->host)) |
873 |
> |
return conf; |
874 |
> |
if (!match(conf->user, user) && !match(conf->host, host)) |
875 |
> |
return conf; |
876 |
|
} |
877 |
|
} |
878 |
|
break; |
888 |
|
return conf; |
889 |
|
} |
890 |
|
break; |
891 |
< |
|
891 |
> |
|
892 |
|
default: |
893 |
|
break; |
894 |
|
} |
924 |
|
conf = ptr->data; |
925 |
|
|
926 |
|
if (EmptyString(conf->name)) |
927 |
< |
continue; |
928 |
< |
|
927 |
> |
continue; |
928 |
> |
|
929 |
|
if (irccmp(conf->name, name) == 0) |
930 |
|
{ |
931 |
< |
if ((user == NULL && (host == NULL))) |
932 |
< |
return (conf); |
933 |
< |
if (EmptyString(conf->user) || EmptyString(conf->host)) |
934 |
< |
return (conf); |
935 |
< |
if (!match(conf->user, user) && !match(conf->host, host)) |
936 |
< |
return (conf); |
931 |
> |
if ((user == NULL && (host == NULL))) |
932 |
> |
return conf; |
933 |
> |
if (EmptyString(conf->user) || EmptyString(conf->host)) |
934 |
> |
return conf; |
935 |
> |
if (!match(conf->user, user) && !match(conf->host, host)) |
936 |
> |
return conf; |
937 |
|
} |
938 |
|
} |
939 |
|
break; |
990 |
|
conf = ptr->data; |
991 |
|
|
992 |
|
if (EmptyString(conf->name)) |
993 |
< |
continue; |
994 |
< |
|
993 |
> |
continue; |
994 |
> |
|
995 |
|
if (name == NULL) |
996 |
|
{ |
997 |
< |
if (EmptyString(conf->host)) |
998 |
< |
continue; |
999 |
< |
if (irccmp(conf->host, host) == 0) |
1000 |
< |
return(conf); |
997 |
> |
if (EmptyString(conf->host)) |
998 |
> |
continue; |
999 |
> |
if (irccmp(conf->host, host) == 0) |
1000 |
> |
return conf; |
1001 |
|
} |
1002 |
|
else if (irccmp(conf->name, name) == 0) |
1003 |
< |
{ |
1203 |
< |
return (conf); |
1204 |
< |
} |
1003 |
> |
return conf; |
1004 |
|
} |
1005 |
+ |
|
1006 |
|
break; |
1007 |
|
|
1008 |
|
default: |
1009 |
|
break; |
1010 |
|
} |
1011 |
< |
return(NULL); |
1011 |
> |
|
1012 |
> |
return NULL; |
1013 |
|
} |
1014 |
|
|
1015 |
|
/* rehash() |
1021 |
|
int |
1022 |
|
rehash(int sig) |
1023 |
|
{ |
1024 |
< |
if (sig != 0) |
1024 |
> |
if (sig) |
1025 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1026 |
< |
"Got signal SIGHUP, reloading ircd.conf file"); |
1026 |
> |
"Got signal SIGHUP, reloading configuration file(s)"); |
1027 |
|
|
1028 |
|
restart_resolver(); |
1029 |
|
|
1034 |
|
|
1035 |
|
read_conf_files(0); |
1036 |
|
|
1037 |
< |
if (ServerInfo.description != NULL) |
1037 |
> |
if (ServerInfo.description) |
1038 |
|
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
1039 |
|
|
1040 |
|
load_conf_modules(); |
1041 |
< |
|
1241 |
< |
rehashed_klines = 1; |
1041 |
> |
check_conf_klines(); |
1042 |
|
|
1043 |
|
return 0; |
1044 |
|
} |
1061 |
|
assert(class_default == class_get_list()->tail->data); |
1062 |
|
|
1063 |
|
#ifdef HAVE_LIBCRYPTO |
1064 |
+ |
ServerInfo.message_digest_algorithm = EVP_sha256(); |
1065 |
|
ServerInfo.rsa_private_key = NULL; |
1066 |
|
ServerInfo.rsa_private_key_file = NULL; |
1067 |
|
#endif |
1093 |
|
ConfigLoggingEntry.use_logging = 1; |
1094 |
|
|
1095 |
|
ConfigChannel.disable_fake_channels = 0; |
1096 |
< |
ConfigChannel.knock_delay = 300; |
1096 |
> |
ConfigChannel.invite_client_count = 10; |
1097 |
> |
ConfigChannel.invite_client_time = 300; |
1098 |
> |
ConfigChannel.knock_client_count = 1; |
1099 |
> |
ConfigChannel.knock_client_time = 300; |
1100 |
|
ConfigChannel.knock_delay_channel = 60; |
1101 |
< |
ConfigChannel.max_chans_per_user = 25; |
1298 |
< |
ConfigChannel.max_chans_per_oper = 50; |
1299 |
< |
ConfigChannel.quiet_on_ban = 1; |
1101 |
> |
ConfigChannel.max_channels = 25; |
1102 |
|
ConfigChannel.max_bans = 25; |
1103 |
|
ConfigChannel.default_split_user_count = 0; |
1104 |
|
ConfigChannel.default_split_server_count = 0; |
1112 |
|
ConfigServerHide.hide_services = 0; |
1113 |
|
ConfigServerHide.hidden_name = xstrdup(NETWORK_NAME_DEFAULT); |
1114 |
|
ConfigServerHide.hide_server_ips = 0; |
1115 |
+ |
ConfigServerHide.disable_remote_commands = 0; |
1116 |
|
|
1314 |
– |
|
1117 |
|
ConfigFileEntry.service_name = xstrdup(SERVICE_NAME_DEFAULT); |
1118 |
|
ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT; |
1119 |
+ |
ConfigFileEntry.cycle_on_host_change = 1; |
1120 |
|
ConfigFileEntry.glines = 0; |
1121 |
|
ConfigFileEntry.gline_time = 12 * 3600; |
1122 |
|
ConfigFileEntry.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT; |
1127 |
|
ConfigFileEntry.hide_spoof_ips = 1; |
1128 |
|
ConfigFileEntry.ignore_bogus_ts = 0; |
1129 |
|
ConfigFileEntry.disable_auth = 0; |
1327 |
– |
ConfigFileEntry.disable_remote = 0; |
1130 |
|
ConfigFileEntry.kill_chase_time_limit = 90; |
1131 |
|
ConfigFileEntry.default_floodcount = 8; |
1132 |
|
ConfigFileEntry.failed_oper_notice = 1; |
1140 |
|
ConfigFileEntry.anti_spam_exit_message_time = 0; |
1141 |
|
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
1142 |
|
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
1143 |
< |
ConfigFileEntry.warn_no_nline = 1; |
1143 |
> |
ConfigFileEntry.warn_no_connect_block = 1; |
1144 |
> |
ConfigFileEntry.stats_e_disabled = 0; |
1145 |
|
ConfigFileEntry.stats_o_oper_only = 0; |
1146 |
< |
ConfigFileEntry.stats_k_oper_only = 1; /* masked */ |
1147 |
< |
ConfigFileEntry.stats_i_oper_only = 1; /* masked */ |
1146 |
> |
ConfigFileEntry.stats_k_oper_only = 1; /* 1 = masked */ |
1147 |
> |
ConfigFileEntry.stats_i_oper_only = 1; /* 1 = masked */ |
1148 |
|
ConfigFileEntry.stats_P_oper_only = 0; |
1149 |
+ |
ConfigFileEntry.stats_u_oper_only = 0; |
1150 |
|
ConfigFileEntry.caller_id_wait = 60; |
1151 |
|
ConfigFileEntry.opers_bypass_callerid = 0; |
1152 |
|
ConfigFileEntry.pace_wait = 10; |
1158 |
|
ConfigFileEntry.oper_pass_resv = 1; |
1159 |
|
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; |
1160 |
|
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; |
1161 |
< |
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | |
1358 |
< |
UMODE_OPERWALL | UMODE_WALLOP; |
1161 |
> |
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP; |
1162 |
|
ConfigFileEntry.use_egd = 0; |
1163 |
|
ConfigFileEntry.egdpool_path = NULL; |
1164 |
< |
ConfigFileEntry.throttle_time = 10; |
1164 |
> |
ConfigFileEntry.throttle_count = 1; |
1165 |
> |
ConfigFileEntry.throttle_time = 1; |
1166 |
|
} |
1167 |
|
|
1168 |
|
static void |
1186 |
|
ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN); |
1187 |
|
} |
1188 |
|
|
1189 |
< |
/* read_conf() |
1189 |
> |
/* read_conf() |
1190 |
|
* |
1191 |
|
* inputs - file descriptor pointing to config file to use |
1192 |
|
* output - None |
1197 |
|
{ |
1198 |
|
lineno = 0; |
1199 |
|
|
1200 |
< |
set_default_conf(); /* Set default values prior to conf parsing */ |
1200 |
> |
set_default_conf(); /* Set default values prior to conf parsing */ |
1201 |
|
conf_parser_ctx.pass = 1; |
1202 |
< |
yyparse(); /* pick up the classes first */ |
1202 |
> |
yyparse(); /* Pick up the classes first */ |
1203 |
|
|
1204 |
|
rewind(file); |
1205 |
|
|
1206 |
|
conf_parser_ctx.pass = 2; |
1207 |
< |
yyparse(); /* Load the values from the conf */ |
1208 |
< |
validate_conf(); /* Check to make sure some values are still okay. */ |
1209 |
< |
/* Some global values are also loaded here. */ |
1210 |
< |
class_delete_marked(); /* Make sure classes are valid */ |
1207 |
> |
yyparse(); /* Load the values from the conf */ |
1208 |
> |
validate_conf(); /* Check to make sure some values are still okay. */ |
1209 |
> |
/* Some global values are also loaded here. */ |
1210 |
> |
class_delete_marked(); /* Delete unused classes that are marked for deletion */ |
1211 |
|
} |
1212 |
|
|
1213 |
|
/* lookup_confhost() |
1220 |
|
{ |
1221 |
|
struct addrinfo hints, *res; |
1222 |
|
|
1223 |
< |
/* Do name lookup now on hostnames given and store the |
1223 |
> |
/* |
1224 |
> |
* Do name lookup now on hostnames given and store the |
1225 |
|
* ip numbers in conf structure. |
1226 |
|
*/ |
1227 |
|
memset(&hints, 0, sizeof(hints)); |
1238 |
|
return; |
1239 |
|
} |
1240 |
|
|
1241 |
< |
assert(res != NULL); |
1241 |
> |
assert(res); |
1242 |
|
|
1243 |
|
memcpy(&conf->addr, res->ai_addr, res->ai_addrlen); |
1244 |
|
conf->addr.ss_len = res->ai_addrlen; |
1257 |
|
int |
1258 |
|
conf_connect_allowed(struct irc_ssaddr *addr, int aftype) |
1259 |
|
{ |
1260 |
< |
struct ip_entry *ip_found; |
1260 |
> |
struct ip_entry *ip_found = NULL; |
1261 |
|
struct MaskItem *conf = find_dline_conf(addr, aftype); |
1262 |
|
|
1263 |
|
/* DLINE exempt also gets you out of static limits/pacing... */ |
1264 |
|
if (conf && (conf->type == CONF_EXEMPT)) |
1265 |
|
return 0; |
1266 |
|
|
1267 |
< |
if (conf != NULL) |
1267 |
> |
if (conf) |
1268 |
|
return BANNED_CLIENT; |
1269 |
|
|
1270 |
|
ip_found = find_or_add_ip(addr); |
1271 |
|
|
1272 |
< |
if ((CurrentTime - ip_found->last_attempt) < |
1468 |
< |
ConfigFileEntry.throttle_time) |
1272 |
> |
if ((CurrentTime - ip_found->last_attempt) < ConfigFileEntry.throttle_time) |
1273 |
|
{ |
1274 |
< |
ip_found->last_attempt = CurrentTime; |
1275 |
< |
return TOO_FAST; |
1274 |
> |
if (ip_found->connection_count >= ConfigFileEntry.throttle_count) |
1275 |
> |
return TOO_FAST; |
1276 |
> |
|
1277 |
> |
++ip_found->connection_count; |
1278 |
|
} |
1279 |
+ |
else |
1280 |
+ |
ip_found->connection_count = 1; |
1281 |
|
|
1282 |
|
ip_found->last_attempt = CurrentTime; |
1283 |
|
return 0; |
1284 |
|
} |
1285 |
|
|
1478 |
– |
/* find_kill() |
1479 |
– |
* |
1480 |
– |
* inputs - pointer to client structure |
1481 |
– |
* output - pointer to struct MaskItem if found |
1482 |
– |
* side effects - See if this user is klined already, |
1483 |
– |
* and if so, return struct MaskItem pointer |
1484 |
– |
*/ |
1485 |
– |
struct MaskItem * |
1486 |
– |
find_kill(struct Client *client_p) |
1487 |
– |
{ |
1488 |
– |
struct MaskItem *conf = NULL; |
1489 |
– |
|
1490 |
– |
assert(client_p != NULL); |
1491 |
– |
|
1492 |
– |
conf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
1493 |
– |
CONF_KLINE, client_p->localClient->aftype, |
1494 |
– |
client_p->username, NULL, 1); |
1495 |
– |
return conf; |
1496 |
– |
} |
1497 |
– |
|
1498 |
– |
struct MaskItem * |
1499 |
– |
find_gline(struct Client *client_p) |
1500 |
– |
{ |
1501 |
– |
struct MaskItem *conf; |
1502 |
– |
|
1503 |
– |
assert(client_p != NULL); |
1504 |
– |
|
1505 |
– |
conf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
1506 |
– |
CONF_GLINE, client_p->localClient->aftype, |
1507 |
– |
client_p->username, NULL, 1); |
1508 |
– |
return conf; |
1509 |
– |
} |
1510 |
– |
|
1286 |
|
/* cleanup_tklines() |
1287 |
|
* |
1288 |
|
* inputs - NONE |
1294 |
|
cleanup_tklines(void *notused) |
1295 |
|
{ |
1296 |
|
hostmask_expire_temporary(); |
1297 |
< |
expire_tklines(&xconf_items); |
1297 |
> |
expire_tklines(&xconf_items); |
1298 |
|
expire_tklines(&nresv_items); |
1299 |
< |
expire_tklines(&resv_channel_list); |
1299 |
> |
expire_tklines(&cresv_items); |
1300 |
|
} |
1301 |
|
|
1302 |
|
/* expire_tklines() |
1308 |
|
static void |
1309 |
|
expire_tklines(dlink_list *tklist) |
1310 |
|
{ |
1311 |
< |
dlink_node *ptr; |
1312 |
< |
dlink_node *next_ptr; |
1538 |
< |
struct MaskItem *conf; |
1311 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
1312 |
> |
struct MaskItem *conf = NULL; |
1313 |
|
|
1314 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head) |
1314 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, tklist->head) |
1315 |
|
{ |
1316 |
|
conf = ptr->data; |
1317 |
|
|
1346 |
|
const unsigned int flag; |
1347 |
|
const unsigned char c; |
1348 |
|
} flag_list[] = { |
1349 |
< |
{ OPER_FLAG_ADMIN, 'A' }, |
1350 |
< |
{ OPER_FLAG_REMOTEBAN, 'B' }, |
1351 |
< |
{ OPER_FLAG_DIE, 'D' }, |
1352 |
< |
{ OPER_FLAG_GLINE, 'G' }, |
1353 |
< |
{ OPER_FLAG_REHASH, 'H' }, |
1354 |
< |
{ OPER_FLAG_K, 'K' }, |
1355 |
< |
{ OPER_FLAG_OPERWALL, 'L' }, |
1356 |
< |
{ OPER_FLAG_GLOBAL_KILL, 'O' }, |
1357 |
< |
{ OPER_FLAG_REMOTE, 'R' }, |
1358 |
< |
{ OPER_FLAG_OPER_SPY, 'S' }, |
1359 |
< |
{ OPER_FLAG_UNKLINE, 'U' }, |
1360 |
< |
{ OPER_FLAG_X, 'X' }, |
1349 |
> |
{ OPER_FLAG_ADMIN, 'A' }, |
1350 |
> |
{ OPER_FLAG_REMOTEBAN, 'B' }, |
1351 |
> |
{ OPER_FLAG_DIE, 'D' }, |
1352 |
> |
{ OPER_FLAG_GLINE, 'G' }, |
1353 |
> |
{ OPER_FLAG_REHASH, 'H' }, |
1354 |
> |
{ OPER_FLAG_KLINE, 'K' }, |
1355 |
> |
{ OPER_FLAG_KILL, 'N' }, |
1356 |
> |
{ OPER_FLAG_KILL_REMOTE, 'O' }, |
1357 |
> |
{ OPER_FLAG_CONNECT, 'P' }, |
1358 |
> |
{ OPER_FLAG_CONNECT_REMOTE, 'Q' }, |
1359 |
> |
{ OPER_FLAG_SQUIT, 'R' }, |
1360 |
> |
{ OPER_FLAG_SQUIT_REMOTE, 'S' }, |
1361 |
> |
{ OPER_FLAG_UNKLINE, 'U' }, |
1362 |
> |
{ OPER_FLAG_XLINE, 'X' }, |
1363 |
|
{ 0, '\0' } |
1364 |
|
}; |
1365 |
|
|
1366 |
|
char * |
1367 |
|
oper_privs_as_string(const unsigned int port) |
1368 |
|
{ |
1369 |
< |
static char privs_out[16]; |
1369 |
> |
static char privs_out[IRCD_BUFSIZE]; |
1370 |
|
char *privs_ptr = privs_out; |
1595 |
– |
const struct oper_privs *opriv = flag_list; |
1371 |
|
|
1372 |
< |
for (; opriv->flag; ++opriv) |
1372 |
> |
for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv) |
1373 |
|
{ |
1374 |
|
if (port & opriv->flag) |
1375 |
|
*privs_ptr++ = opriv->c; |
1391 |
|
const char * |
1392 |
|
get_oper_name(const struct Client *client_p) |
1393 |
|
{ |
1394 |
< |
dlink_node *cnode = NULL; |
1394 |
> |
const dlink_node *cnode = NULL; |
1395 |
|
/* +5 for !,@,{,} and null */ |
1396 |
|
static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5]; |
1397 |
|
|
1399 |
|
{ |
1400 |
|
if ((cnode = client_p->localClient->confs.head)) |
1401 |
|
{ |
1402 |
< |
struct MaskItem *conf = cnode->data; |
1402 |
> |
const struct MaskItem *conf = cnode->data; |
1403 |
|
|
1404 |
|
if (IsConfOperator(conf)) |
1405 |
|
{ |
1406 |
< |
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
1406 |
> |
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
1407 |
|
client_p->username, client_p->host, conf->name); |
1408 |
< |
return buffer; |
1408 |
> |
return buffer; |
1409 |
|
} |
1410 |
|
} |
1411 |
|
|
1412 |
< |
/* Probably should assert here for now. If there is an oper out there |
1412 |
> |
/* Probably should assert here for now. If there is an oper out there |
1413 |
|
* with no oper{} conf attached, it would be good for us to know... |
1414 |
|
*/ |
1415 |
|
assert(0); /* Oper without oper conf! */ |
1416 |
|
} |
1417 |
|
|
1418 |
|
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
1419 |
< |
client_p->username, client_p->host, client_p->servptr->name); |
1419 |
> |
client_p->username, client_p->host, client_p->servptr->name); |
1420 |
|
return buffer; |
1421 |
|
} |
1422 |
|
|
1429 |
|
void |
1430 |
|
read_conf_files(int cold) |
1431 |
|
{ |
1432 |
< |
const char *filename; |
1433 |
< |
char chanmodes[32]; |
1434 |
< |
char chanlimit[32]; |
1432 |
> |
const char *filename = NULL; |
1433 |
> |
char chanmodes[IRCD_BUFSIZE] = ""; |
1434 |
> |
char chanlimit[IRCD_BUFSIZE] = ""; |
1435 |
|
|
1436 |
|
conf_parser_ctx.boot = cold; |
1437 |
|
filename = ConfigFileEntry.configfile; |
1440 |
|
FIXME: The full path is in conffilenamebuf first time since we |
1441 |
|
dont know anything else |
1442 |
|
|
1443 |
< |
- Gozem 2002-07-21 |
1443 |
> |
- Gozem 2002-07-21 |
1444 |
|
*/ |
1445 |
|
strlcpy(conffilebuf, filename, sizeof(conffilebuf)); |
1446 |
|
|
1455 |
|
else |
1456 |
|
{ |
1457 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1458 |
< |
"Unable to read configuration file '%s': %s", |
1459 |
< |
filename, strerror(errno)); |
1458 |
> |
"Unable to read configuration file '%s': %s", |
1459 |
> |
filename, strerror(errno)); |
1460 |
|
return; |
1461 |
|
} |
1462 |
|
} |
1478 |
|
add_isupport("CHANTYPES", "#", -1); |
1479 |
|
|
1480 |
|
snprintf(chanlimit, sizeof(chanlimit), "#:%d", |
1481 |
< |
ConfigChannel.max_chans_per_user); |
1481 |
> |
ConfigChannel.max_channels); |
1482 |
|
add_isupport("CHANLIMIT", chanlimit, -1); |
1483 |
< |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,imnprstORS"); |
1484 |
< |
add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN); |
1483 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstMORS"); |
1484 |
> |
add_isupport("CHANNELLEN", NULL, CHANNELLEN); |
1485 |
|
add_isupport("TOPICLEN", NULL, ServerInfo.max_topic_length); |
1711 |
– |
add_isupport("EXCEPTS", "e", -1); |
1712 |
– |
add_isupport("INVEX", "I", -1); |
1486 |
|
add_isupport("CHANMODES", chanmodes, -1); |
1487 |
|
|
1488 |
|
/* |
1506 |
|
dlink_list *free_items [] = { |
1507 |
|
&server_items, &oconf_items, |
1508 |
|
&uconf_items, &xconf_items, |
1509 |
< |
&nresv_items, &cluster_items, &service_items, &resv_channel_list, NULL |
1509 |
> |
&nresv_items, &cluster_items, &service_items, &cresv_items, NULL |
1510 |
|
}; |
1511 |
|
|
1512 |
|
dlink_list ** iterator = free_items; /* C is dumb */ |
1514 |
|
/* We only need to free anything allocated by yyparse() here. |
1515 |
|
* Resetting structs, etc, is taken care of by set_default_conf(). |
1516 |
|
*/ |
1517 |
< |
|
1517 |
> |
|
1518 |
|
for (; *iterator != NULL; iterator++) |
1519 |
|
{ |
1520 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, (*iterator)->head) |
1527 |
|
if (conf->type == CONF_SERVER || conf->type == CONF_OPER) |
1528 |
|
{ |
1529 |
|
if (!conf->ref_count) |
1530 |
< |
conf_free(conf); |
1530 |
> |
conf_free(conf); |
1531 |
|
} |
1532 |
|
else if (conf->type == CONF_XLINE) |
1533 |
|
{ |
1539 |
|
} |
1540 |
|
} |
1541 |
|
|
1542 |
+ |
motd_clear(); |
1543 |
+ |
|
1544 |
|
/* |
1545 |
|
* don't delete the class table, rather mark all entries |
1546 |
|
* for deletion. The table is cleaned up by class_delete_marked. - avalon |
1562 |
|
MyFree(ConfigFileEntry.egdpool_path); |
1563 |
|
ConfigFileEntry.egdpool_path = NULL; |
1564 |
|
#ifdef HAVE_LIBCRYPTO |
1565 |
< |
if (ServerInfo.rsa_private_key != NULL) |
1565 |
> |
if (ServerInfo.rsa_private_key) |
1566 |
|
{ |
1567 |
|
RSA_free(ServerInfo.rsa_private_key); |
1568 |
|
ServerInfo.rsa_private_key = NULL; |
1570 |
|
|
1571 |
|
MyFree(ServerInfo.rsa_private_key_file); |
1572 |
|
ServerInfo.rsa_private_key_file = NULL; |
1798 |
– |
|
1799 |
– |
if (ServerInfo.server_ctx) |
1800 |
– |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2| |
1801 |
– |
SSL_OP_NO_SSLv3| |
1802 |
– |
SSL_OP_NO_TLSv1); |
1803 |
– |
if (ServerInfo.client_ctx) |
1804 |
– |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2| |
1805 |
– |
SSL_OP_NO_SSLv3| |
1806 |
– |
SSL_OP_NO_TLSv1); |
1573 |
|
#endif |
1574 |
|
|
1575 |
|
/* clean out AdminInfo */ |
1586 |
|
/* clean out general */ |
1587 |
|
MyFree(ConfigFileEntry.service_name); |
1588 |
|
ConfigFileEntry.service_name = NULL; |
1823 |
– |
|
1824 |
– |
delete_isupport("INVEX"); |
1825 |
– |
delete_isupport("EXCEPTS"); |
1589 |
|
} |
1590 |
|
|
1591 |
|
/* conf_add_class_to_conf() |
1592 |
|
* |
1593 |
|
* inputs - pointer to config item |
1594 |
|
* output - NONE |
1595 |
< |
* side effects - Add a class pointer to a conf |
1595 |
> |
* side effects - Add a class pointer to a conf |
1596 |
|
*/ |
1597 |
|
void |
1598 |
|
conf_add_class_to_conf(struct MaskItem *conf, const char *class_name) |
1599 |
|
{ |
1600 |
< |
if (class_name == NULL) |
1600 |
> |
if (class_name == NULL) |
1601 |
|
{ |
1602 |
|
conf->class = class_default; |
1603 |
|
|
1604 |
|
if (conf->type == CONF_CLIENT) |
1605 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1606 |
< |
"Warning *** Defaulting to default class for %s@%s", |
1607 |
< |
conf->user, conf->host); |
1606 |
> |
"Warning *** Defaulting to default class for %s@%s", |
1607 |
> |
conf->user, conf->host); |
1608 |
|
else |
1609 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1610 |
< |
"Warning *** Defaulting to default class for %s", |
1611 |
< |
conf->name); |
1610 |
> |
"Warning *** Defaulting to default class for %s", |
1611 |
> |
conf->name); |
1612 |
|
} |
1613 |
|
else |
1614 |
|
conf->class = class_find(class_name, 1); |
1617 |
|
{ |
1618 |
|
if (conf->type == CONF_CLIENT) |
1619 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1620 |
< |
"Warning *** Defaulting to default class for %s@%s", |
1621 |
< |
conf->user, conf->host); |
1620 |
> |
"Warning *** Defaulting to default class for %s@%s", |
1621 |
> |
conf->user, conf->host); |
1622 |
|
else |
1623 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1624 |
< |
"Warning *** Defaulting to default class for %s", |
1625 |
< |
conf->name); |
1624 |
> |
"Warning *** Defaulting to default class for %s", |
1625 |
> |
conf->name); |
1626 |
|
conf->class = class_default; |
1627 |
|
} |
1628 |
|
} |
1664 |
|
|
1665 |
|
/* |
1666 |
|
* valid_tkline() |
1667 |
< |
* |
1667 |
> |
* |
1668 |
|
* inputs - pointer to ascii string to check |
1669 |
|
* - whether the specified time is in seconds or minutes |
1670 |
|
* output - -1 not enough parameters |
1673 |
|
* Originally written by Dianora (Diane, db@db.net) |
1674 |
|
*/ |
1675 |
|
time_t |
1676 |
< |
valid_tkline(const char *p, int minutes) |
1676 |
> |
valid_tkline(const char *data, const int minutes) |
1677 |
|
{ |
1678 |
+ |
const unsigned char *p = (const unsigned char *)data; |
1679 |
+ |
unsigned char tmpch = '\0'; |
1680 |
|
time_t result = 0; |
1681 |
|
|
1682 |
< |
for (; *p; ++p) |
1682 |
> |
while ((tmpch = *p++)) |
1683 |
|
{ |
1684 |
< |
if (!IsDigit(*p)) |
1684 |
> |
if (!IsDigit(tmpch)) |
1685 |
|
return 0; |
1686 |
|
|
1687 |
|
result *= 10; |
1688 |
< |
result += ((*p) & 0xF); |
1688 |
> |
result += (tmpch & 0xF); |
1689 |
|
} |
1690 |
|
|
1691 |
|
/* |
1692 |
< |
* In the degenerate case where oper does a /quote kline 0 user@host :reason |
1692 |
> |
* In the degenerate case where oper does a /quote kline 0 user@host :reason |
1693 |
|
* i.e. they specifically use 0, I am going to return 1 instead |
1694 |
|
* as a return value of non-zero is used to flag it as a temporary kline |
1695 |
|
*/ |
1696 |
|
if (result == 0) |
1697 |
|
result = 1; |
1698 |
|
|
1699 |
< |
/* |
1699 |
> |
/* |
1700 |
|
* If the incoming time is in seconds convert it to minutes for the purpose |
1701 |
|
* of this calculation |
1702 |
|
*/ |
1703 |
|
if (!minutes) |
1704 |
< |
result = result / (time_t)60; |
1704 |
> |
result = result / 60; |
1705 |
|
|
1706 |
|
if (result > MAX_TDKLINE_TIME) |
1707 |
|
result = MAX_TDKLINE_TIME; |
1708 |
|
|
1709 |
< |
result = result * (time_t)60; /* turn it into seconds */ |
1709 |
> |
result = result * 60; /* turn it into seconds */ |
1710 |
|
|
1711 |
|
return result; |
1712 |
|
} |
1713 |
|
|
1714 |
+ |
/* valid_wild_card_simple() |
1715 |
+ |
* |
1716 |
+ |
* inputs - data to check for sufficient non-wildcard characters |
1717 |
+ |
* outputs - 1 if valid, else 0 |
1718 |
+ |
* side effects - none |
1719 |
+ |
*/ |
1720 |
+ |
int |
1721 |
+ |
valid_wild_card_simple(const char *data) |
1722 |
+ |
{ |
1723 |
+ |
const unsigned char *p = (const unsigned char *)data; |
1724 |
+ |
unsigned char tmpch = '\0'; |
1725 |
+ |
unsigned int nonwild = 0; |
1726 |
+ |
|
1727 |
+ |
while ((tmpch = *p++)) |
1728 |
+ |
{ |
1729 |
+ |
if (tmpch == '\\') |
1730 |
+ |
{ |
1731 |
+ |
++p; |
1732 |
+ |
if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple) |
1733 |
+ |
return 1; |
1734 |
+ |
} |
1735 |
+ |
else if (!IsMWildChar(tmpch)) |
1736 |
+ |
{ |
1737 |
+ |
if (++nonwild >= ConfigFileEntry.min_nonwildcard_simple) |
1738 |
+ |
return 1; |
1739 |
+ |
} |
1740 |
+ |
} |
1741 |
+ |
|
1742 |
+ |
return 0; |
1743 |
+ |
} |
1744 |
+ |
|
1745 |
|
/* valid_wild_card() |
1746 |
|
* |
1747 |
|
* input - pointer to client |
1753 |
|
int |
1754 |
|
valid_wild_card(struct Client *source_p, int warn, int count, ...) |
1755 |
|
{ |
1756 |
< |
char *p; |
1757 |
< |
char tmpch; |
1962 |
< |
int nonwild = 0; |
1756 |
> |
unsigned char tmpch = '\0'; |
1757 |
> |
unsigned int nonwild = 0; |
1758 |
|
va_list args; |
1759 |
|
|
1760 |
|
/* |
1773 |
|
|
1774 |
|
while (count--) |
1775 |
|
{ |
1776 |
< |
p = va_arg(args, char *); |
1776 |
> |
const unsigned char *p = va_arg(args, const unsigned char *); |
1777 |
|
if (p == NULL) |
1778 |
|
continue; |
1779 |
|
|
1786 |
|
* break - no point in searching further. |
1787 |
|
*/ |
1788 |
|
if (++nonwild >= ConfigFileEntry.min_nonwildcard) |
1789 |
+ |
{ |
1790 |
+ |
va_end(args); |
1791 |
|
return 1; |
1792 |
+ |
} |
1793 |
|
} |
1794 |
|
} |
1795 |
|
} |
1796 |
|
|
1797 |
|
if (warn) |
1798 |
< |
sendto_one(source_p, ":%s NOTICE %s :Please include at least %d non-wildcard characters with the mask", |
1799 |
< |
me.name, source_p->name, ConfigFileEntry.min_nonwildcard); |
1798 |
> |
sendto_one_notice(source_p, &me, |
1799 |
> |
":Please include at least %u non-wildcard characters with the mask", |
1800 |
> |
ConfigFileEntry.min_nonwildcard); |
1801 |
> |
va_end(args); |
1802 |
|
return 0; |
1803 |
|
} |
1804 |
|
|
1812 |
|
* - parse_flags bit map of things to test |
1813 |
|
* - pointer to user or string to parse into |
1814 |
|
* - pointer to host or NULL to parse into if non NULL |
1815 |
< |
* - pointer to optional tkline time or NULL |
1815 |
> |
* - pointer to optional tkline time or NULL |
1816 |
|
* - pointer to target_server to parse into if non NULL |
1817 |
|
* - pointer to reason to parse into |
1818 |
|
* |
1834 |
|
*/ |
1835 |
|
int |
1836 |
|
parse_aline(const char *cmd, struct Client *source_p, |
1837 |
< |
int parc, char **parv, |
1838 |
< |
int parse_flags, char **up_p, char **h_p, time_t *tkline_time, |
1839 |
< |
char **target_server, char **reason) |
1837 |
> |
int parc, char **parv, |
1838 |
> |
int parse_flags, char **up_p, char **h_p, time_t *tkline_time, |
1839 |
> |
char **target_server, char **reason) |
1840 |
|
{ |
1841 |
|
int found_tkline_time=0; |
1842 |
< |
static char def_reason[] = "No Reason"; |
1842 |
> |
static char def_reason[] = CONF_NOREASON; |
1843 |
|
static char user[USERLEN*4+1]; |
1844 |
|
static char host[HOSTLEN*4+1]; |
1845 |
|
|
1857 |
|
*tkline_time = found_tkline_time; |
1858 |
|
else |
1859 |
|
{ |
1860 |
< |
sendto_one(source_p, ":%s NOTICE %s :temp_line not supported by %s", |
2061 |
< |
me.name, source_p->name, cmd); |
1860 |
> |
sendto_one_notice(source_p, &me, ":temp_line not supported by %s", cmd); |
1861 |
|
return -1; |
1862 |
|
} |
1863 |
|
} |
1864 |
|
|
1865 |
|
if (parc == 0) |
1866 |
|
{ |
1867 |
< |
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
2069 |
< |
me.name, source_p->name, cmd); |
1867 |
> |
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd); |
1868 |
|
return -1; |
1869 |
|
} |
1870 |
|
|
1878 |
|
*up_p = user; |
1879 |
|
*h_p = host; |
1880 |
|
} |
1881 |
< |
|
1881 |
> |
|
1882 |
|
parc--; |
1883 |
|
parv++; |
1884 |
|
|
1891 |
|
|
1892 |
|
if (target_server == NULL) |
1893 |
|
{ |
1894 |
< |
sendto_one(source_p, ":%s NOTICE %s :ON server not supported by %s", |
1895 |
< |
me.name, source_p->name, cmd); |
2098 |
< |
return -1; |
1894 |
> |
sendto_one_notice(source_p, &me, ":ON server not supported by %s", cmd); |
1895 |
> |
return -1; |
1896 |
|
} |
1897 |
|
|
1898 |
|
if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN)) |
1899 |
|
{ |
1900 |
< |
sendto_one(source_p, form_str(ERR_NOPRIVS), |
2104 |
< |
me.name, source_p->name, "remoteban"); |
1900 |
> |
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "remoteban"); |
1901 |
|
return -1; |
1902 |
|
} |
1903 |
|
|
1904 |
|
if (parc == 0 || EmptyString(*parv)) |
1905 |
|
{ |
1906 |
< |
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
1907 |
< |
me.name, source_p->name, cmd); |
2112 |
< |
return -1; |
1906 |
> |
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd); |
1907 |
> |
return -1; |
1908 |
|
} |
1909 |
|
|
1910 |
|
*target_server = *parv; |
1917 |
|
* caller probably NULL'd it first, but no harm to do it again -db |
1918 |
|
*/ |
1919 |
|
if (target_server != NULL) |
1920 |
< |
*target_server = NULL; |
1920 |
> |
*target_server = NULL; |
1921 |
|
} |
1922 |
|
} |
1923 |
|
|
1925 |
|
{ |
1926 |
|
if (strchr(user, '!') != NULL) |
1927 |
|
{ |
1928 |
< |
sendto_one(source_p, ":%s NOTICE %s :Invalid character '!' in kline", |
2134 |
< |
me.name, source_p->name); |
1928 |
> |
sendto_one_notice(source_p, &me, ":Invalid character '!' in kline"); |
1929 |
|
return -1; |
1930 |
|
} |
1931 |
|
|
1942 |
|
{ |
1943 |
|
*reason = *parv; |
1944 |
|
if (!valid_comment(source_p, *reason, 1)) |
1945 |
< |
return -1; |
1945 |
> |
return -1; |
1946 |
|
} |
1947 |
|
else |
1948 |
|
*reason = def_reason; |
1981 |
|
{ |
1982 |
|
*(hostp++) = '\0'; /* short and squat */ |
1983 |
|
if (*user_host_or_nick) |
1984 |
< |
strlcpy(luser, user_host_or_nick, USERLEN*4 + 1); /* here is my user */ |
1984 |
> |
strlcpy(luser, user_host_or_nick, USERLEN*4 + 1); /* here is my user */ |
1985 |
|
else |
1986 |
< |
strcpy(luser, "*"); |
1986 |
> |
strcpy(luser, "*"); |
1987 |
> |
|
1988 |
|
if (*hostp) |
1989 |
< |
strlcpy(lhost, hostp, HOSTLEN + 1); /* here is my host */ |
1989 |
> |
strlcpy(lhost, hostp, HOSTLEN + 1); /* here is my host */ |
1990 |
|
else |
1991 |
< |
strcpy(lhost, "*"); |
1991 |
> |
strcpy(lhost, "*"); |
1992 |
|
} |
1993 |
|
else |
1994 |
|
{ |
1995 |
|
luser[0] = '*'; /* no @ found, assume its *@somehost */ |
1996 |
< |
luser[1] = '\0'; |
1996 |
> |
luser[1] = '\0'; |
1997 |
|
strlcpy(lhost, user_host_or_nick, HOSTLEN*4 + 1); |
1998 |
|
} |
1999 |
< |
|
1999 |
> |
|
2000 |
|
return 1; |
2001 |
|
} |
2002 |
|
else |
2003 |
|
{ |
2004 |
|
/* Try to find user@host mask from nick */ |
2005 |
|
/* Okay to use source_p as the first param, because source_p == client_p */ |
2006 |
< |
if ((target_p = |
2007 |
< |
find_chasing(source_p, source_p, user_host_or_nick, NULL)) == NULL) |
2008 |
< |
return 0; |
2006 |
> |
if ((target_p = |
2007 |
> |
find_chasing(source_p, user_host_or_nick)) == NULL) |
2008 |
> |
return 0; /* find_chasing sends ERR_NOSUCHNICK */ |
2009 |
|
|
2010 |
|
if (IsExemptKline(target_p)) |
2011 |
|
{ |
2012 |
|
if (!IsServer(source_p)) |
2013 |
< |
sendto_one(source_p, |
2219 |
< |
":%s NOTICE %s :%s is E-lined", |
2220 |
< |
me.name, source_p->name, target_p->name); |
2013 |
> |
sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name); |
2014 |
|
return 0; |
2015 |
|
} |
2016 |
|
|
2071 |
|
else |
2072 |
|
encr = password; |
2073 |
|
|
2074 |
< |
return !strcmp(encr, conf->passwd); |
2074 |
> |
return encr && !strcmp(encr, conf->passwd); |
2075 |
|
} |
2076 |
|
|
2077 |
|
/* |
2079 |
|
* |
2080 |
|
* inputs - client sending the cluster |
2081 |
|
* - command name "KLINE" "XLINE" etc. |
2082 |
< |
* - capab -- CAP_KLN etc. from s_serv.h |
2082 |
> |
* - capab -- CAP_KLN etc. from server.h |
2083 |
|
* - cluster type -- CLUSTER_KLINE etc. from conf.h |
2084 |
|
* - pattern and args to send along |
2085 |
|
* output - none |
2091 |
|
int capab, int cluster_type, const char *pattern, ...) |
2092 |
|
{ |
2093 |
|
va_list args; |
2094 |
< |
char buffer[IRCD_BUFSIZE]; |
2094 |
> |
char buffer[IRCD_BUFSIZE] = ""; |
2095 |
|
const dlink_node *ptr = NULL; |
2096 |
|
|
2097 |
|
va_start(args, pattern); |
2104 |
|
|
2105 |
|
if (conf->flags & cluster_type) |
2106 |
|
sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab, |
2107 |
< |
"%s %s %s", command, conf->name, buffer); |
2107 |
> |
"%s %s %s", command, conf->name, buffer); |
2108 |
|
} |
2109 |
|
} |
2110 |
|
|
2152 |
|
{ |
2153 |
|
*p = '\0'; |
2154 |
|
|
2155 |
< |
if (iptr->nickptr && *iptr->nuhmask != '\0') |
2155 |
> |
if (iptr->nickptr && *iptr->nuhmask) |
2156 |
|
strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize); |
2157 |
|
|
2158 |
< |
if ((q = strchr(++p, '@'))) { |
2158 |
> |
if ((q = strchr(++p, '@'))) |
2159 |
> |
{ |
2160 |
|
*q++ = '\0'; |
2161 |
|
|
2162 |
< |
if (*p != '\0') |
2162 |
> |
if (*p) |
2163 |
|
strlcpy(iptr->userptr, p, iptr->usersize); |
2164 |
|
|
2165 |
< |
if (*q != '\0') |
2165 |
> |
if (*q) |
2166 |
|
strlcpy(iptr->hostptr, q, iptr->hostsize); |
2167 |
|
} |
2168 |
|
else |
2169 |
|
{ |
2170 |
< |
if (*p != '\0') |
2170 |
> |
if (*p) |
2171 |
|
strlcpy(iptr->userptr, p, iptr->usersize); |
2172 |
|
} |
2173 |
|
} |
2179 |
|
/* if found a @ */ |
2180 |
|
*p++ = '\0'; |
2181 |
|
|
2182 |
< |
if (*iptr->nuhmask != '\0') |
2182 |
> |
if (*iptr->nuhmask) |
2183 |
|
strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize); |
2184 |
|
|
2185 |
< |
if (*p != '\0') |
2185 |
> |
if (*p) |
2186 |
|
strlcpy(iptr->hostptr, p, iptr->hostsize); |
2187 |
|
} |
2188 |
|
else |