1 |
|
/* |
2 |
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (c) 1997-2014 ircd-hybrid development team |
4 |
> |
* Copyright (c) 1997-2015 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 |
55 |
|
#include "conf_class.h" |
56 |
|
#include "motd.h" |
57 |
|
#include "ipcache.h" |
58 |
+ |
#include "isupport.h" |
59 |
|
|
60 |
|
|
61 |
+ |
struct config_channel_entry ConfigChannel; |
62 |
+ |
struct config_serverhide_entry ConfigServerHide; |
63 |
+ |
struct config_general_entry ConfigGeneral; |
64 |
+ |
struct config_log_entry ConfigLog = { .use_logging = 1 }; |
65 |
+ |
struct config_serverinfo_entry ConfigServerInfo; |
66 |
+ |
struct config_admin_entry ConfigAdminInfo; |
67 |
+ |
struct conf_parser_context conf_parser_ctx; |
68 |
+ |
|
69 |
|
/* general conf items link list root, other than k lines etc. */ |
70 |
< |
dlink_list service_items = { NULL, NULL, 0 }; |
71 |
< |
dlink_list server_items = { NULL, NULL, 0 }; |
72 |
< |
dlink_list cluster_items = { NULL, NULL, 0 }; |
73 |
< |
dlink_list oconf_items = { NULL, NULL, 0 }; |
74 |
< |
dlink_list uconf_items = { NULL, NULL, 0 }; |
75 |
< |
dlink_list xconf_items = { NULL, NULL, 0 }; |
76 |
< |
dlink_list nresv_items = { NULL, NULL, 0 }; |
77 |
< |
dlink_list cresv_items = { NULL, NULL, 0 }; |
70 |
> |
dlink_list service_items; |
71 |
> |
dlink_list server_items; |
72 |
> |
dlink_list cluster_items; |
73 |
> |
dlink_list oconf_items; |
74 |
> |
dlink_list uconf_items; |
75 |
> |
dlink_list xconf_items; |
76 |
> |
dlink_list nresv_items; |
77 |
> |
dlink_list cresv_items; |
78 |
|
|
79 |
|
extern unsigned int lineno; |
80 |
|
extern char linebuf[]; |
81 |
|
extern char conffilebuf[IRCD_BUFSIZE]; |
82 |
|
extern int yyparse(); /* defined in y.tab.c */ |
83 |
|
|
75 |
– |
/* internally defined functions */ |
76 |
– |
static void read_conf(FILE *); |
77 |
– |
static void clear_out_old_conf(void); |
78 |
– |
static void expire_tklines(dlink_list *); |
79 |
– |
static int verify_access(struct Client *); |
80 |
– |
static int attach_iline(struct Client *, struct MaskItem *); |
81 |
– |
static dlink_list *map_to_list(enum maskitem_type); |
82 |
– |
static int find_user_host(struct Client *, char *, char *, char *, unsigned int); |
83 |
– |
|
84 |
|
|
85 |
|
/* conf_dns_callback() |
86 |
|
* |
114 |
|
static void |
115 |
|
conf_dns_lookup(struct MaskItem *conf) |
116 |
|
{ |
117 |
< |
if (!conf->dns_pending) |
118 |
< |
{ |
119 |
< |
conf->dns_pending = 1; |
117 |
> |
if (conf->dns_pending) |
118 |
> |
return; |
119 |
|
|
120 |
< |
if (conf->aftype == AF_INET) |
121 |
< |
gethost_byname_type(conf_dns_callback, conf, conf->host, T_A); |
122 |
< |
else |
123 |
< |
gethost_byname_type(conf_dns_callback, conf, conf->host, T_AAAA); |
120 |
> |
conf->dns_pending = 1; |
121 |
> |
|
122 |
> |
if (conf->aftype == AF_INET) |
123 |
> |
gethost_byname_type(conf_dns_callback, conf, conf->host, T_A); |
124 |
> |
else |
125 |
> |
gethost_byname_type(conf_dns_callback, conf, conf->host, T_AAAA); |
126 |
> |
} |
127 |
> |
|
128 |
> |
/* map_to_list() |
129 |
> |
* |
130 |
> |
* inputs - ConfType conf |
131 |
> |
* output - pointer to dlink_list to use |
132 |
> |
* side effects - none |
133 |
> |
*/ |
134 |
> |
static dlink_list * |
135 |
> |
map_to_list(enum maskitem_type type) |
136 |
> |
{ |
137 |
> |
switch (type) |
138 |
> |
{ |
139 |
> |
case CONF_XLINE: |
140 |
> |
return &xconf_items; |
141 |
> |
break; |
142 |
> |
case CONF_ULINE: |
143 |
> |
return &uconf_items; |
144 |
> |
break; |
145 |
> |
case CONF_NRESV: |
146 |
> |
return &nresv_items; |
147 |
> |
break; |
148 |
> |
case CONF_CRESV: |
149 |
> |
return &cresv_items; |
150 |
> |
break; |
151 |
> |
case CONF_OPER: |
152 |
> |
return &oconf_items; |
153 |
> |
break; |
154 |
> |
case CONF_SERVER: |
155 |
> |
return &server_items; |
156 |
> |
break; |
157 |
> |
case CONF_SERVICE: |
158 |
> |
return &service_items; |
159 |
> |
break; |
160 |
> |
case CONF_CLUSTER: |
161 |
> |
return &cluster_items; |
162 |
> |
break; |
163 |
> |
default: |
164 |
> |
return NULL; |
165 |
|
} |
166 |
|
} |
167 |
|
|
204 |
|
MyFree(conf->spasswd); |
205 |
|
MyFree(conf->reason); |
206 |
|
MyFree(conf->certfp); |
207 |
+ |
MyFree(conf->whois); |
208 |
|
MyFree(conf->user); |
209 |
|
MyFree(conf->host); |
210 |
|
#ifdef HAVE_LIBCRYPTO |
241 |
|
MyFree(conf); |
242 |
|
} |
243 |
|
|
244 |
+ |
/* attach_iline() |
245 |
+ |
* |
246 |
+ |
* inputs - client pointer |
247 |
+ |
* - conf pointer |
248 |
+ |
* output - |
249 |
+ |
* side effects - do actual attach |
250 |
+ |
*/ |
251 |
+ |
static int |
252 |
+ |
attach_iline(struct Client *client_p, struct MaskItem *conf) |
253 |
+ |
{ |
254 |
+ |
const struct ClassItem *const class = conf->class; |
255 |
+ |
struct ip_entry *ip_found; |
256 |
+ |
int a_limit_reached = 0; |
257 |
+ |
unsigned int local = 0, global = 0, ident = 0; |
258 |
+ |
|
259 |
+ |
ip_found = ipcache_find_or_add_address(&client_p->connection->ip); |
260 |
+ |
ip_found->count++; |
261 |
+ |
AddFlag(client_p, FLAGS_IPHASH); |
262 |
+ |
|
263 |
+ |
count_user_host(client_p->username, client_p->host, |
264 |
+ |
&global, &local, &ident); |
265 |
+ |
|
266 |
+ |
/* XXX blah. go down checking the various silly limits |
267 |
+ |
* setting a_limit_reached if any limit is reached. |
268 |
+ |
* - Dianora |
269 |
+ |
*/ |
270 |
+ |
if (class->max_total && class->ref_count >= class->max_total) |
271 |
+ |
a_limit_reached = 1; |
272 |
+ |
else if (class->max_perip && ip_found->count > class->max_perip) |
273 |
+ |
a_limit_reached = 1; |
274 |
+ |
else if (class->max_local && local >= class->max_local) |
275 |
+ |
a_limit_reached = 1; |
276 |
+ |
else if (class->max_global && global >= class->max_global) |
277 |
+ |
a_limit_reached = 1; |
278 |
+ |
else if (class->max_ident && ident >= class->max_ident && |
279 |
+ |
client_p->username[0] != '~') |
280 |
+ |
a_limit_reached = 1; |
281 |
+ |
|
282 |
+ |
if (a_limit_reached) |
283 |
+ |
{ |
284 |
+ |
if (!IsConfExemptLimits(conf)) |
285 |
+ |
return TOO_MANY; /* Already at maximum allowed */ |
286 |
+ |
|
287 |
+ |
sendto_one_notice(client_p, &me, ":*** Your connection class is full, " |
288 |
+ |
"but you have exceed_limit = yes;"); |
289 |
+ |
} |
290 |
+ |
|
291 |
+ |
return attach_conf(client_p, conf); |
292 |
+ |
} |
293 |
+ |
|
294 |
+ |
/* verify_access() |
295 |
+ |
* |
296 |
+ |
* inputs - pointer to client to verify |
297 |
+ |
* output - 0 if success -'ve if not |
298 |
+ |
* side effect - find the first (best) I line to attach. |
299 |
+ |
*/ |
300 |
+ |
static int |
301 |
+ |
verify_access(struct Client *client_p) |
302 |
+ |
{ |
303 |
+ |
struct MaskItem *conf = NULL; |
304 |
+ |
|
305 |
+ |
if (HasFlag(client_p, FLAGS_GOTID)) |
306 |
+ |
{ |
307 |
+ |
conf = find_address_conf(client_p->host, client_p->username, |
308 |
+ |
&client_p->connection->ip, |
309 |
+ |
client_p->connection->aftype, |
310 |
+ |
client_p->connection->password); |
311 |
+ |
} |
312 |
+ |
else |
313 |
+ |
{ |
314 |
+ |
char non_ident[USERLEN + 1] = "~"; |
315 |
+ |
|
316 |
+ |
strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1); |
317 |
+ |
conf = find_address_conf(client_p->host, non_ident, |
318 |
+ |
&client_p->connection->ip, |
319 |
+ |
client_p->connection->aftype, |
320 |
+ |
client_p->connection->password); |
321 |
+ |
} |
322 |
+ |
|
323 |
+ |
if (!conf) |
324 |
+ |
return NOT_AUTHORIZED; |
325 |
+ |
|
326 |
+ |
assert(IsConfClient(conf) || IsConfKill(conf)); |
327 |
+ |
|
328 |
+ |
if (IsConfClient(conf)) |
329 |
+ |
{ |
330 |
+ |
if (IsConfRedir(conf)) |
331 |
+ |
{ |
332 |
+ |
sendto_one_numeric(client_p, &me, RPL_REDIR, |
333 |
+ |
conf->name ? conf->name : "", |
334 |
+ |
conf->port); |
335 |
+ |
return NOT_AUTHORIZED; |
336 |
+ |
} |
337 |
+ |
|
338 |
+ |
if (IsConfDoSpoofIp(conf)) |
339 |
+ |
{ |
340 |
+ |
if (IsConfSpoofNotice(conf)) |
341 |
+ |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, "%s spoofing: %s as %s", |
342 |
+ |
client_p->name, client_p->host, conf->name); |
343 |
+ |
|
344 |
+ |
strlcpy(client_p->host, conf->name, sizeof(client_p->host)); |
345 |
+ |
} |
346 |
+ |
|
347 |
+ |
return attach_iline(client_p, conf); |
348 |
+ |
} |
349 |
+ |
|
350 |
+ |
sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason); |
351 |
+ |
return BANNED_CLIENT; |
352 |
+ |
} |
353 |
+ |
|
354 |
|
/* check_client() |
355 |
|
* |
356 |
|
* inputs - pointer to client |
388 |
|
|
389 |
|
case I_LINE_FULL: |
390 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE, |
391 |
< |
"auth{} block is full for %s (%s).", |
391 |
> |
"auth {} block is full for %s (%s).", |
392 |
|
get_client_name(source_p, SHOW_IP), |
393 |
|
source_p->sockhost); |
394 |
|
ilog(LOG_TYPE_IRCD, "Too many connections from %s.", |
398 |
|
break; |
399 |
|
|
400 |
|
case NOT_AUTHORIZED: |
250 |
– |
++ServerStats.is_ref; |
401 |
|
/* jdc - lists server name & port connections are on */ |
402 |
|
/* a purely cosmetical change */ |
403 |
|
sendto_realops_flags(UMODE_UNAUTH, L_ALL, SEND_NOTICE, |
406 |
|
source_p->sockhost, |
407 |
|
source_p->connection->listener->name, |
408 |
|
source_p->connection->listener->port); |
409 |
< |
ilog(LOG_TYPE_IRCD, |
260 |
< |
"Unauthorized client connection from %s on [%s/%u].", |
409 |
> |
ilog(LOG_TYPE_IRCD, "Unauthorized client connection from %s on [%s/%u].", |
410 |
|
get_client_name(source_p, SHOW_IP), |
411 |
|
source_p->connection->listener->name, |
412 |
|
source_p->connection->listener->port); |
413 |
|
|
414 |
+ |
++ServerStats.is_ref; |
415 |
|
exit_client(source_p, "You are not authorized to use this server"); |
416 |
|
break; |
417 |
|
|
418 |
< |
case BANNED_CLIENT: |
419 |
< |
exit_client(source_p, "Banned"); |
420 |
< |
++ServerStats.is_ref; |
421 |
< |
break; |
272 |
< |
|
273 |
< |
case 0: |
274 |
< |
default: |
275 |
< |
break; |
276 |
< |
} |
277 |
< |
|
278 |
< |
return (i < 0 ? 0 : 1); |
279 |
< |
} |
280 |
< |
|
281 |
< |
/* verify_access() |
282 |
< |
* |
283 |
< |
* inputs - pointer to client to verify |
284 |
< |
* output - 0 if success -'ve if not |
285 |
< |
* side effect - find the first (best) I line to attach. |
286 |
< |
*/ |
287 |
< |
static int |
288 |
< |
verify_access(struct Client *client_p) |
289 |
< |
{ |
290 |
< |
struct MaskItem *conf = NULL; |
291 |
< |
char non_ident[USERLEN + 1] = "~"; |
292 |
< |
|
293 |
< |
if (IsGotId(client_p)) |
294 |
< |
{ |
295 |
< |
conf = find_address_conf(client_p->host, client_p->username, |
296 |
< |
&client_p->connection->ip, |
297 |
< |
client_p->connection->aftype, |
298 |
< |
client_p->connection->password); |
299 |
< |
} |
300 |
< |
else |
301 |
< |
{ |
302 |
< |
strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1); |
303 |
< |
conf = find_address_conf(client_p->host,non_ident, |
304 |
< |
&client_p->connection->ip, |
305 |
< |
client_p->connection->aftype, |
306 |
< |
client_p->connection->password); |
307 |
< |
} |
308 |
< |
|
309 |
< |
if (conf) |
310 |
< |
{ |
311 |
< |
if (IsConfClient(conf)) |
312 |
< |
{ |
313 |
< |
if (IsConfRedir(conf)) |
314 |
< |
{ |
315 |
< |
sendto_one_numeric(client_p, &me, RPL_REDIR, |
316 |
< |
conf->name ? conf->name : "", |
317 |
< |
conf->port); |
318 |
< |
return NOT_AUTHORIZED; |
319 |
< |
} |
320 |
< |
|
321 |
< |
/* Thanks for spoof idea amm */ |
322 |
< |
if (IsConfDoSpoofIp(conf)) |
323 |
< |
{ |
324 |
< |
if (!ConfigGeneral.hide_spoof_ips && IsConfSpoofNotice(conf)) |
325 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
326 |
< |
"%s spoofing: %s as %s", |
327 |
< |
client_p->name, client_p->host, conf->name); |
328 |
< |
strlcpy(client_p->host, conf->name, sizeof(client_p->host)); |
329 |
< |
AddFlag(client_p, FLAGS_IP_SPOOFING | FLAGS_AUTH_SPOOF); |
330 |
< |
} |
331 |
< |
|
332 |
< |
return attach_iline(client_p, conf); |
333 |
< |
} |
334 |
< |
else if (IsConfKill(conf) || (ConfigGeneral.glines && IsConfGline(conf))) |
335 |
< |
{ |
336 |
< |
if (IsConfGline(conf)) |
337 |
< |
sendto_one_notice(client_p, &me, ":*** G-lined"); |
338 |
< |
sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason); |
339 |
< |
return BANNED_CLIENT; |
340 |
< |
} |
341 |
< |
} |
342 |
< |
|
343 |
< |
return NOT_AUTHORIZED; |
344 |
< |
} |
345 |
< |
|
346 |
< |
/* attach_iline() |
347 |
< |
* |
348 |
< |
* inputs - client pointer |
349 |
< |
* - conf pointer |
350 |
< |
* output - |
351 |
< |
* side effects - do actual attach |
352 |
< |
*/ |
353 |
< |
static int |
354 |
< |
attach_iline(struct Client *client_p, struct MaskItem *conf) |
355 |
< |
{ |
356 |
< |
const struct ClassItem *const class = conf->class; |
357 |
< |
struct ip_entry *ip_found; |
358 |
< |
int a_limit_reached = 0; |
359 |
< |
unsigned int local = 0, global = 0, ident = 0; |
360 |
< |
|
361 |
< |
ip_found = ipcache_find_or_add_address(&client_p->connection->ip); |
362 |
< |
ip_found->count++; |
363 |
< |
AddFlag(client_p, FLAGS_IPHASH); |
364 |
< |
|
365 |
< |
count_user_host(client_p->username, client_p->host, |
366 |
< |
&global, &local, &ident); |
367 |
< |
|
368 |
< |
/* XXX blah. go down checking the various silly limits |
369 |
< |
* setting a_limit_reached if any limit is reached. |
370 |
< |
* - Dianora |
371 |
< |
*/ |
372 |
< |
if (class->max_total && class->ref_count >= class->max_total) |
373 |
< |
a_limit_reached = 1; |
374 |
< |
else if (class->max_perip && ip_found->count > class->max_perip) |
375 |
< |
a_limit_reached = 1; |
376 |
< |
else if (class->max_local && local >= class->max_local) |
377 |
< |
a_limit_reached = 1; |
378 |
< |
else if (class->max_global && global >= class->max_global) |
379 |
< |
a_limit_reached = 1; |
380 |
< |
else if (class->max_ident && ident >= class->max_ident && |
381 |
< |
client_p->username[0] != '~') |
382 |
< |
a_limit_reached = 1; |
383 |
< |
|
384 |
< |
if (a_limit_reached) |
385 |
< |
{ |
386 |
< |
if (!IsConfExemptLimits(conf)) |
387 |
< |
return TOO_MANY; /* Already at maximum allowed */ |
418 |
> |
case BANNED_CLIENT: |
419 |
> |
++ServerStats.is_ref; |
420 |
> |
exit_client(source_p, "Banned"); |
421 |
> |
break; |
422 |
|
|
423 |
< |
sendto_one_notice(client_p, &me, ":*** Your connection class is full, " |
424 |
< |
"but you have exceed_limit = yes;"); |
423 |
> |
case 0: |
424 |
> |
default: |
425 |
> |
break; |
426 |
|
} |
427 |
|
|
428 |
< |
return attach_conf(client_p, conf); |
428 |
> |
return !(i < 0); |
429 |
|
} |
430 |
|
|
431 |
|
/* detach_conf() |
512 |
|
{ |
513 |
|
dlink_node *node = NULL; |
514 |
|
|
515 |
< |
assert(client_p != NULL); |
481 |
< |
assert(host != NULL); |
482 |
< |
|
483 |
< |
if (client_p == NULL || host == NULL) |
484 |
< |
return 0; |
515 |
> |
assert(host); |
516 |
|
|
517 |
|
DLINK_FOREACH(node, server_items.head) |
518 |
|
{ |
522 |
|
continue; |
523 |
|
|
524 |
|
attach_conf(client_p, conf); |
525 |
< |
return -1; |
525 |
> |
return 1; |
526 |
|
} |
527 |
|
|
528 |
|
return 0; |
556 |
|
return NULL; |
557 |
|
} |
558 |
|
|
528 |
– |
/* map_to_list() |
529 |
– |
* |
530 |
– |
* inputs - ConfType conf |
531 |
– |
* output - pointer to dlink_list to use |
532 |
– |
* side effects - none |
533 |
– |
*/ |
534 |
– |
static dlink_list * |
535 |
– |
map_to_list(enum maskitem_type type) |
536 |
– |
{ |
537 |
– |
switch(type) |
538 |
– |
{ |
539 |
– |
case CONF_XLINE: |
540 |
– |
return(&xconf_items); |
541 |
– |
break; |
542 |
– |
case CONF_ULINE: |
543 |
– |
return(&uconf_items); |
544 |
– |
break; |
545 |
– |
case CONF_NRESV: |
546 |
– |
return(&nresv_items); |
547 |
– |
break; |
548 |
– |
case CONF_CRESV: |
549 |
– |
return(&cresv_items); |
550 |
– |
case CONF_OPER: |
551 |
– |
return(&oconf_items); |
552 |
– |
break; |
553 |
– |
case CONF_SERVER: |
554 |
– |
return(&server_items); |
555 |
– |
break; |
556 |
– |
case CONF_SERVICE: |
557 |
– |
return(&service_items); |
558 |
– |
break; |
559 |
– |
case CONF_CLUSTER: |
560 |
– |
return(&cluster_items); |
561 |
– |
break; |
562 |
– |
default: |
563 |
– |
return NULL; |
564 |
– |
} |
565 |
– |
} |
566 |
– |
|
559 |
|
/* find_matching_name_conf() |
560 |
|
* |
561 |
|
* inputs - type of link list to look in |
583 |
|
|
584 |
|
if (EmptyString(conf->name)) |
585 |
|
continue; |
586 |
< |
if ((name != NULL) && !irccmp(name, conf->name)) |
586 |
> |
if (name && !irccmp(name, conf->name)) |
587 |
|
return conf; |
588 |
|
} |
589 |
|
break; |
598 |
|
|
599 |
|
if (EmptyString(conf->name)) |
600 |
|
continue; |
601 |
< |
if ((name != NULL) && !match(conf->name, name)) |
601 |
> |
if (name && !match(conf->name, name)) |
602 |
|
{ |
603 |
|
if ((user == NULL && (host == NULL))) |
604 |
|
return conf; |
617 |
|
{ |
618 |
|
conf = node->data; |
619 |
|
|
620 |
< |
if ((name != NULL) && !match(name, conf->name)) |
620 |
> |
if (name && !match(name, conf->name)) |
621 |
|
return conf; |
622 |
< |
else if ((host != NULL) && !match(host, conf->host)) |
622 |
> |
if (host && !match(host, conf->host)) |
623 |
|
return conf; |
624 |
|
} |
625 |
|
break; |
745 |
|
return NULL; |
746 |
|
} |
747 |
|
|
756 |
– |
/* rehash() |
757 |
– |
* |
758 |
– |
* Actual REHASH service routine. Called with sig == 0 if it has been called |
759 |
– |
* as a result of an operator issuing this command, else assume it has been |
760 |
– |
* called as a result of the server receiving a HUP signal. |
761 |
– |
*/ |
762 |
– |
int |
763 |
– |
rehash(int sig) |
764 |
– |
{ |
765 |
– |
if (sig) |
766 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
767 |
– |
"Got signal SIGHUP, reloading configuration file(s)"); |
768 |
– |
|
769 |
– |
restart_resolver(); |
770 |
– |
|
771 |
– |
/* don't close listeners until we know we can go ahead with the rehash */ |
772 |
– |
|
773 |
– |
read_conf_files(0); |
774 |
– |
|
775 |
– |
load_conf_modules(); |
776 |
– |
check_conf_klines(); |
777 |
– |
|
778 |
– |
return 0; |
779 |
– |
} |
780 |
– |
|
748 |
|
/* set_default_conf() |
749 |
|
* |
750 |
|
* inputs - NONE |
794 |
|
memset(&ConfigServerInfo.ip6, 0, sizeof(ConfigServerInfo.ip6)); |
795 |
|
ConfigServerInfo.specific_ipv6_vhost = 0; |
796 |
|
|
797 |
< |
ConfigServerInfo.max_clients = MAXCLIENTS_MAX; |
797 |
> |
ConfigServerInfo.default_max_clients = MAXCLIENTS_MAX; |
798 |
|
ConfigServerInfo.max_nick_length = 9; |
799 |
|
ConfigServerInfo.max_topic_length = 80; |
800 |
|
ConfigServerInfo.hub = 0; |
815 |
|
ConfigChannel.knock_delay_channel = 60; |
816 |
|
ConfigChannel.max_channels = 25; |
817 |
|
ConfigChannel.max_bans = 25; |
818 |
+ |
ConfigChannel.default_join_flood_count = 18; |
819 |
+ |
ConfigChannel.default_join_flood_time = 6; |
820 |
|
ConfigChannel.default_split_user_count = 0; |
821 |
|
ConfigChannel.default_split_server_count = 0; |
822 |
|
ConfigChannel.no_join_on_split = 0; |
835 |
|
ConfigGeneral.away_time = 10; |
836 |
|
ConfigGeneral.max_watch = WATCHSIZE_DEFAULT; |
837 |
|
ConfigGeneral.cycle_on_host_change = 1; |
838 |
< |
ConfigGeneral.glines = 0; |
839 |
< |
ConfigGeneral.gline_time = 12 * 3600; |
840 |
< |
ConfigGeneral.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT; |
841 |
< |
ConfigGeneral.gline_min_cidr = 16; |
873 |
< |
ConfigGeneral.gline_min_cidr6 = 48; |
838 |
> |
ConfigGeneral.dline_min_cidr = 16; |
839 |
> |
ConfigGeneral.dline_min_cidr6 = 48; |
840 |
> |
ConfigGeneral.kline_min_cidr = 16; |
841 |
> |
ConfigGeneral.kline_min_cidr6 = 48; |
842 |
|
ConfigGeneral.invisible_on_connect = 1; |
843 |
|
ConfigGeneral.tkline_expire_notices = 1; |
876 |
– |
ConfigGeneral.hide_spoof_ips = 1; |
844 |
|
ConfigGeneral.ignore_bogus_ts = 0; |
845 |
|
ConfigGeneral.disable_auth = 0; |
846 |
|
ConfigGeneral.kill_chase_time_limit = 90; |
858 |
|
ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
859 |
|
ConfigGeneral.warn_no_connect_block = 1; |
860 |
|
ConfigGeneral.stats_e_disabled = 0; |
894 |
– |
ConfigGeneral.stats_o_oper_only = 0; |
895 |
– |
ConfigGeneral.stats_k_oper_only = 1; /* 1 = masked */ |
861 |
|
ConfigGeneral.stats_i_oper_only = 1; /* 1 = masked */ |
862 |
+ |
ConfigGeneral.stats_k_oper_only = 1; /* 1 = masked */ |
863 |
+ |
ConfigGeneral.stats_o_oper_only = 1; |
864 |
+ |
ConfigGeneral.stats_m_oper_only = 1; |
865 |
|
ConfigGeneral.stats_P_oper_only = 0; |
866 |
|
ConfigGeneral.stats_u_oper_only = 0; |
867 |
|
ConfigGeneral.caller_id_wait = 60; |
871 |
|
ConfigGeneral.short_motd = 0; |
872 |
|
ConfigGeneral.ping_cookie = 0; |
873 |
|
ConfigGeneral.no_oper_flood = 0; |
906 |
– |
ConfigGeneral.true_no_oper_flood = 0; |
874 |
|
ConfigGeneral.oper_pass_resv = 1; |
875 |
|
ConfigGeneral.max_targets = MAX_TARGETS_DEFAULT; |
876 |
< |
ConfigGeneral.oper_only_umodes = UMODE_DEBUG; |
876 |
> |
ConfigGeneral.oper_only_umodes = UMODE_DEBUG | UMODE_LOCOPS | UMODE_HIDDEN | UMODE_FARCONNECT | |
877 |
> |
UMODE_UNAUTH | UMODE_EXTERNAL | UMODE_BOTS | UMODE_NCHANGE | |
878 |
> |
UMODE_SPY | UMODE_FULL | UMODE_SKILL | UMODE_REJ | UMODE_CCONN; |
879 |
|
ConfigGeneral.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP; |
880 |
|
ConfigGeneral.throttle_count = 1; |
881 |
|
ConfigGeneral.throttle_time = 1; |
890 |
|
if (ConfigGeneral.ts_max_delta < TS_MAX_DELTA_MIN) |
891 |
|
ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
892 |
|
|
893 |
< |
if (ConfigServerInfo.network_name == NULL) |
893 |
> |
if (EmptyString(ConfigServerInfo.network_name)) |
894 |
|
ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT); |
895 |
|
|
896 |
< |
if (ConfigServerInfo.network_desc == NULL) |
896 |
> |
if (EmptyString(ConfigServerInfo.network_desc)) |
897 |
|
ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT); |
898 |
|
|
899 |
|
ConfigGeneral.max_watch = IRCD_MAX(ConfigGeneral.max_watch, WATCHSIZE_MIN); |
923 |
|
class_delete_marked(); /* Delete unused classes that are marked for deletion */ |
924 |
|
} |
925 |
|
|
926 |
+ |
/* conf_rehash() |
927 |
+ |
* |
928 |
+ |
* Actual REHASH service routine. Called with sig == 0 if it has been called |
929 |
+ |
* as a result of an operator issuing this command, else assume it has been |
930 |
+ |
* called as a result of the server receiving a HUP signal. |
931 |
+ |
*/ |
932 |
+ |
void |
933 |
+ |
conf_rehash(int sig) |
934 |
+ |
{ |
935 |
+ |
if (sig) |
936 |
+ |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
937 |
+ |
"Got signal SIGHUP, reloading configuration file(s)"); |
938 |
+ |
|
939 |
+ |
restart_resolver(); |
940 |
+ |
|
941 |
+ |
/* don't close listeners until we know we can go ahead with the rehash */ |
942 |
+ |
|
943 |
+ |
read_conf_files(0); |
944 |
+ |
|
945 |
+ |
load_conf_modules(); |
946 |
+ |
check_conf_klines(); |
947 |
+ |
} |
948 |
+ |
|
949 |
|
/* lookup_confhost() |
950 |
|
* |
951 |
|
* start DNS lookups of all hostnames in the conf |
1019 |
|
return 0; |
1020 |
|
} |
1021 |
|
|
1030 |
– |
/* cleanup_tklines() |
1031 |
– |
* |
1032 |
– |
* inputs - NONE |
1033 |
– |
* output - NONE |
1034 |
– |
* side effects - call function to expire temporary k/d lines |
1035 |
– |
* This is an event started off in ircd.c |
1036 |
– |
*/ |
1037 |
– |
void |
1038 |
– |
cleanup_tklines(void *unused) |
1039 |
– |
{ |
1040 |
– |
hostmask_expire_temporary(); |
1041 |
– |
expire_tklines(&xconf_items); |
1042 |
– |
expire_tklines(&nresv_items); |
1043 |
– |
expire_tklines(&cresv_items); |
1044 |
– |
} |
1045 |
– |
|
1022 |
|
/* expire_tklines() |
1023 |
|
* |
1024 |
|
* inputs - tkline list pointer |
1037 |
|
if (!conf->until || conf->until > CurrentTime) |
1038 |
|
continue; |
1039 |
|
|
1040 |
< |
if (conf->type == CONF_XLINE) |
1041 |
< |
{ |
1042 |
< |
if (ConfigGeneral.tkline_expire_notices) |
1043 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1068 |
< |
"Temporary X-line for [%s] expired", conf->name); |
1069 |
< |
conf_free(conf); |
1070 |
< |
} |
1071 |
< |
else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV) |
1072 |
< |
{ |
1073 |
< |
if (ConfigGeneral.tkline_expire_notices) |
1074 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1075 |
< |
"Temporary RESV for [%s] expired", conf->name); |
1076 |
< |
conf_free(conf); |
1077 |
< |
} |
1040 |
> |
if (ConfigGeneral.tkline_expire_notices) |
1041 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "Temporary %s for [%s] expired", |
1042 |
> |
(conf->type == CONF_XLINE) ? "X-line" : "RESV", conf->name); |
1043 |
> |
conf_free(conf); |
1044 |
|
} |
1045 |
|
} |
1046 |
|
|
1047 |
+ |
/* cleanup_tklines() |
1048 |
+ |
* |
1049 |
+ |
* inputs - NONE |
1050 |
+ |
* output - NONE |
1051 |
+ |
* side effects - call function to expire temporary k/d lines |
1052 |
+ |
* This is an event started off in ircd.c |
1053 |
+ |
*/ |
1054 |
+ |
void |
1055 |
+ |
cleanup_tklines(void *unused) |
1056 |
+ |
{ |
1057 |
+ |
hostmask_expire_temporary(); |
1058 |
+ |
expire_tklines(&xconf_items); |
1059 |
+ |
expire_tklines(&nresv_items); |
1060 |
+ |
expire_tklines(&cresv_items); |
1061 |
+ |
} |
1062 |
+ |
|
1063 |
|
/* oper_privs_as_string() |
1064 |
|
* |
1065 |
|
* inputs - pointer to client_p |
1074 |
|
{ OPER_FLAG_ADMIN, 'A' }, |
1075 |
|
{ OPER_FLAG_REMOTEBAN, 'B' }, |
1076 |
|
{ OPER_FLAG_DIE, 'D' }, |
1095 |
– |
{ OPER_FLAG_GLINE, 'G' }, |
1077 |
|
{ OPER_FLAG_REHASH, 'H' }, |
1078 |
|
{ OPER_FLAG_KLINE, 'K' }, |
1079 |
|
{ OPER_FLAG_KILL, 'N' }, |
1087 |
|
{ 0, '\0' } |
1088 |
|
}; |
1089 |
|
|
1090 |
< |
char * |
1090 |
> |
const char * |
1091 |
|
oper_privs_as_string(const unsigned int port) |
1092 |
|
{ |
1093 |
|
static char privs_out[IRCD_BUFSIZE]; |
1115 |
|
const char * |
1116 |
|
get_oper_name(const struct Client *client_p) |
1117 |
|
{ |
1118 |
< |
const dlink_node *node = NULL; |
1138 |
< |
/* +5 for !,@,{,} and null */ |
1139 |
< |
static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5]; |
1118 |
> |
static char buffer[IRCD_BUFSIZE]; |
1119 |
|
|
1120 |
|
if (IsServer(client_p)) |
1121 |
|
return client_p->name; |
1122 |
|
|
1123 |
|
if (MyConnect(client_p)) |
1124 |
|
{ |
1125 |
< |
if ((node = client_p->connection->confs.head)) |
1125 |
> |
const dlink_node *const node = client_p->connection->confs.head; |
1126 |
> |
|
1127 |
> |
if (node) |
1128 |
|
{ |
1129 |
|
const struct MaskItem *const conf = node->data; |
1130 |
|
|
1148 |
|
return buffer; |
1149 |
|
} |
1150 |
|
|
1170 |
– |
/* read_conf_files() |
1171 |
– |
* |
1172 |
– |
* inputs - cold start YES or NO |
1173 |
– |
* output - none |
1174 |
– |
* side effects - read all conf files needed, ircd.conf kline.conf etc. |
1175 |
– |
*/ |
1176 |
– |
void |
1177 |
– |
read_conf_files(int cold) |
1178 |
– |
{ |
1179 |
– |
const char *filename = NULL; |
1180 |
– |
char chanmodes[IRCD_BUFSIZE] = ""; |
1181 |
– |
char chanlimit[IRCD_BUFSIZE] = ""; |
1182 |
– |
|
1183 |
– |
conf_parser_ctx.boot = cold; |
1184 |
– |
filename = ConfigGeneral.configfile; |
1185 |
– |
|
1186 |
– |
/* We need to know the initial filename for the yyerror() to report |
1187 |
– |
FIXME: The full path is in conffilenamebuf first time since we |
1188 |
– |
don't know anything else |
1189 |
– |
|
1190 |
– |
- Gozem 2002-07-21 |
1191 |
– |
*/ |
1192 |
– |
strlcpy(conffilebuf, filename, sizeof(conffilebuf)); |
1193 |
– |
|
1194 |
– |
if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL) |
1195 |
– |
{ |
1196 |
– |
if (cold) |
1197 |
– |
{ |
1198 |
– |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
1199 |
– |
filename, strerror(errno)); |
1200 |
– |
exit(-1); |
1201 |
– |
} |
1202 |
– |
else |
1203 |
– |
{ |
1204 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1205 |
– |
"Unable to read configuration file '%s': %s", |
1206 |
– |
filename, strerror(errno)); |
1207 |
– |
return; |
1208 |
– |
} |
1209 |
– |
} |
1210 |
– |
|
1211 |
– |
if (!cold) |
1212 |
– |
clear_out_old_conf(); |
1213 |
– |
|
1214 |
– |
read_conf(conf_parser_ctx.conf_file); |
1215 |
– |
fclose(conf_parser_ctx.conf_file); |
1216 |
– |
|
1217 |
– |
log_reopen_all(); |
1218 |
– |
|
1219 |
– |
add_isupport("NICKLEN", NULL, ConfigServerInfo.max_nick_length); |
1220 |
– |
add_isupport("NETWORK", ConfigServerInfo.network_name, -1); |
1221 |
– |
|
1222 |
– |
snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans); |
1223 |
– |
add_isupport("MAXLIST", chanmodes, -1); |
1224 |
– |
add_isupport("MAXTARGETS", NULL, ConfigGeneral.max_targets); |
1225 |
– |
add_isupport("CHANTYPES", "#", -1); |
1226 |
– |
|
1227 |
– |
snprintf(chanlimit, sizeof(chanlimit), "#:%d", |
1228 |
– |
ConfigChannel.max_channels); |
1229 |
– |
add_isupport("CHANLIMIT", chanlimit, -1); |
1230 |
– |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstMORS"); |
1231 |
– |
add_isupport("CHANNELLEN", NULL, CHANNELLEN); |
1232 |
– |
add_isupport("TOPICLEN", NULL, ConfigServerInfo.max_topic_length); |
1233 |
– |
add_isupport("CHANMODES", chanmodes, -1); |
1234 |
– |
|
1235 |
– |
/* |
1236 |
– |
* message_locale may have changed. rebuild isupport since it relies |
1237 |
– |
* on strlen(form_str(RPL_ISUPPORT)) |
1238 |
– |
*/ |
1239 |
– |
rebuild_isupport_message_line(); |
1240 |
– |
} |
1241 |
– |
|
1151 |
|
/* clear_out_old_conf() |
1152 |
|
* |
1153 |
|
* inputs - none |
1170 |
|
* Resetting structs, etc, is taken care of by set_default_conf(). |
1171 |
|
*/ |
1172 |
|
|
1173 |
< |
for (; *iterator != NULL; iterator++) |
1173 |
> |
for (; *iterator; iterator++) |
1174 |
|
{ |
1175 |
|
DLINK_FOREACH_SAFE(node, node_next, (*iterator)->head) |
1176 |
|
{ |
1177 |
|
struct MaskItem *conf = node->data; |
1178 |
|
|
1179 |
|
conf->active = 0; |
1271 |
– |
dlinkDelete(&conf->node, *iterator); |
1180 |
|
|
1181 |
< |
/* XXX This is less than pretty */ |
1274 |
< |
if (conf->type == CONF_SERVER || conf->type == CONF_OPER) |
1181 |
> |
if (!IsConfDatabase(conf)) |
1182 |
|
{ |
1183 |
+ |
dlinkDelete(&conf->node, *iterator); |
1184 |
+ |
|
1185 |
|
if (!conf->ref_count) |
1186 |
|
conf_free(conf); |
1187 |
|
} |
1279 |
– |
else if (conf->type == CONF_XLINE) |
1280 |
– |
{ |
1281 |
– |
if (!conf->until) |
1282 |
– |
conf_free(conf); |
1283 |
– |
} |
1284 |
– |
else |
1285 |
– |
conf_free(conf); |
1188 |
|
} |
1189 |
|
} |
1190 |
|
|
1191 |
|
motd_clear(); |
1192 |
|
|
1193 |
|
/* |
1194 |
< |
* don't delete the class table, rather mark all entries |
1195 |
< |
* for deletion. The table is cleaned up by class_delete_marked. - avalon |
1194 |
> |
* Don't delete the class table, rather mark all entries for deletion. |
1195 |
> |
* The table is cleaned up by class_delete_marked. - avalon |
1196 |
|
*/ |
1197 |
|
class_mark_for_deletion(); |
1198 |
|
|
1199 |
|
clear_out_address_conf(); |
1200 |
|
|
1201 |
< |
/* clean out module paths */ |
1201 |
> |
/* Clean out module paths */ |
1202 |
|
mod_clear_paths(); |
1203 |
|
|
1204 |
|
pseudo_clear(); |
1205 |
|
|
1206 |
< |
/* clean out ConfigServerInfo */ |
1206 |
> |
/* Clean out ConfigServerInfo */ |
1207 |
|
MyFree(ConfigServerInfo.description); |
1208 |
|
ConfigServerInfo.description = NULL; |
1209 |
|
MyFree(ConfigServerInfo.network_name); |
1221 |
|
ConfigServerInfo.rsa_private_key_file = NULL; |
1222 |
|
#endif |
1223 |
|
|
1224 |
< |
/* clean out ConfigAdminInfo */ |
1224 |
> |
/* Clean out ConfigAdminInfo */ |
1225 |
|
MyFree(ConfigAdminInfo.name); |
1226 |
|
ConfigAdminInfo.name = NULL; |
1227 |
|
MyFree(ConfigAdminInfo.email); |
1229 |
|
MyFree(ConfigAdminInfo.description); |
1230 |
|
ConfigAdminInfo.description = NULL; |
1231 |
|
|
1232 |
< |
/* clean out listeners */ |
1233 |
< |
close_listeners(); |
1232 |
> |
/* Clean out listeners */ |
1233 |
> |
listener_close_marked(); |
1234 |
> |
} |
1235 |
> |
|
1236 |
> |
/* read_conf_files() |
1237 |
> |
* |
1238 |
> |
* inputs - cold start YES or NO |
1239 |
> |
* output - none |
1240 |
> |
* side effects - read all conf files needed, ircd.conf kline.conf etc. |
1241 |
> |
*/ |
1242 |
> |
void |
1243 |
> |
read_conf_files(int cold) |
1244 |
> |
{ |
1245 |
> |
const char *filename = NULL; |
1246 |
> |
char chanmodes[IRCD_BUFSIZE] = ""; |
1247 |
> |
char chanlimit[IRCD_BUFSIZE] = ""; |
1248 |
> |
|
1249 |
> |
conf_parser_ctx.boot = cold; |
1250 |
> |
filename = ConfigGeneral.configfile; |
1251 |
> |
|
1252 |
> |
/* We need to know the initial filename for the yyerror() to report |
1253 |
> |
FIXME: The full path is in conffilenamebuf first time since we |
1254 |
> |
don't know anything else |
1255 |
> |
|
1256 |
> |
- Gozem 2002-07-21 |
1257 |
> |
*/ |
1258 |
> |
strlcpy(conffilebuf, filename, sizeof(conffilebuf)); |
1259 |
> |
|
1260 |
> |
if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL) |
1261 |
> |
{ |
1262 |
> |
if (cold) |
1263 |
> |
{ |
1264 |
> |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
1265 |
> |
filename, strerror(errno)); |
1266 |
> |
exit(-1); |
1267 |
> |
} |
1268 |
> |
else |
1269 |
> |
{ |
1270 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
1271 |
> |
"Unable to read configuration file '%s': %s", |
1272 |
> |
filename, strerror(errno)); |
1273 |
> |
return; |
1274 |
> |
} |
1275 |
> |
} |
1276 |
> |
|
1277 |
> |
if (!cold) |
1278 |
> |
clear_out_old_conf(); |
1279 |
> |
|
1280 |
> |
read_conf(conf_parser_ctx.conf_file); |
1281 |
> |
fclose(conf_parser_ctx.conf_file); |
1282 |
> |
|
1283 |
> |
log_reopen_all(); |
1284 |
> |
|
1285 |
> |
isupport_add("NICKLEN", NULL, ConfigServerInfo.max_nick_length); |
1286 |
> |
isupport_add("NETWORK", ConfigServerInfo.network_name, -1); |
1287 |
> |
|
1288 |
> |
snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans); |
1289 |
> |
isupport_add("MAXLIST", chanmodes, -1); |
1290 |
> |
isupport_add("MAXTARGETS", NULL, ConfigGeneral.max_targets); |
1291 |
> |
isupport_add("CHANTYPES", "#", -1); |
1292 |
> |
|
1293 |
> |
snprintf(chanlimit, sizeof(chanlimit), "#:%d", |
1294 |
> |
ConfigChannel.max_channels); |
1295 |
> |
isupport_add("CHANLIMIT", chanlimit, -1); |
1296 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstCMORS"); |
1297 |
> |
isupport_add("CHANNELLEN", NULL, CHANNELLEN); |
1298 |
> |
isupport_add("TOPICLEN", NULL, ConfigServerInfo.max_topic_length); |
1299 |
> |
isupport_add("CHANMODES", chanmodes, -1); |
1300 |
> |
|
1301 |
> |
/* |
1302 |
> |
* message_locale may have changed. rebuild isupport since it relies |
1303 |
> |
* on strlen(form_str(RPL_ISUPPORT)) |
1304 |
> |
*/ |
1305 |
> |
isupport_rebuild(); |
1306 |
|
} |
1307 |
|
|
1308 |
|
/* conf_add_class_to_conf() |
1312 |
|
* side effects - Add a class pointer to a conf |
1313 |
|
*/ |
1314 |
|
void |
1315 |
< |
conf_add_class_to_conf(struct MaskItem *conf, const char *class_name) |
1315 |
> |
conf_add_class_to_conf(struct MaskItem *conf, const char *name) |
1316 |
|
{ |
1317 |
< |
if (class_name == NULL) |
1317 |
> |
if (EmptyString(name) || (conf->class = class_find(name, 1)) == NULL) |
1318 |
|
{ |
1319 |
|
conf->class = class_default; |
1320 |
|
|
1321 |
|
if (conf->type == CONF_CLIENT || conf->type == CONF_OPER) |
1322 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1349 |
< |
"Warning *** Defaulting to default class for %s@%s", |
1350 |
< |
conf->user, conf->host); |
1351 |
< |
else |
1352 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1353 |
< |
"Warning *** Defaulting to default class for %s", |
1354 |
< |
conf->name); |
1355 |
< |
} |
1356 |
< |
else |
1357 |
< |
conf->class = class_find(class_name, 1); |
1358 |
< |
|
1359 |
< |
if (conf->class == NULL) |
1360 |
< |
{ |
1361 |
< |
if (conf->type == CONF_CLIENT || conf->type == CONF_OPER) |
1362 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1322 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
1323 |
|
"Warning *** Defaulting to default class for %s@%s", |
1324 |
|
conf->user, conf->host); |
1325 |
|
else |
1326 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1326 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
1327 |
|
"Warning *** Defaulting to default class for %s", |
1328 |
|
conf->name); |
1369 |
– |
conf->class = class_default; |
1329 |
|
} |
1330 |
|
} |
1331 |
|
|
1344 |
|
return; |
1345 |
|
|
1346 |
|
strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf)); |
1347 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1347 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
1348 |
|
"\"%s\", line %u: %s: %s", |
1349 |
|
conffilebuf, lineno + 1, msg, newlinebuf); |
1350 |
|
ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s", |
1357 |
|
char newlinebuf[IRCD_BUFSIZE]; |
1358 |
|
|
1359 |
|
strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf)); |
1360 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1360 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
1361 |
|
"\"%s\", line %u: %s: %s", |
1362 |
|
conffilebuf, lineno + 1, msg, newlinebuf); |
1363 |
|
ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s", |
1392 |
|
|
1393 |
|
/* |
1394 |
|
* In the degenerate case where oper does a /quote kline 0 user@host :reason |
1395 |
< |
* i.e. they specifically use 0, I am going to return 1 instead |
1396 |
< |
* as a return value of non-zero is used to flag it as a temporary kline |
1395 |
> |
* i.e. they specifically use 0, I am going to return 1 instead as a return |
1396 |
> |
* value of non-zero is used to flag it as a temporary kline |
1397 |
|
*/ |
1398 |
|
if (result == 0) |
1399 |
|
result = 1; |
1408 |
|
if (result > MAX_TDKLINE_TIME) |
1409 |
|
result = MAX_TDKLINE_TIME; |
1410 |
|
|
1411 |
< |
result = result * 60; /* turn it into seconds */ |
1411 |
> |
result = result * 60; /* Turn it into seconds */ |
1412 |
|
|
1413 |
|
return result; |
1414 |
|
} |
1424 |
|
{ |
1425 |
|
const unsigned char *p = (const unsigned char *)data; |
1426 |
|
unsigned char tmpch = '\0'; |
1427 |
< |
unsigned int nonwild = 0; |
1427 |
> |
unsigned int nonwild = 0, wild = 0; |
1428 |
|
|
1429 |
|
while ((tmpch = *p++)) |
1430 |
|
{ |
1439 |
|
if (++nonwild >= ConfigGeneral.min_nonwildcard_simple) |
1440 |
|
return 1; |
1441 |
|
} |
1442 |
+ |
else |
1443 |
+ |
++wild; |
1444 |
|
} |
1445 |
|
|
1446 |
< |
return 0; |
1446 |
> |
return !wild; |
1447 |
|
} |
1448 |
|
|
1449 |
|
/* valid_wild_card() |
1455 |
|
* side effects - NOTICE is given to source_p if warn is 1 |
1456 |
|
*/ |
1457 |
|
int |
1458 |
< |
valid_wild_card(struct Client *source_p, int warn, int count, ...) |
1458 |
> |
valid_wild_card(struct Client *source_p, int count, ...) |
1459 |
|
{ |
1460 |
|
unsigned char tmpch = '\0'; |
1461 |
|
unsigned int nonwild = 0; |
1498 |
|
} |
1499 |
|
} |
1500 |
|
|
1501 |
< |
if (warn) |
1501 |
> |
if (IsClient(source_p)) |
1502 |
|
sendto_one_notice(source_p, &me, |
1503 |
|
":Please include at least %u non-wildcard characters with the mask", |
1504 |
|
ConfigGeneral.min_nonwildcard); |
1506 |
|
return 0; |
1507 |
|
} |
1508 |
|
|
1509 |
+ |
/* find_user_host() |
1510 |
+ |
* |
1511 |
+ |
* inputs - pointer to client placing kline |
1512 |
+ |
* - pointer to user_host_or_nick |
1513 |
+ |
* - pointer to user buffer |
1514 |
+ |
* - pointer to host buffer |
1515 |
+ |
* output - 0 if not ok to kline, 1 to kline i.e. if valid user host |
1516 |
+ |
* side effects - |
1517 |
+ |
*/ |
1518 |
+ |
static int |
1519 |
+ |
find_user_host(struct Client *source_p, char *user_host_or_nick, |
1520 |
+ |
char *luser, char *lhost) |
1521 |
+ |
{ |
1522 |
+ |
struct Client *target_p = NULL; |
1523 |
+ |
char *hostp = NULL; |
1524 |
+ |
|
1525 |
+ |
if (lhost == NULL) |
1526 |
+ |
{ |
1527 |
+ |
strlcpy(luser, user_host_or_nick, USERLEN*4 + 1); |
1528 |
+ |
return 1; |
1529 |
+ |
} |
1530 |
+ |
|
1531 |
+ |
if ((hostp = strchr(user_host_or_nick, '@')) || *user_host_or_nick == '*') |
1532 |
+ |
{ |
1533 |
+ |
/* Explicit user@host mask given */ |
1534 |
+ |
if (hostp) /* I'm a little user@host */ |
1535 |
+ |
{ |
1536 |
+ |
*(hostp++) = '\0'; /* short and squat */ |
1537 |
+ |
|
1538 |
+ |
if (*user_host_or_nick) |
1539 |
+ |
strlcpy(luser, user_host_or_nick, USERLEN*4 + 1); /* here is my user */ |
1540 |
+ |
else |
1541 |
+ |
strcpy(luser, "*"); |
1542 |
+ |
|
1543 |
+ |
if (*hostp) |
1544 |
+ |
strlcpy(lhost, hostp, HOSTLEN + 1); /* here is my host */ |
1545 |
+ |
else |
1546 |
+ |
strcpy(lhost, "*"); |
1547 |
+ |
} |
1548 |
+ |
else |
1549 |
+ |
{ |
1550 |
+ |
luser[0] = '*'; /* no @ found, assume its *@somehost */ |
1551 |
+ |
luser[1] = '\0'; |
1552 |
+ |
strlcpy(lhost, user_host_or_nick, HOSTLEN*4 + 1); |
1553 |
+ |
} |
1554 |
+ |
|
1555 |
+ |
return 1; |
1556 |
+ |
} |
1557 |
+ |
else |
1558 |
+ |
{ |
1559 |
+ |
/* Try to find user@host mask from nick */ |
1560 |
+ |
/* Okay to use source_p as the first param, because source_p == client_p */ |
1561 |
+ |
if ((target_p = |
1562 |
+ |
find_chasing(source_p, user_host_or_nick)) == NULL) |
1563 |
+ |
return 0; /* find_chasing sends ERR_NOSUCHNICK */ |
1564 |
+ |
|
1565 |
+ |
if (HasFlag(target_p, FLAGS_EXEMPTKLINE)) |
1566 |
+ |
{ |
1567 |
+ |
if (IsClient(source_p)) |
1568 |
+ |
sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name); |
1569 |
+ |
return 0; |
1570 |
+ |
} |
1571 |
+ |
|
1572 |
+ |
/* |
1573 |
+ |
* Turn the "user" bit into "*user", blow away '~' |
1574 |
+ |
* if found in original user name (non-idented) |
1575 |
+ |
*/ |
1576 |
+ |
strlcpy(luser, target_p->username, USERLEN*4 + 1); |
1577 |
+ |
|
1578 |
+ |
if (target_p->username[0] == '~') |
1579 |
+ |
luser[0] = '*'; |
1580 |
+ |
|
1581 |
+ |
if (!strcmp(target_p->sockhost, "0")) |
1582 |
+ |
strlcpy(lhost, target_p->host, HOSTLEN*4 + 1); |
1583 |
+ |
else |
1584 |
+ |
strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1); |
1585 |
+ |
return 1; |
1586 |
+ |
} |
1587 |
+ |
|
1588 |
+ |
return 0; |
1589 |
+ |
} |
1590 |
+ |
|
1591 |
|
/* XXX should this go into a separate file ? -Dianora */ |
1592 |
|
/* parse_aline |
1593 |
|
* |
1602 |
|
* - pointer to target_server to parse into if non NULL |
1603 |
|
* - pointer to reason to parse into |
1604 |
|
* |
1605 |
< |
* output - 1 if valid, -1 if not valid |
1605 |
> |
* output - 1 if valid, 0 if not valid |
1606 |
|
* side effects - A generalised k/d/x etc. line parser, |
1607 |
|
* "ALINE [time] user@host|string [ON] target :reason" |
1608 |
|
* will parse returning a parsed user, host if |
1625 |
|
char **target_server, char **reason) |
1626 |
|
{ |
1627 |
|
int found_tkline_time=0; |
1628 |
< |
static char def_reason[] = CONF_NOREASON; |
1628 |
> |
static char default_reason[] = CONF_NOREASON; |
1629 |
|
static char user[USERLEN*4+1]; |
1630 |
|
static char host[HOSTLEN*4+1]; |
1631 |
|
|
1634 |
|
|
1635 |
|
found_tkline_time = valid_tkline(*parv, TK_MINUTES); |
1636 |
|
|
1637 |
< |
if (found_tkline_time != 0) |
1637 |
> |
if (found_tkline_time) |
1638 |
|
{ |
1639 |
|
parv++; |
1640 |
|
parc--; |
1641 |
|
|
1642 |
< |
if (tkline_time != NULL) |
1642 |
> |
if (tkline_time) |
1643 |
|
*tkline_time = found_tkline_time; |
1644 |
|
else |
1645 |
|
{ |
1646 |
|
sendto_one_notice(source_p, &me, ":temp_line not supported by %s", cmd); |
1647 |
< |
return -1; |
1647 |
> |
return 0; |
1648 |
|
} |
1649 |
|
} |
1650 |
|
|
1651 |
|
if (parc == 0) |
1652 |
|
{ |
1653 |
|
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd); |
1654 |
< |
return -1; |
1654 |
> |
return 0; |
1655 |
|
} |
1656 |
|
|
1657 |
|
if (h_p == NULL) |
1658 |
|
*up_p = *parv; |
1659 |
|
else |
1660 |
|
{ |
1661 |
< |
if (find_user_host(source_p, *parv, user, host, parse_flags) == 0) |
1662 |
< |
return -1; |
1661 |
> |
if (find_user_host(source_p, *parv, user, host) == 0) |
1662 |
> |
return 0; |
1663 |
|
|
1664 |
|
*up_p = user; |
1665 |
|
*h_p = host; |
1668 |
|
parc--; |
1669 |
|
parv++; |
1670 |
|
|
1671 |
< |
if (parc != 0) |
1671 |
> |
if (parc) |
1672 |
|
{ |
1673 |
|
if (irccmp(*parv, "ON") == 0) |
1674 |
|
{ |
1675 |
|
parc--; |
1676 |
|
parv++; |
1677 |
|
|
1635 |
– |
if (target_server == NULL) |
1636 |
– |
{ |
1637 |
– |
sendto_one_notice(source_p, &me, ":ON server not supported by %s", cmd); |
1638 |
– |
return -1; |
1639 |
– |
} |
1640 |
– |
|
1678 |
|
if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN)) |
1679 |
|
{ |
1680 |
|
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "remoteban"); |
1681 |
< |
return -1; |
1681 |
> |
return 0; |
1682 |
|
} |
1683 |
|
|
1684 |
|
if (parc == 0 || EmptyString(*parv)) |
1685 |
|
{ |
1686 |
|
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd); |
1687 |
< |
return -1; |
1687 |
> |
return 0; |
1688 |
|
} |
1689 |
|
|
1690 |
|
*target_server = *parv; |
1696 |
|
/* Make sure target_server *is* NULL if no ON server found |
1697 |
|
* caller probably NULL'd it first, but no harm to do it again -db |
1698 |
|
*/ |
1699 |
< |
if (target_server != NULL) |
1699 |
> |
if (target_server) |
1700 |
|
*target_server = NULL; |
1701 |
|
} |
1702 |
|
} |
1703 |
|
|
1704 |
< |
if (h_p != NULL) |
1704 |
> |
if (h_p) |
1705 |
|
{ |
1706 |
< |
if (strchr(user, '!') != NULL) |
1706 |
> |
if (strchr(user, '!')) |
1707 |
|
{ |
1708 |
|
sendto_one_notice(source_p, &me, ":Invalid character '!' in kline"); |
1709 |
< |
return -1; |
1709 |
> |
return 0; |
1710 |
|
} |
1711 |
|
|
1712 |
< |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p)) |
1713 |
< |
return -1; |
1712 |
> |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 2, *up_p, *h_p)) |
1713 |
> |
return 0; |
1714 |
|
} |
1715 |
|
else |
1716 |
< |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p)) |
1717 |
< |
return -1; |
1716 |
> |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, *up_p)) |
1717 |
> |
return 0; |
1718 |
|
|
1719 |
< |
if (reason != NULL) |
1719 |
> |
if (reason) |
1720 |
|
{ |
1721 |
< |
if (parc != 0 && !EmptyString(*parv)) |
1685 |
< |
{ |
1721 |
> |
if (parc && !EmptyString(*parv)) |
1722 |
|
*reason = *parv; |
1687 |
– |
if (!valid_comment(source_p, *reason, 1)) |
1688 |
– |
return -1; |
1689 |
– |
} |
1723 |
|
else |
1724 |
< |
*reason = def_reason; |
1724 |
> |
*reason = default_reason; |
1725 |
|
} |
1726 |
|
|
1727 |
|
return 1; |
1728 |
|
} |
1729 |
|
|
1697 |
– |
/* find_user_host() |
1698 |
– |
* |
1699 |
– |
* inputs - pointer to client placing kline |
1700 |
– |
* - pointer to user_host_or_nick |
1701 |
– |
* - pointer to user buffer |
1702 |
– |
* - pointer to host buffer |
1703 |
– |
* output - 0 if not ok to kline, 1 to kline i.e. if valid user host |
1704 |
– |
* side effects - |
1705 |
– |
*/ |
1706 |
– |
static int |
1707 |
– |
find_user_host(struct Client *source_p, char *user_host_or_nick, |
1708 |
– |
char *luser, char *lhost, unsigned int flags) |
1709 |
– |
{ |
1710 |
– |
struct Client *target_p = NULL; |
1711 |
– |
char *hostp = NULL; |
1712 |
– |
|
1713 |
– |
if (lhost == NULL) |
1714 |
– |
{ |
1715 |
– |
strlcpy(luser, user_host_or_nick, USERLEN*4 + 1); |
1716 |
– |
return 1; |
1717 |
– |
} |
1718 |
– |
|
1719 |
– |
if ((hostp = strchr(user_host_or_nick, '@')) || *user_host_or_nick == '*') |
1720 |
– |
{ |
1721 |
– |
/* Explicit user@host mask given */ |
1722 |
– |
|
1723 |
– |
if (hostp != NULL) /* I'm a little user@host */ |
1724 |
– |
{ |
1725 |
– |
*(hostp++) = '\0'; /* short and squat */ |
1726 |
– |
if (*user_host_or_nick) |
1727 |
– |
strlcpy(luser, user_host_or_nick, USERLEN*4 + 1); /* here is my user */ |
1728 |
– |
else |
1729 |
– |
strcpy(luser, "*"); |
1730 |
– |
|
1731 |
– |
if (*hostp) |
1732 |
– |
strlcpy(lhost, hostp, HOSTLEN + 1); /* here is my host */ |
1733 |
– |
else |
1734 |
– |
strcpy(lhost, "*"); |
1735 |
– |
} |
1736 |
– |
else |
1737 |
– |
{ |
1738 |
– |
luser[0] = '*'; /* no @ found, assume its *@somehost */ |
1739 |
– |
luser[1] = '\0'; |
1740 |
– |
strlcpy(lhost, user_host_or_nick, HOSTLEN*4 + 1); |
1741 |
– |
} |
1742 |
– |
|
1743 |
– |
return 1; |
1744 |
– |
} |
1745 |
– |
else |
1746 |
– |
{ |
1747 |
– |
/* Try to find user@host mask from nick */ |
1748 |
– |
/* Okay to use source_p as the first param, because source_p == client_p */ |
1749 |
– |
if ((target_p = |
1750 |
– |
find_chasing(source_p, user_host_or_nick)) == NULL) |
1751 |
– |
return 0; /* find_chasing sends ERR_NOSUCHNICK */ |
1752 |
– |
|
1753 |
– |
if (IsExemptKline(target_p)) |
1754 |
– |
{ |
1755 |
– |
if (IsClient(source_p)) |
1756 |
– |
sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name); |
1757 |
– |
return 0; |
1758 |
– |
} |
1759 |
– |
|
1760 |
– |
/* |
1761 |
– |
* turn the "user" bit into "*user", blow away '~' |
1762 |
– |
* if found in original user name (non-idented) |
1763 |
– |
*/ |
1764 |
– |
strlcpy(luser, target_p->username, USERLEN*4 + 1); |
1765 |
– |
|
1766 |
– |
if (target_p->username[0] == '~') |
1767 |
– |
luser[0] = '*'; |
1768 |
– |
|
1769 |
– |
if (!strcmp(target_p->sockhost, "0")) |
1770 |
– |
strlcpy(lhost, target_p->host, HOSTLEN*4 + 1); |
1771 |
– |
else |
1772 |
– |
strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1); |
1773 |
– |
return 1; |
1774 |
– |
} |
1775 |
– |
|
1776 |
– |
return 0; |
1777 |
– |
} |
1778 |
– |
|
1779 |
– |
/* valid_comment() |
1780 |
– |
* |
1781 |
– |
* inputs - pointer to client |
1782 |
– |
* - pointer to comment |
1783 |
– |
* output - 0 if no valid comment, |
1784 |
– |
* - 1 if valid |
1785 |
– |
* side effects - truncates reason where necessary |
1786 |
– |
*/ |
1787 |
– |
int |
1788 |
– |
valid_comment(struct Client *source_p, char *comment, int warn) |
1789 |
– |
{ |
1790 |
– |
if (strlen(comment) > REASONLEN) |
1791 |
– |
comment[REASONLEN-1] = '\0'; |
1792 |
– |
|
1793 |
– |
return 1; |
1794 |
– |
} |
1795 |
– |
|
1730 |
|
/* match_conf_password() |
1731 |
|
* |
1732 |
|
* inputs - pointer to given password |
1755 |
|
* |
1756 |
|
* inputs - client sending the cluster |
1757 |
|
* - command name "KLINE" "XLINE" etc. |
1758 |
< |
* - capab -- CAP_KLN etc. from server.h |
1758 |
> |
* - capab -- CAPAB_KLN etc. from server.h |
1759 |
|
* - cluster type -- CLUSTER_KLINE etc. from conf.h |
1760 |
|
* - pattern and args to send along |
1761 |
|
* output - none |
1763 |
|
* along to all servers that match capab and cluster type |
1764 |
|
*/ |
1765 |
|
void |
1766 |
< |
cluster_a_line(struct Client *source_p, const char *command, |
1767 |
< |
int capab, int cluster_type, const char *pattern, ...) |
1766 |
> |
cluster_a_line(struct Client *source_p, const char *command, unsigned int capab, |
1767 |
> |
unsigned int cluster_type, const char *pattern, ...) |
1768 |
|
{ |
1769 |
|
va_list args; |
1770 |
|
char buffer[IRCD_BUFSIZE] = ""; |
1779 |
|
const struct MaskItem *conf = node->data; |
1780 |
|
|
1781 |
|
if (conf->flags & cluster_type) |
1782 |
< |
sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab, |
1782 |
> |
sendto_match_servs(source_p, conf->name, CAPAB_CLUSTER | capab, |
1783 |
|
"%s %s %s", command, conf->name, buffer); |
1784 |
|
} |
1785 |
|
} |
1819 |
|
|
1820 |
|
if (iptr->nickptr) |
1821 |
|
strlcpy(iptr->nickptr, "*", iptr->nicksize); |
1822 |
+ |
|
1823 |
|
if (iptr->userptr) |
1824 |
|
strlcpy(iptr->userptr, "*", iptr->usersize); |
1825 |
+ |
|
1826 |
|
if (iptr->hostptr) |
1827 |
|
strlcpy(iptr->hostptr, "*", iptr->hostsize); |
1828 |
|
|
1865 |
|
} |
1866 |
|
else |
1867 |
|
{ |
1868 |
< |
/* no @ found */ |
1868 |
> |
/* No @ found */ |
1869 |
|
if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:")) |
1870 |
|
strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize); |
1871 |
|
else |