1 |
|
/* |
2 |
|
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
< |
* s_conf.c: Configuration file functions. |
3 |
> |
* conf.c: Configuration file functions. |
4 |
|
* |
5 |
|
* Copyright (C) 2002 by the past and present ircd coders, and others. |
6 |
|
* |
23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
+ |
#include "list.h" |
27 |
|
#include "ircd_defs.h" |
28 |
< |
#include "tools.h" |
29 |
< |
#include "s_conf.h" |
28 |
> |
#include "balloc.h" |
29 |
> |
#include "conf.h" |
30 |
|
#include "s_serv.h" |
31 |
|
#include "resv.h" |
32 |
|
#include "channel.h" |
33 |
|
#include "client.h" |
33 |
– |
#include "common.h" |
34 |
|
#include "event.h" |
35 |
– |
#include "hash.h" |
35 |
|
#include "hook.h" |
36 |
|
#include "irc_string.h" |
38 |
– |
#include "sprintf_irc.h" |
37 |
|
#include "s_bsd.h" |
40 |
– |
#include "irc_getaddrinfo.h" |
38 |
|
#include "ircd.h" |
42 |
– |
#include "list.h" |
39 |
|
#include "listener.h" |
40 |
|
#include "hostmask.h" |
41 |
|
#include "modules.h" |
42 |
|
#include "numeric.h" |
43 |
|
#include "fdlist.h" |
44 |
< |
#include "s_log.h" |
44 |
> |
#include "log.h" |
45 |
|
#include "send.h" |
46 |
|
#include "s_gline.h" |
51 |
– |
#include "fileio.h" |
47 |
|
#include "memory.h" |
48 |
|
#include "irc_res.h" |
49 |
|
#include "userhost.h" |
50 |
|
#include "s_user.h" |
51 |
|
#include "channel_mode.h" |
52 |
+ |
#include "parse.h" |
53 |
+ |
#include "s_misc.h" |
54 |
|
|
55 |
|
struct Callback *client_check_cb = NULL; |
56 |
|
struct config_server_hide ConfigServerHide; |
57 |
|
|
58 |
|
/* general conf items link list root, other than k lines etc. */ |
59 |
+ |
dlink_list service_items = { NULL, NULL, 0 }; |
60 |
|
dlink_list server_items = { NULL, NULL, 0 }; |
61 |
|
dlink_list cluster_items = { NULL, NULL, 0 }; |
64 |
– |
dlink_list hub_items = { NULL, NULL, 0 }; |
65 |
– |
dlink_list leaf_items = { NULL, NULL, 0 }; |
62 |
|
dlink_list oconf_items = { NULL, NULL, 0 }; |
63 |
|
dlink_list uconf_items = { NULL, NULL, 0 }; |
64 |
|
dlink_list xconf_items = { NULL, NULL, 0 }; |
68 |
|
dlink_list class_items = { NULL, NULL, 0 }; |
69 |
|
dlink_list gdeny_items = { NULL, NULL, 0 }; |
70 |
|
|
75 |
– |
dlink_list temporary_klines = { NULL, NULL, 0 }; |
76 |
– |
dlink_list temporary_dlines = { NULL, NULL, 0 }; |
71 |
|
dlink_list temporary_xlines = { NULL, NULL, 0 }; |
78 |
– |
dlink_list temporary_rklines = { NULL, NULL, 0 }; |
79 |
– |
dlink_list temporary_glines = { NULL, NULL, 0 }; |
80 |
– |
dlink_list temporary_rxlines = { NULL, NULL, 0 }; |
72 |
|
dlink_list temporary_resv = { NULL, NULL, 0 }; |
73 |
|
|
74 |
|
extern unsigned int lineno; |
75 |
|
extern char linebuf[]; |
76 |
|
extern char conffilebuf[IRCD_BUFSIZE]; |
86 |
– |
extern char yytext[]; |
77 |
|
extern int yyparse(); /* defined in y.tab.c */ |
78 |
< |
int ypass = 1; /* used by yyparse() */ |
78 |
> |
|
79 |
> |
struct conf_parser_context conf_parser_ctx = { 0, 0, NULL }; |
80 |
|
|
81 |
|
/* internally defined functions */ |
82 |
< |
static void lookup_confhost(struct ConfItem *); |
92 |
< |
static void set_default_conf(void); |
93 |
< |
static void validate_conf(void); |
94 |
< |
static void read_conf(FBFILE *); |
82 |
> |
static void read_conf(FILE *); |
83 |
|
static void clear_out_old_conf(void); |
84 |
|
static void flush_deleted_I_P(void); |
85 |
|
static void expire_tklines(dlink_list *); |
102 |
|
|
103 |
|
static void flags_to_ascii(unsigned int, const unsigned int[], char *, int); |
104 |
|
|
117 |
– |
FBFILE *conf_fbfile_in = NULL; |
118 |
– |
|
105 |
|
/* address of default class conf */ |
106 |
|
static struct ConfItem *class_default; |
107 |
|
|
124 |
|
static int ip_entries_count = 0; |
125 |
|
|
126 |
|
|
127 |
< |
inline void * |
127 |
> |
void * |
128 |
|
map_to_conf(struct ConfItem *aconf) |
129 |
|
{ |
130 |
|
void *conf; |
131 |
< |
conf = (void *)((unsigned long)aconf + |
132 |
< |
(unsigned long)sizeof(struct ConfItem)); |
131 |
> |
conf = (void *)((uintptr_t)aconf + |
132 |
> |
(uintptr_t)sizeof(struct ConfItem)); |
133 |
|
return(conf); |
134 |
|
} |
135 |
|
|
136 |
< |
inline struct ConfItem * |
136 |
> |
struct ConfItem * |
137 |
|
unmap_conf_item(void *aconf) |
138 |
|
{ |
139 |
|
struct ConfItem *conf; |
140 |
|
|
141 |
< |
conf = (struct ConfItem *)((unsigned long)aconf - |
142 |
< |
(unsigned long)sizeof(struct ConfItem)); |
141 |
> |
conf = (struct ConfItem *)((uintptr_t)aconf - |
142 |
> |
(uintptr_t)sizeof(struct ConfItem)); |
143 |
|
return(conf); |
144 |
|
} |
145 |
|
|
154 |
|
* if successful save hp in the conf item it was called with |
155 |
|
*/ |
156 |
|
static void |
157 |
< |
conf_dns_callback(void *vptr, struct DNSReply *reply) |
157 |
> |
conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name) |
158 |
|
{ |
159 |
< |
struct AccessItem *aconf = (struct AccessItem *)vptr; |
174 |
< |
struct ConfItem *conf; |
159 |
> |
struct AccessItem *aconf = vptr; |
160 |
|
|
161 |
< |
MyFree(aconf->dns_query); |
177 |
< |
aconf->dns_query = NULL; |
161 |
> |
aconf->dns_pending = 0; |
162 |
|
|
163 |
< |
if (reply != NULL) |
164 |
< |
memcpy(&aconf->ipnum, &reply->addr, sizeof(reply->addr)); |
165 |
< |
else { |
166 |
< |
ilog(L_NOTICE, "Host not found: %s, ignoring connect{} block", |
183 |
< |
aconf->host); |
184 |
< |
conf = unmap_conf_item(aconf); |
185 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
186 |
< |
"Ignoring connect{} block for %s - host not found", |
187 |
< |
conf->name); |
188 |
< |
delete_conf_item(conf); |
189 |
< |
} |
163 |
> |
if (addr != NULL) |
164 |
> |
memcpy(&aconf->addr, addr, sizeof(aconf->addr)); |
165 |
> |
else |
166 |
> |
aconf->dns_failed = 1; |
167 |
|
} |
168 |
|
|
169 |
|
/* conf_dns_lookup() |
175 |
|
static void |
176 |
|
conf_dns_lookup(struct AccessItem *aconf) |
177 |
|
{ |
178 |
< |
if (aconf->dns_query == NULL) |
178 |
> |
if (!aconf->dns_pending) |
179 |
|
{ |
180 |
< |
aconf->dns_query = MyMalloc(sizeof(struct DNSQuery)); |
181 |
< |
aconf->dns_query->ptr = aconf; |
205 |
< |
aconf->dns_query->callback = conf_dns_callback; |
206 |
< |
gethost_byname(aconf->host, aconf->dns_query); |
180 |
> |
aconf->dns_pending = 1; |
181 |
> |
gethost_byname(conf_dns_callback, aconf, aconf->host); |
182 |
|
} |
183 |
|
} |
184 |
|
|
249 |
|
aconf->status = status; |
250 |
|
break; |
251 |
|
|
277 |
– |
case LEAF_TYPE: |
278 |
– |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
279 |
– |
sizeof(struct MatchItem)); |
280 |
– |
dlinkAdd(conf, &conf->node, &leaf_items); |
281 |
– |
break; |
282 |
– |
|
283 |
– |
case HUB_TYPE: |
284 |
– |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
285 |
– |
sizeof(struct MatchItem)); |
286 |
– |
dlinkAdd(conf, &conf->node, &hub_items); |
287 |
– |
break; |
288 |
– |
|
252 |
|
case ULINE_TYPE: |
253 |
|
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
254 |
|
sizeof(struct MatchItem)); |
266 |
|
sizeof(struct MatchItem)); |
267 |
|
dlinkAdd(conf, &conf->node, &xconf_items); |
268 |
|
break; |
269 |
< |
|
269 |
> |
#ifdef HAVE_LIBPCRE |
270 |
|
case RXLINE_TYPE: |
271 |
|
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
272 |
|
sizeof(struct MatchItem)); |
280 |
|
aconf->status = CONF_KLINE; |
281 |
|
dlinkAdd(conf, &conf->node, &rkconf_items); |
282 |
|
break; |
283 |
< |
|
283 |
> |
#endif |
284 |
|
case CLUSTER_TYPE: |
285 |
|
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem)); |
286 |
|
dlinkAdd(conf, &conf->node, &cluster_items); |
297 |
|
dlinkAdd(conf, &conf->node, &nresv_items); |
298 |
|
break; |
299 |
|
|
300 |
+ |
case SERVICE_TYPE: |
301 |
+ |
status = CONF_SERVICE; |
302 |
+ |
conf = MyMalloc(sizeof(struct ConfItem)); |
303 |
+ |
dlinkAdd(conf, &conf->node, &service_items); |
304 |
+ |
break; |
305 |
+ |
|
306 |
|
case CLASS_TYPE: |
307 |
|
conf = MyMalloc(sizeof(struct ConfItem) + |
308 |
|
sizeof(struct ClassItem)); |
310 |
|
|
311 |
|
aclass = map_to_conf(conf); |
312 |
|
aclass->active = 1; |
313 |
< |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
314 |
< |
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
315 |
< |
MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT; |
316 |
< |
MaxSendq(aclass) = DEFAULT_SENDQ; |
313 |
> |
aclass->con_freq = DEFAULT_CONNECTFREQUENCY; |
314 |
> |
aclass->ping_freq = DEFAULT_PINGFREQUENCY; |
315 |
> |
aclass->max_total = MAXIMUM_LINKS_DEFAULT; |
316 |
> |
aclass->max_sendq = DEFAULT_SENDQ; |
317 |
|
|
318 |
|
break; |
319 |
|
|
331 |
|
void |
332 |
|
delete_conf_item(struct ConfItem *conf) |
333 |
|
{ |
334 |
< |
dlink_node *m = NULL; |
334 |
> |
dlink_node *m = NULL, *m_next = NULL; |
335 |
|
struct MatchItem *match_item; |
336 |
|
struct AccessItem *aconf; |
337 |
|
ConfType type = conf->type; |
350 |
|
case SERVER_TYPE: |
351 |
|
aconf = map_to_conf(conf); |
352 |
|
|
353 |
< |
if (aconf->dns_query != NULL) |
354 |
< |
{ |
386 |
< |
delete_resolver_queries(aconf->dns_query); |
387 |
< |
MyFree(aconf->dns_query); |
388 |
< |
} |
353 |
> |
if (aconf->dns_pending) |
354 |
> |
delete_resolver_queries(aconf); |
355 |
|
if (aconf->passwd != NULL) |
356 |
|
memset(aconf->passwd, 0, strlen(aconf->passwd)); |
357 |
|
if (aconf->spasswd != NULL) |
364 |
|
MyFree(aconf->oper_reason); |
365 |
|
MyFree(aconf->user); |
366 |
|
MyFree(aconf->host); |
401 |
– |
MyFree(aconf->fakename); |
367 |
|
#ifdef HAVE_LIBCRYPTO |
368 |
+ |
MyFree(aconf->cipher_list); |
369 |
+ |
|
370 |
|
if (aconf->rsa_public_key) |
371 |
|
RSA_free(aconf->rsa_public_key); |
372 |
|
MyFree(aconf->rsa_public_key_file); |
392 |
|
|
393 |
|
case SERVER_TYPE: |
394 |
|
aconf = map_to_conf(conf); |
395 |
+ |
|
396 |
+ |
DLINK_FOREACH_SAFE(m, m_next, aconf->hub_list.head) |
397 |
+ |
{ |
398 |
+ |
MyFree(m->data); |
399 |
+ |
free_dlink_node(m); |
400 |
+ |
} |
401 |
+ |
|
402 |
+ |
DLINK_FOREACH_SAFE(m, m_next, aconf->leaf_list.head) |
403 |
+ |
{ |
404 |
+ |
MyFree(m->data); |
405 |
+ |
free_dlink_node(m); |
406 |
+ |
} |
407 |
+ |
|
408 |
|
if (!IsConfIllegal(aconf)) |
409 |
|
dlinkDelete(&conf->node, &server_items); |
410 |
|
MyFree(conf); |
415 |
|
} |
416 |
|
break; |
417 |
|
|
438 |
– |
case HUB_TYPE: |
439 |
– |
match_item = map_to_conf(conf); |
440 |
– |
MyFree(match_item->user); |
441 |
– |
MyFree(match_item->host); |
442 |
– |
MyFree(match_item->reason); |
443 |
– |
MyFree(match_item->oper_reason); |
444 |
– |
/* If marked illegal, its already been pulled off of the hub_items list */ |
445 |
– |
if (!match_item->illegal) |
446 |
– |
dlinkDelete(&conf->node, &hub_items); |
447 |
– |
MyFree(conf); |
448 |
– |
break; |
449 |
– |
|
450 |
– |
case LEAF_TYPE: |
451 |
– |
match_item = map_to_conf(conf); |
452 |
– |
MyFree(match_item->user); |
453 |
– |
MyFree(match_item->host); |
454 |
– |
MyFree(match_item->reason); |
455 |
– |
MyFree(match_item->oper_reason); |
456 |
– |
/* If marked illegal, its already been pulled off of the leaf_items list */ |
457 |
– |
if (!match_item->illegal) |
458 |
– |
dlinkDelete(&conf->node, &leaf_items); |
459 |
– |
MyFree(conf); |
460 |
– |
break; |
461 |
– |
|
418 |
|
case ULINE_TYPE: |
419 |
|
match_item = map_to_conf(conf); |
420 |
|
MyFree(match_item->user); |
434 |
|
dlinkDelete(&conf->node, &xconf_items); |
435 |
|
MyFree(conf); |
436 |
|
break; |
437 |
< |
|
437 |
> |
#ifdef HAVE_LIBPCRE |
438 |
|
case RKLINE_TYPE: |
439 |
|
aconf = map_to_conf(conf); |
440 |
|
MyFree(aconf->regexuser); |
457 |
|
dlinkDelete(&conf->node, &rxconf_items); |
458 |
|
MyFree(conf); |
459 |
|
break; |
460 |
< |
|
460 |
> |
#endif |
461 |
|
case NRESV_TYPE: |
462 |
|
match_item = map_to_conf(conf); |
463 |
|
MyFree(match_item->user); |
499 |
|
MyFree(conf); |
500 |
|
break; |
501 |
|
|
502 |
+ |
case SERVICE_TYPE: |
503 |
+ |
dlinkDelete(&conf->node, &service_items); |
504 |
+ |
MyFree(conf); |
505 |
+ |
break; |
506 |
+ |
|
507 |
|
default: |
508 |
|
break; |
509 |
|
} |
537 |
|
* side effects - |
538 |
|
*/ |
539 |
|
void |
540 |
< |
report_confitem_types(struct Client *source_p, ConfType type, int temp) |
540 |
> |
report_confitem_types(struct Client *source_p, ConfType type) |
541 |
|
{ |
542 |
< |
dlink_node *ptr = NULL; |
542 |
> |
dlink_node *ptr = NULL, *dptr = NULL; |
543 |
|
struct ConfItem *conf = NULL; |
544 |
|
struct AccessItem *aconf = NULL; |
545 |
|
struct MatchItem *matchitem = NULL; |
546 |
|
struct ClassItem *classitem = NULL; |
547 |
|
char buf[12]; |
548 |
|
char *p = NULL; |
588 |
– |
const char *pfx = NULL; |
549 |
|
|
550 |
|
switch (type) |
551 |
|
{ |
588 |
|
} |
589 |
|
break; |
590 |
|
|
591 |
+ |
#ifdef HAVE_LIBPCRE |
592 |
|
case RXLINE_TYPE: |
593 |
|
DLINK_FOREACH(ptr, rxconf_items.head) |
594 |
|
{ |
597 |
|
|
598 |
|
sendto_one(source_p, form_str(RPL_STATSXLINE), |
599 |
|
me.name, source_p->name, |
600 |
< |
matchitem->hold ? "xR": "XR", matchitem->count, |
600 |
> |
"XR", matchitem->count, |
601 |
|
conf->name, matchitem->reason); |
602 |
|
} |
603 |
|
break; |
604 |
|
|
605 |
|
case RKLINE_TYPE: |
645 |
– |
pfx = temp ? "kR" : "KR"; |
646 |
– |
|
606 |
|
DLINK_FOREACH(ptr, rkconf_items.head) |
607 |
|
{ |
608 |
|
aconf = map_to_conf((conf = ptr->data)); |
609 |
|
|
651 |
– |
if (temp && !(conf->flags & CONF_FLAGS_TEMPORARY)) |
652 |
– |
continue; |
653 |
– |
|
610 |
|
sendto_one(source_p, form_str(RPL_STATSKLINE), me.name, |
611 |
< |
source_p->name, pfx, aconf->host, aconf->user, |
611 |
> |
source_p->name, "KR", aconf->host, aconf->user, |
612 |
|
aconf->reason, aconf->oper_reason ? aconf->oper_reason : ""); |
613 |
|
} |
614 |
|
break; |
615 |
+ |
#endif |
616 |
|
|
617 |
|
case ULINE_TYPE: |
618 |
|
DLINK_FOREACH(ptr, uconf_items.head) |
657 |
|
aconf = map_to_conf(conf); |
658 |
|
|
659 |
|
/* Don't allow non opers to see oper privs */ |
660 |
< |
if (IsOper(source_p)) |
660 |
> |
if (HasUMode(source_p, UMODE_OPER)) |
661 |
|
sendto_one(source_p, form_str(RPL_STATSOLINE), |
662 |
|
me.name, source_p->name, 'O', aconf->user, aconf->host, |
663 |
|
conf->name, oper_privs_as_string(aconf->port), |
677 |
|
classitem = map_to_conf(conf); |
678 |
|
sendto_one(source_p, form_str(RPL_STATSYLINE), |
679 |
|
me.name, source_p->name, 'Y', |
680 |
< |
conf->name, PingFreq(classitem), |
681 |
< |
ConFreq(classitem), |
682 |
< |
MaxTotal(classitem), MaxSendq(classitem), |
683 |
< |
CurrUserCount(classitem), |
680 |
> |
conf->name, classitem->ping_freq, |
681 |
> |
classitem->con_freq, |
682 |
> |
classitem->max_total, classitem->max_sendq, |
683 |
> |
classitem->curr_user_count, |
684 |
|
classitem->active ? "active" : "disabled"); |
685 |
|
} |
686 |
|
break; |
689 |
|
case CLIENT_TYPE: |
690 |
|
break; |
691 |
|
|
692 |
+ |
case SERVICE_TYPE: |
693 |
+ |
DLINK_FOREACH(ptr, service_items.head) |
694 |
+ |
{ |
695 |
+ |
conf = ptr->data; |
696 |
+ |
sendto_one(source_p, form_str(RPL_STATSSERVICE), |
697 |
+ |
me.name, source_p->name, 'S', "*", conf->name, 0, 0); |
698 |
+ |
} |
699 |
+ |
break; |
700 |
+ |
|
701 |
|
case SERVER_TYPE: |
702 |
|
DLINK_FOREACH(ptr, server_items.head) |
703 |
|
{ |
710 |
|
|
711 |
|
if (IsConfAllowAutoConn(aconf)) |
712 |
|
*p++ = 'A'; |
713 |
< |
if (IsConfCryptLink(aconf)) |
714 |
< |
*p++ = 'C'; |
749 |
< |
if (aconf->fakename) |
750 |
< |
*p++ = 'M'; |
713 |
> |
if (IsConfSSL(aconf)) |
714 |
> |
*p++ = 'S'; |
715 |
|
if (IsConfTopicBurst(aconf)) |
716 |
|
*p++ = 'T'; |
753 |
– |
if (IsConfCompressed(aconf)) |
754 |
– |
*p++ = 'Z'; |
717 |
|
if (buf[0] == '\0') |
718 |
|
*p++ = '*'; |
719 |
|
|
722 |
|
/* |
723 |
|
* Allow admins to see actual ips unless hide_server_ips is enabled |
724 |
|
*/ |
725 |
< |
if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p)) |
725 |
> |
if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN)) |
726 |
|
sendto_one(source_p, form_str(RPL_STATSCLINE), |
727 |
|
me.name, source_p->name, 'C', aconf->host, |
728 |
|
buf, conf->name, aconf->port, |
736 |
|
break; |
737 |
|
|
738 |
|
case HUB_TYPE: |
739 |
< |
DLINK_FOREACH(ptr, hub_items.head) |
739 |
> |
DLINK_FOREACH(ptr, server_items.head) |
740 |
|
{ |
741 |
|
conf = ptr->data; |
742 |
< |
matchitem = map_to_conf(conf); |
743 |
< |
sendto_one(source_p, form_str(RPL_STATSHLINE), me.name, |
744 |
< |
source_p->name, 'H', matchitem->host, conf->name, 0, "*"); |
742 |
> |
aconf = map_to_conf(conf); |
743 |
> |
|
744 |
> |
DLINK_FOREACH(dptr, aconf->hub_list.head) |
745 |
> |
sendto_one(source_p, form_str(RPL_STATSHLINE), me.name, |
746 |
> |
source_p->name, 'H', dptr->data, conf->name, 0, "*"); |
747 |
|
} |
748 |
|
break; |
749 |
|
|
750 |
|
case LEAF_TYPE: |
751 |
< |
DLINK_FOREACH(ptr, leaf_items.head) |
751 |
> |
DLINK_FOREACH(ptr, server_items.head) |
752 |
|
{ |
753 |
|
conf = ptr->data; |
754 |
< |
matchitem = map_to_conf(conf); |
755 |
< |
sendto_one(source_p, form_str(RPL_STATSLLINE), me.name, |
756 |
< |
source_p->name, 'L', matchitem->host, conf->name, 0, "*"); |
754 |
> |
aconf = map_to_conf(conf); |
755 |
> |
|
756 |
> |
DLINK_FOREACH(dptr, aconf->leaf_list.head) |
757 |
> |
sendto_one(source_p, form_str(RPL_STATSLLINE), me.name, |
758 |
> |
source_p->name, 'L', dptr->data, conf->name, 0, "*"); |
759 |
|
} |
760 |
|
break; |
761 |
|
|
766 |
|
case CRESV_TYPE: |
767 |
|
case NRESV_TYPE: |
768 |
|
case CLUSTER_TYPE: |
769 |
+ |
default: |
770 |
|
break; |
771 |
|
} |
772 |
|
} |
793 |
|
|
794 |
|
/* I'm already in big trouble if source_p->localClient is NULL -db */ |
795 |
|
if ((i = verify_access(source_p, username))) |
796 |
< |
ilog(L_INFO, "Access denied: %s[%s]", |
796 |
> |
ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]", |
797 |
|
source_p->name, source_p->sockhost); |
798 |
|
|
799 |
|
switch (i) |
803 |
|
"Too many on IP for %s (%s).", |
804 |
|
get_client_name(source_p, SHOW_IP), |
805 |
|
source_p->sockhost); |
806 |
< |
ilog(L_INFO,"Too many connections on IP from %s.", |
806 |
> |
ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.", |
807 |
|
get_client_name(source_p, SHOW_IP)); |
808 |
|
++ServerStats.is_ref; |
809 |
|
exit_client(source_p, &me, "No more connections allowed on that IP"); |
814 |
|
"I-line is full for %s (%s).", |
815 |
|
get_client_name(source_p, SHOW_IP), |
816 |
|
source_p->sockhost); |
817 |
< |
ilog(L_INFO,"Too many connections from %s.", |
817 |
> |
ilog(LOG_TYPE_IRCD, "Too many connections from %s.", |
818 |
|
get_client_name(source_p, SHOW_IP)); |
819 |
|
++ServerStats.is_ref; |
820 |
|
exit_client(source_p, &me, |
831 |
|
source_p->sockhost, |
832 |
|
source_p->localClient->listener->name, |
833 |
|
source_p->localClient->listener->port); |
834 |
< |
ilog(L_INFO, |
834 |
> |
ilog(LOG_TYPE_IRCD, |
835 |
|
"Unauthorized client connection from %s on [%s/%u].", |
836 |
|
get_client_name(source_p, SHOW_IP), |
837 |
|
source_p->localClient->listener->name, |
994 |
|
* setting a_limit_reached if any limit is reached. |
995 |
|
* - Dianora |
996 |
|
*/ |
997 |
< |
if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass)) |
997 |
> |
if (aclass->max_total != 0 && aclass->curr_user_count >= aclass->max_total) |
998 |
|
a_limit_reached = 1; |
999 |
< |
else if (MaxPerIp(aclass) != 0 && ip_found->count > MaxPerIp(aclass)) |
999 |
> |
else if (aclass->max_perip != 0 && ip_found->count > aclass->max_perip) |
1000 |
|
a_limit_reached = 1; |
1001 |
< |
else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass)) |
1001 |
> |
else if (aclass->max_local != 0 && local >= aclass->max_local) |
1002 |
|
a_limit_reached = 1; |
1003 |
< |
else if (MaxGlobal(aclass) != 0 && global >= MaxGlobal(aclass)) |
1003 |
> |
else if (aclass->max_global != 0 && global >= aclass->max_global) |
1004 |
|
a_limit_reached = 1; |
1005 |
< |
else if (MaxIdent(aclass) != 0 && ident >= MaxIdent(aclass) && |
1005 |
> |
else if (aclass->max_ident != 0 && ident >= aclass->max_ident && |
1006 |
|
client_p->username[0] != '~') |
1007 |
|
a_limit_reached = 1; |
1008 |
|
|
1158 |
|
{ |
1159 |
|
struct sockaddr_in *v4 = (struct sockaddr_in *)addr; |
1160 |
|
int hash; |
1161 |
< |
u_int32_t ip; |
1161 |
> |
uint32_t ip; |
1162 |
|
|
1163 |
|
ip = ntohl(v4->sin_addr.s_addr); |
1164 |
|
hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1); |
1169 |
|
{ |
1170 |
|
int hash; |
1171 |
|
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr; |
1172 |
< |
u_int32_t *ip = (u_int32_t *)&v6->sin6_addr.s6_addr; |
1172 |
> |
uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr; |
1173 |
|
|
1174 |
|
hash = ip[0] ^ ip[3]; |
1175 |
|
hash ^= hash >> 16; |
1193 |
|
* used in the hash. |
1194 |
|
*/ |
1195 |
|
void |
1196 |
< |
count_ip_hash(int *number_ips_stored, unsigned long *mem_ips_stored) |
1196 |
> |
count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored) |
1197 |
|
{ |
1198 |
|
struct ip_entry *ptr; |
1199 |
|
int i; |
1285 |
|
|
1286 |
|
assert(aconf->clients > 0); |
1287 |
|
|
1288 |
< |
if ((aclass_conf = ClassPtr(aconf)) != NULL) |
1288 |
> |
if ((aclass_conf = aconf->class_ptr) != NULL) |
1289 |
|
{ |
1290 |
|
aclass = map_to_conf(aclass_conf); |
1291 |
|
|
1301 |
|
delete_conf_item(conf); |
1302 |
|
|
1303 |
|
break; |
1337 |
– |
|
1338 |
– |
case LEAF_TYPE: |
1339 |
– |
case HUB_TYPE: |
1340 |
– |
match_item = map_to_conf(conf); |
1341 |
– |
if (match_item->ref_count == 0 && match_item->illegal) |
1342 |
– |
delete_conf_item(conf); |
1343 |
– |
break; |
1304 |
|
default: |
1305 |
|
break; |
1306 |
|
} |
1326 |
|
int |
1327 |
|
attach_conf(struct Client *client_p, struct ConfItem *conf) |
1328 |
|
{ |
1329 |
+ |
struct AccessItem *aconf = map_to_conf(conf); |
1330 |
+ |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1331 |
+ |
|
1332 |
|
if (dlinkFind(&client_p->localClient->confs, conf) != NULL) |
1333 |
|
return 1; |
1334 |
|
|
1335 |
< |
if (conf->type == CLIENT_TYPE || |
1336 |
< |
conf->type == SERVER_TYPE || |
1374 |
< |
conf->type == OPER_TYPE) |
1375 |
< |
{ |
1376 |
< |
struct AccessItem *aconf = map_to_conf(conf); |
1377 |
< |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1335 |
> |
if (IsConfIllegal(aconf)) /* TBV: can't happen */ |
1336 |
> |
return NOT_AUTHORIZED; |
1337 |
|
|
1338 |
< |
if (IsConfIllegal(aconf)) |
1339 |
< |
return NOT_AUTHORIZED; |
1338 |
> |
if (conf->type == CLIENT_TYPE) |
1339 |
> |
if (cidr_limit_reached(IsConfExemptLimits(aconf), |
1340 |
> |
&client_p->localClient->ip, aclass)) |
1341 |
> |
return TOO_MANY; /* Already at maximum allowed */ |
1342 |
|
|
1343 |
< |
if (conf->type == CLIENT_TYPE) |
1344 |
< |
if (cidr_limit_reached(IsConfExemptLimits(aconf), |
1384 |
< |
&client_p->localClient->ip, aclass)) |
1385 |
< |
return TOO_MANY; /* Already at maximum allowed */ |
1386 |
< |
|
1387 |
< |
CurrUserCount(aclass)++; |
1388 |
< |
aconf->clients++; |
1389 |
< |
} |
1390 |
< |
else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE) |
1391 |
< |
{ |
1392 |
< |
struct MatchItem *match_item = map_to_conf(conf); |
1393 |
< |
match_item->ref_count++; |
1394 |
< |
} |
1343 |
> |
aclass->curr_user_count++; |
1344 |
> |
aconf->clients++; |
1345 |
|
|
1346 |
|
dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs); |
1347 |
|
|
1430 |
|
{ |
1431 |
|
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
1432 |
|
|
1433 |
< |
if (aconf->clients >= MaxTotal(aclass)) |
1433 |
> |
if (aconf->clients >= aclass->max_total) |
1434 |
|
continue; |
1435 |
|
} |
1436 |
|
|
1502 |
|
case SERVER_TYPE: |
1503 |
|
return(&server_items); |
1504 |
|
break; |
1505 |
+ |
case SERVICE_TYPE: |
1506 |
+ |
return(&service_items); |
1507 |
+ |
break; |
1508 |
|
case CLUSTER_TYPE: |
1509 |
|
return(&cluster_items); |
1510 |
|
break; |
1540 |
|
|
1541 |
|
switch (type) |
1542 |
|
{ |
1543 |
< |
case RXLINE_TYPE: |
1543 |
> |
#ifdef HAVE_LIBPCRE |
1544 |
> |
case RXLINE_TYPE: |
1545 |
|
DLINK_FOREACH(ptr, list_p->head) |
1546 |
|
{ |
1547 |
|
conf = ptr->data; |
1551 |
|
return conf; |
1552 |
|
} |
1553 |
|
break; |
1554 |
+ |
#endif |
1555 |
+ |
case SERVICE_TYPE: |
1556 |
+ |
DLINK_FOREACH(ptr, list_p->head) |
1557 |
+ |
{ |
1558 |
+ |
conf = ptr->data; |
1559 |
+ |
|
1560 |
+ |
if (EmptyString(conf->name)) |
1561 |
+ |
continue; |
1562 |
+ |
if ((name != NULL) && !irccmp(name, conf->name)) |
1563 |
+ |
return conf; |
1564 |
+ |
} |
1565 |
+ |
break; |
1566 |
|
|
1567 |
|
case XLINE_TYPE: |
1568 |
|
case ULINE_TYPE: |
1617 |
|
* side effects - looks for an exact match on name field |
1618 |
|
*/ |
1619 |
|
struct ConfItem * |
1620 |
< |
find_exact_name_conf(ConfType type, const char *name, |
1620 |
> |
find_exact_name_conf(ConfType type, const struct Client *who, const char *name, |
1621 |
|
const char *user, const char *host) |
1622 |
|
{ |
1623 |
|
dlink_node *ptr = NULL; |
1658 |
|
DLINK_FOREACH(ptr, list_p->head) |
1659 |
|
{ |
1660 |
|
conf = ptr->data; |
1661 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
1661 |
> |
aconf = map_to_conf(conf); |
1662 |
> |
|
1663 |
|
if (EmptyString(conf->name)) |
1664 |
< |
continue; |
1665 |
< |
|
1666 |
< |
if (irccmp(conf->name, name) == 0) |
1664 |
> |
continue; |
1665 |
> |
|
1666 |
> |
if (!irccmp(conf->name, name)) |
1667 |
|
{ |
1668 |
< |
if ((user == NULL && (host == NULL))) |
1669 |
< |
return (conf); |
1670 |
< |
if (EmptyString(aconf->user) || EmptyString(aconf->host)) |
1671 |
< |
return (conf); |
1672 |
< |
if (match(aconf->user, user) && match(aconf->host, host)) |
1673 |
< |
return (conf); |
1668 |
> |
if (!who) |
1669 |
> |
return conf; |
1670 |
> |
if (EmptyString(aconf->user) || EmptyString(aconf->host)) |
1671 |
> |
return conf; |
1672 |
> |
if (match(aconf->user, who->username)) |
1673 |
> |
{ |
1674 |
> |
switch (aconf->type) |
1675 |
> |
{ |
1676 |
> |
case HM_HOST: |
1677 |
> |
if (match(aconf->host, who->host) || match(aconf->host, who->sockhost)) |
1678 |
> |
return conf; |
1679 |
> |
break; |
1680 |
> |
case HM_IPV4: |
1681 |
> |
if (who->localClient->aftype == AF_INET) |
1682 |
> |
if (match_ipv4(&who->localClient->ip, &aconf->addr, aconf->bits)) |
1683 |
> |
return conf; |
1684 |
> |
break; |
1685 |
> |
#ifdef IPV6 |
1686 |
> |
case HM_IPV6: |
1687 |
> |
if (who->localClient->aftype == AF_INET6) |
1688 |
> |
if (match_ipv6(&who->localClient->ip, &aconf->addr, aconf->bits)) |
1689 |
> |
return conf; |
1690 |
> |
break; |
1691 |
> |
#endif |
1692 |
> |
default: |
1693 |
> |
assert(0); |
1694 |
> |
} |
1695 |
> |
} |
1696 |
|
} |
1697 |
|
} |
1698 |
+ |
|
1699 |
|
break; |
1700 |
|
|
1701 |
|
case SERVER_TYPE: |
1751 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
1752 |
|
"Got signal SIGHUP, reloading ircd.conf file"); |
1753 |
|
|
1764 |
– |
#ifndef _WIN32 |
1754 |
|
restart_resolver(); |
1755 |
< |
#endif |
1755 |
> |
|
1756 |
|
/* don't close listeners until we know we can go ahead with the rehash */ |
1757 |
|
|
1758 |
|
/* Check to see if we magically got(or lost) IPv6 support */ |
1763 |
|
if (ServerInfo.description != NULL) |
1764 |
|
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
1765 |
|
|
1777 |
– |
#ifndef STATIC_MODULES |
1766 |
|
load_conf_modules(); |
1779 |
– |
#endif |
1767 |
|
|
1768 |
|
flush_deleted_I_P(); |
1769 |
|
|
1770 |
|
rehashed_klines = 1; |
1771 |
< |
|
1771 |
> |
/* XXX */ |
1772 |
|
if (ConfigLoggingEntry.use_logging) |
1773 |
< |
reopen_log(logFileName); |
1773 |
> |
log_close_all(); |
1774 |
|
|
1775 |
|
return(0); |
1776 |
|
} |
1809 |
|
ServerInfo.specific_ipv6_vhost = 0; |
1810 |
|
|
1811 |
|
ServerInfo.max_clients = MAXCLIENTS_MAX; |
1812 |
< |
/* Don't reset hub, as that will break lazylinks */ |
1813 |
< |
/* ServerInfo.hub = NO; */ |
1812 |
> |
|
1813 |
> |
ServerInfo.hub = 0; |
1814 |
|
ServerInfo.dns_host.sin_addr.s_addr = 0; |
1815 |
|
ServerInfo.dns_host.sin_port = 0; |
1816 |
|
AdminInfo.name = NULL; |
1817 |
|
AdminInfo.email = NULL; |
1818 |
|
AdminInfo.description = NULL; |
1819 |
|
|
1820 |
< |
set_log_level(L_NOTICE); |
1820 |
> |
log_close_all(); |
1821 |
> |
|
1822 |
|
ConfigLoggingEntry.use_logging = 1; |
1823 |
< |
ConfigLoggingEntry.operlog[0] = '\0'; |
1824 |
< |
ConfigLoggingEntry.userlog[0] = '\0'; |
1825 |
< |
ConfigLoggingEntry.klinelog[0] = '\0'; |
1826 |
< |
ConfigLoggingEntry.glinelog[0] = '\0'; |
1827 |
< |
ConfigLoggingEntry.killlog[0] = '\0'; |
1828 |
< |
ConfigLoggingEntry.operspylog[0] = '\0'; |
1829 |
< |
ConfigLoggingEntry.ioerrlog[0] = '\0'; |
1842 |
< |
ConfigLoggingEntry.failed_operlog[0] = '\0'; |
1843 |
< |
|
1844 |
< |
ConfigChannel.disable_fake_channels = NO; |
1845 |
< |
ConfigChannel.restrict_channels = NO; |
1846 |
< |
ConfigChannel.disable_local_channels = NO; |
1847 |
< |
ConfigChannel.use_invex = YES; |
1848 |
< |
ConfigChannel.use_except = YES; |
1849 |
< |
ConfigChannel.use_knock = YES; |
1823 |
> |
|
1824 |
> |
ConfigChannel.disable_fake_channels = 0; |
1825 |
> |
ConfigChannel.restrict_channels = 0; |
1826 |
> |
ConfigChannel.disable_local_channels = 0; |
1827 |
> |
ConfigChannel.use_invex = 1; |
1828 |
> |
ConfigChannel.use_except = 1; |
1829 |
> |
ConfigChannel.use_knock = 1; |
1830 |
|
ConfigChannel.knock_delay = 300; |
1831 |
|
ConfigChannel.knock_delay_channel = 60; |
1832 |
|
ConfigChannel.max_chans_per_user = 15; |
1833 |
< |
ConfigChannel.quiet_on_ban = YES; |
1833 |
> |
ConfigChannel.quiet_on_ban = 1; |
1834 |
|
ConfigChannel.max_bans = 25; |
1835 |
|
ConfigChannel.default_split_user_count = 0; |
1836 |
|
ConfigChannel.default_split_server_count = 0; |
1837 |
< |
ConfigChannel.no_join_on_split = NO; |
1838 |
< |
ConfigChannel.no_create_on_split = NO; |
1859 |
< |
ConfigChannel.burst_topicwho = YES; |
1837 |
> |
ConfigChannel.no_join_on_split = 0; |
1838 |
> |
ConfigChannel.no_create_on_split = 0; |
1839 |
|
|
1840 |
< |
ConfigServerHide.flatten_links = NO; |
1840 |
> |
ConfigServerHide.flatten_links = 0; |
1841 |
|
ConfigServerHide.links_delay = 300; |
1842 |
< |
ConfigServerHide.hidden = NO; |
1843 |
< |
ConfigServerHide.disable_hidden = NO; |
1844 |
< |
ConfigServerHide.hide_servers = NO; |
1842 |
> |
ConfigServerHide.hidden = 0; |
1843 |
> |
ConfigServerHide.disable_hidden = 0; |
1844 |
> |
ConfigServerHide.hide_servers = 0; |
1845 |
|
DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT); |
1846 |
< |
ConfigServerHide.hide_server_ips = NO; |
1846 |
> |
ConfigServerHide.hide_server_ips = 0; |
1847 |
|
|
1848 |
|
|
1849 |
+ |
DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT); |
1850 |
|
ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT; |
1851 |
|
ConfigFileEntry.gline_min_cidr = 16; |
1852 |
|
ConfigFileEntry.gline_min_cidr6 = 48; |
1853 |
< |
ConfigFileEntry.invisible_on_connect = YES; |
1854 |
< |
ConfigFileEntry.burst_away = NO; |
1855 |
< |
ConfigFileEntry.use_whois_actually = YES; |
1856 |
< |
ConfigFileEntry.tkline_expire_notices = YES; |
1857 |
< |
ConfigFileEntry.hide_spoof_ips = YES; |
1858 |
< |
ConfigFileEntry.ignore_bogus_ts = NO; |
1859 |
< |
ConfigFileEntry.disable_auth = NO; |
1860 |
< |
ConfigFileEntry.disable_remote = NO; |
1853 |
> |
ConfigFileEntry.invisible_on_connect = 1; |
1854 |
> |
ConfigFileEntry.burst_away = 0; |
1855 |
> |
ConfigFileEntry.use_whois_actually = 1; |
1856 |
> |
ConfigFileEntry.tkline_expire_notices = 1; |
1857 |
> |
ConfigFileEntry.hide_spoof_ips = 1; |
1858 |
> |
ConfigFileEntry.ignore_bogus_ts = 0; |
1859 |
> |
ConfigFileEntry.disable_auth = 0; |
1860 |
> |
ConfigFileEntry.disable_remote = 0; |
1861 |
|
ConfigFileEntry.kill_chase_time_limit = 90; |
1862 |
< |
ConfigFileEntry.default_floodcount = 8; /* XXX */ |
1863 |
< |
ConfigFileEntry.failed_oper_notice = YES; |
1864 |
< |
ConfigFileEntry.dots_in_ident = 0; /* XXX */ |
1885 |
< |
ConfigFileEntry.dot_in_ip6_addr = YES; |
1862 |
> |
ConfigFileEntry.default_floodcount = 8; |
1863 |
> |
ConfigFileEntry.failed_oper_notice = 1; |
1864 |
> |
ConfigFileEntry.dots_in_ident = 0; |
1865 |
|
ConfigFileEntry.min_nonwildcard = 4; |
1866 |
|
ConfigFileEntry.min_nonwildcard_simple = 3; |
1867 |
|
ConfigFileEntry.max_accept = 20; |
1868 |
< |
ConfigFileEntry.anti_nick_flood = NO; /* XXX */ |
1868 |
> |
ConfigFileEntry.anti_nick_flood = 0; |
1869 |
|
ConfigFileEntry.max_nick_time = 20; |
1870 |
|
ConfigFileEntry.max_nick_changes = 5; |
1871 |
< |
ConfigFileEntry.anti_spam_exit_message_time = 0; /* XXX */ |
1871 |
> |
ConfigFileEntry.anti_spam_exit_message_time = 0; |
1872 |
|
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
1873 |
< |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; /* XXX */ |
1874 |
< |
ConfigFileEntry.kline_with_reason = YES; |
1873 |
> |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
1874 |
> |
ConfigFileEntry.kline_with_reason = 1; |
1875 |
|
ConfigFileEntry.kline_reason = NULL; |
1876 |
< |
ConfigFileEntry.warn_no_nline = YES; |
1877 |
< |
ConfigFileEntry.stats_o_oper_only = NO; /* XXX */ |
1876 |
> |
ConfigFileEntry.warn_no_nline = 1; |
1877 |
> |
ConfigFileEntry.stats_o_oper_only = 0; |
1878 |
|
ConfigFileEntry.stats_k_oper_only = 1; /* masked */ |
1879 |
|
ConfigFileEntry.stats_i_oper_only = 1; /* masked */ |
1880 |
< |
ConfigFileEntry.stats_P_oper_only = NO; |
1880 |
> |
ConfigFileEntry.stats_P_oper_only = 0; |
1881 |
|
ConfigFileEntry.caller_id_wait = 60; |
1882 |
< |
ConfigFileEntry.opers_bypass_callerid = NO; |
1882 |
> |
ConfigFileEntry.opers_bypass_callerid = 0; |
1883 |
|
ConfigFileEntry.pace_wait = 10; |
1884 |
|
ConfigFileEntry.pace_wait_simple = 1; |
1885 |
< |
ConfigFileEntry.short_motd = NO; |
1886 |
< |
ConfigFileEntry.ping_cookie = NO; |
1887 |
< |
ConfigFileEntry.no_oper_flood = NO; /* XXX */ |
1888 |
< |
ConfigFileEntry.true_no_oper_flood = NO; /* XXX */ |
1889 |
< |
ConfigFileEntry.oper_pass_resv = YES; |
1890 |
< |
ConfigFileEntry.glines = NO; /* XXX */ |
1891 |
< |
ConfigFileEntry.gline_time = 12 * 3600; /* XXX */ |
1913 |
< |
ConfigFileEntry.idletime = 0; |
1885 |
> |
ConfigFileEntry.short_motd = 0; |
1886 |
> |
ConfigFileEntry.ping_cookie = 0; |
1887 |
> |
ConfigFileEntry.no_oper_flood = 0; |
1888 |
> |
ConfigFileEntry.true_no_oper_flood = 0; |
1889 |
> |
ConfigFileEntry.oper_pass_resv = 1; |
1890 |
> |
ConfigFileEntry.glines = 0; |
1891 |
> |
ConfigFileEntry.gline_time = 12 * 3600; |
1892 |
|
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; |
1893 |
|
ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT; |
1894 |
< |
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; /* XXX */ |
1894 |
> |
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; |
1895 |
|
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | |
1896 |
< |
UMODE_OPERWALL | UMODE_WALLOP; /* XXX */ |
1897 |
< |
DupString(ConfigFileEntry.servlink_path, SLPATH); |
1920 |
< |
#ifdef HAVE_LIBCRYPTO |
1921 |
< |
/* jdc -- This is our default value for a cipher. According to the |
1922 |
< |
* CRYPTLINK document (doc/cryptlink.txt), BF/128 must be supported |
1923 |
< |
* under all circumstances if cryptlinks are enabled. So, |
1924 |
< |
* this will be our default. |
1925 |
< |
* |
1926 |
< |
* NOTE: I apologise for the hard-coded value of "1" (BF/128). |
1927 |
< |
* This should be moved into a find_cipher() routine. |
1928 |
< |
*/ |
1929 |
< |
ConfigFileEntry.default_cipher_preference = &CipherTable[1]; |
1930 |
< |
#endif |
1931 |
< |
ConfigFileEntry.use_egd = NO; |
1896 |
> |
UMODE_OPERWALL | UMODE_WALLOP; |
1897 |
> |
ConfigFileEntry.use_egd = 0; |
1898 |
|
ConfigFileEntry.egdpool_path = NULL; |
1933 |
– |
#ifdef HAVE_LIBZ |
1934 |
– |
ConfigFileEntry.compression_level = 0; |
1935 |
– |
#endif |
1899 |
|
ConfigFileEntry.throttle_time = 10; |
1900 |
|
} |
1901 |
|
|
1939 |
– |
/* read_conf() |
1940 |
– |
* |
1941 |
– |
* inputs - file descriptor pointing to config file to use |
1942 |
– |
* output - None |
1943 |
– |
* side effects - Read configuration file. |
1944 |
– |
*/ |
1945 |
– |
static void |
1946 |
– |
read_conf(FBFILE *file) |
1947 |
– |
{ |
1948 |
– |
lineno = 0; |
1949 |
– |
|
1950 |
– |
set_default_conf(); /* Set default values prior to conf parsing */ |
1951 |
– |
ypass = 1; |
1952 |
– |
yyparse(); /* pick up the classes first */ |
1953 |
– |
|
1954 |
– |
fbrewind(file); |
1955 |
– |
|
1956 |
– |
ypass = 2; |
1957 |
– |
yyparse(); /* Load the values from the conf */ |
1958 |
– |
validate_conf(); /* Check to make sure some values are still okay. */ |
1959 |
– |
/* Some global values are also loaded here. */ |
1960 |
– |
check_class(); /* Make sure classes are valid */ |
1961 |
– |
} |
1962 |
– |
|
1902 |
|
static void |
1903 |
|
validate_conf(void) |
1904 |
|
{ |
1908 |
|
if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN) |
1909 |
|
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
1910 |
|
|
1972 |
– |
if (ConfigFileEntry.servlink_path == NULL) |
1973 |
– |
DupString(ConfigFileEntry.servlink_path, SLPATH); |
1974 |
– |
|
1911 |
|
if (ServerInfo.network_name == NULL) |
1912 |
|
DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT); |
1913 |
|
|
1914 |
|
if (ServerInfo.network_desc == NULL) |
1915 |
|
DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT); |
1916 |
|
|
1917 |
+ |
if (ConfigFileEntry.service_name == NULL) |
1918 |
+ |
DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT); |
1919 |
+ |
|
1920 |
|
if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) || |
1921 |
|
(ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX)) |
1922 |
|
ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX; |
1924 |
|
ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN); |
1925 |
|
} |
1926 |
|
|
1927 |
+ |
/* read_conf() |
1928 |
+ |
* |
1929 |
+ |
* inputs - file descriptor pointing to config file to use |
1930 |
+ |
* output - None |
1931 |
+ |
* side effects - Read configuration file. |
1932 |
+ |
*/ |
1933 |
+ |
static void |
1934 |
+ |
read_conf(FILE *file) |
1935 |
+ |
{ |
1936 |
+ |
lineno = 0; |
1937 |
+ |
|
1938 |
+ |
set_default_conf(); /* Set default values prior to conf parsing */ |
1939 |
+ |
conf_parser_ctx.pass = 1; |
1940 |
+ |
yyparse(); /* pick up the classes first */ |
1941 |
+ |
|
1942 |
+ |
rewind(file); |
1943 |
+ |
|
1944 |
+ |
conf_parser_ctx.pass = 2; |
1945 |
+ |
yyparse(); /* Load the values from the conf */ |
1946 |
+ |
validate_conf(); /* Check to make sure some values are still okay. */ |
1947 |
+ |
/* Some global values are also loaded here. */ |
1948 |
+ |
check_class(); /* Make sure classes are valid */ |
1949 |
+ |
} |
1950 |
+ |
|
1951 |
|
/* lookup_confhost() |
1952 |
|
* |
1953 |
|
* start DNS lookups of all hostnames in the conf |
1961 |
|
|
1962 |
|
aconf = map_to_conf(conf); |
1963 |
|
|
1964 |
< |
if (EmptyString(aconf->host) || |
2002 |
< |
EmptyString(aconf->user)) |
1964 |
> |
if (has_wildcards(aconf->host)) |
1965 |
|
{ |
1966 |
< |
ilog(L_ERROR, "Host/server name error: (%s) (%s)", |
1966 |
> |
ilog(LOG_TYPE_IRCD, "Host/server name error: (%s) (%s)", |
1967 |
|
aconf->host, conf->name); |
1968 |
|
return; |
1969 |
|
} |
1970 |
|
|
2009 |
– |
if (strchr(aconf->host, '*') || |
2010 |
– |
strchr(aconf->host, '?')) |
2011 |
– |
return; |
2012 |
– |
|
1971 |
|
/* Do name lookup now on hostnames given and store the |
1972 |
|
* ip numbers in conf structure. |
1973 |
|
*/ |
1979 |
|
/* Get us ready for a bind() and don't bother doing dns lookup */ |
1980 |
|
hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; |
1981 |
|
|
1982 |
< |
if (irc_getaddrinfo(aconf->host, NULL, &hints, &res)) |
1982 |
> |
if (getaddrinfo(aconf->host, NULL, &hints, &res)) |
1983 |
|
{ |
1984 |
|
conf_dns_lookup(aconf); |
1985 |
|
return; |
1987 |
|
|
1988 |
|
assert(res != NULL); |
1989 |
|
|
1990 |
< |
memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen); |
1991 |
< |
aconf->ipnum.ss_len = res->ai_addrlen; |
1992 |
< |
aconf->ipnum.ss.ss_family = res->ai_family; |
1993 |
< |
irc_freeaddrinfo(res); |
1990 |
> |
memcpy(&aconf->addr, res->ai_addr, res->ai_addrlen); |
1991 |
> |
aconf->addr.ss_len = res->ai_addrlen; |
1992 |
> |
aconf->addr.ss.ss_family = res->ai_family; |
1993 |
> |
freeaddrinfo(res); |
1994 |
|
} |
1995 |
|
|
1996 |
|
/* conf_connect_allowed() |
2029 |
|
static struct AccessItem * |
2030 |
|
find_regexp_kline(const char *uhi[]) |
2031 |
|
{ |
2032 |
+ |
#ifdef HAVE_LIBPCRE |
2033 |
|
const dlink_node *ptr = NULL; |
2034 |
|
|
2035 |
|
DLINK_FOREACH(ptr, rkconf_items.head) |
2044 |
|
!ircd_pcre_exec(aptr->regexhost, uhi[2]))) |
2045 |
|
return aptr; |
2046 |
|
} |
2047 |
< |
|
2047 |
> |
#endif |
2048 |
|
return NULL; |
2049 |
|
} |
2050 |
|
|
2067 |
|
|
2068 |
|
assert(client_p != NULL); |
2069 |
|
|
2070 |
< |
aconf = find_kline_conf(client_p->host, client_p->username, |
2071 |
< |
&client_p->localClient->ip, |
2072 |
< |
client_p->localClient->aftype); |
2070 |
> |
aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
2071 |
> |
CONF_KLINE, client_p->localClient->aftype, |
2072 |
> |
client_p->username, NULL, 1); |
2073 |
|
if (aconf == NULL) |
2074 |
|
aconf = find_regexp_kline(uhi); |
2075 |
|
|
2076 |
< |
if (aconf && (aconf->status & CONF_KLINE)) |
2118 |
< |
return aconf; |
2119 |
< |
|
2120 |
< |
return NULL; |
2076 |
> |
return aconf; |
2077 |
|
} |
2078 |
|
|
2079 |
|
struct AccessItem * |
2083 |
|
|
2084 |
|
assert(client_p != NULL); |
2085 |
|
|
2086 |
< |
aconf = find_gline_conf(client_p->host, client_p->username, |
2087 |
< |
&client_p->localClient->ip, |
2088 |
< |
client_p->localClient->aftype); |
2089 |
< |
|
2134 |
< |
if (aconf && (aconf->status & CONF_GLINE)) |
2135 |
< |
return aconf; |
2136 |
< |
|
2137 |
< |
return NULL; |
2086 |
> |
aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
2087 |
> |
CONF_GLINE, client_p->localClient->aftype, |
2088 |
> |
client_p->username, NULL, 1); |
2089 |
> |
return aconf; |
2090 |
|
} |
2091 |
|
|
2092 |
|
/* add_temp_line() |
2099 |
|
void |
2100 |
|
add_temp_line(struct ConfItem *conf) |
2101 |
|
{ |
2102 |
< |
struct AccessItem *aconf; |
2151 |
< |
|
2152 |
< |
if (conf->type == DLINE_TYPE) |
2153 |
< |
{ |
2154 |
< |
aconf = map_to_conf(conf); |
2155 |
< |
SetConfTemporary(aconf); |
2156 |
< |
dlinkAdd(conf, &conf->node, &temporary_dlines); |
2157 |
< |
MyFree(aconf->user); |
2158 |
< |
aconf->user = NULL; |
2159 |
< |
add_conf_by_address(CONF_DLINE, aconf); |
2160 |
< |
} |
2161 |
< |
else if (conf->type == KLINE_TYPE) |
2162 |
< |
{ |
2163 |
< |
aconf = map_to_conf(conf); |
2164 |
< |
SetConfTemporary(aconf); |
2165 |
< |
dlinkAdd(conf, &conf->node, &temporary_klines); |
2166 |
< |
add_conf_by_address(CONF_KILL, aconf); |
2167 |
< |
} |
2168 |
< |
else if (conf->type == GLINE_TYPE) |
2169 |
< |
{ |
2170 |
< |
aconf = map_to_conf(conf); |
2171 |
< |
SetConfTemporary(aconf); |
2172 |
< |
dlinkAdd(conf, &conf->node, &temporary_glines); |
2173 |
< |
add_conf_by_address(CONF_GLINE, aconf); |
2174 |
< |
} |
2175 |
< |
else if (conf->type == XLINE_TYPE) |
2102 |
> |
if (conf->type == XLINE_TYPE) |
2103 |
|
{ |
2104 |
|
conf->flags |= CONF_FLAGS_TEMPORARY; |
2105 |
|
dlinkAdd(conf, make_dlink_node(), &temporary_xlines); |
2106 |
|
} |
2180 |
– |
else if (conf->type == RXLINE_TYPE) |
2181 |
– |
{ |
2182 |
– |
conf->flags |= CONF_FLAGS_TEMPORARY; |
2183 |
– |
dlinkAdd(conf, make_dlink_node(), &temporary_rxlines); |
2184 |
– |
} |
2185 |
– |
else if (conf->type == RKLINE_TYPE) |
2186 |
– |
{ |
2187 |
– |
conf->flags |= CONF_FLAGS_TEMPORARY; |
2188 |
– |
dlinkAdd(conf, make_dlink_node(), &temporary_rklines); |
2189 |
– |
} |
2107 |
|
else if ((conf->type == NRESV_TYPE) || (conf->type == CRESV_TYPE)) |
2108 |
|
{ |
2109 |
|
conf->flags |= CONF_FLAGS_TEMPORARY; |
2121 |
|
void |
2122 |
|
cleanup_tklines(void *notused) |
2123 |
|
{ |
2124 |
< |
expire_tklines(&temporary_glines); |
2208 |
< |
expire_tklines(&temporary_klines); |
2209 |
< |
expire_tklines(&temporary_dlines); |
2124 |
> |
hostmask_expire_temporary(); |
2125 |
|
expire_tklines(&temporary_xlines); |
2211 |
– |
expire_tklines(&temporary_rxlines); |
2212 |
– |
expire_tklines(&temporary_rklines); |
2126 |
|
expire_tklines(&temporary_resv); |
2127 |
|
} |
2128 |
|
|
2140 |
|
struct ConfItem *conf; |
2141 |
|
struct MatchItem *xconf; |
2142 |
|
struct MatchItem *nconf; |
2230 |
– |
struct AccessItem *aconf; |
2143 |
|
struct ResvChannel *cconf; |
2144 |
|
|
2145 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head) |
2146 |
|
{ |
2147 |
|
conf = ptr->data; |
2236 |
– |
if (conf->type == GLINE_TYPE || |
2237 |
– |
conf->type == KLINE_TYPE || |
2238 |
– |
conf->type == DLINE_TYPE) |
2239 |
– |
{ |
2240 |
– |
aconf = (struct AccessItem *)map_to_conf(conf); |
2241 |
– |
if (aconf->hold <= CurrentTime) |
2242 |
– |
{ |
2243 |
– |
/* XXX - Do we want GLINE expiry notices?? */ |
2244 |
– |
/* Alert opers that a TKline expired - Hwy */ |
2245 |
– |
if (ConfigFileEntry.tkline_expire_notices) |
2246 |
– |
{ |
2247 |
– |
if (aconf->status & CONF_KILL) |
2248 |
– |
{ |
2249 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
2250 |
– |
"Temporary K-line for [%s@%s] expired", |
2251 |
– |
(aconf->user) ? aconf->user : "*", |
2252 |
– |
(aconf->host) ? aconf->host : "*"); |
2253 |
– |
} |
2254 |
– |
else if (conf->type == DLINE_TYPE) |
2255 |
– |
{ |
2256 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
2257 |
– |
"Temporary D-line for [%s] expired", |
2258 |
– |
(aconf->host) ? aconf->host : "*"); |
2259 |
– |
} |
2260 |
– |
} |
2148 |
|
|
2149 |
< |
dlinkDelete(ptr, tklist); |
2263 |
< |
delete_one_address_conf(aconf->host, aconf); |
2264 |
< |
} |
2265 |
< |
} |
2266 |
< |
else if (conf->type == XLINE_TYPE || |
2267 |
< |
conf->type == RXLINE_TYPE) |
2149 |
> |
if (conf->type == XLINE_TYPE) |
2150 |
|
{ |
2151 |
|
xconf = (struct MatchItem *)map_to_conf(conf); |
2152 |
|
if (xconf->hold <= CurrentTime) |
2153 |
|
{ |
2154 |
|
if (ConfigFileEntry.tkline_expire_notices) |
2155 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
2156 |
< |
"Temporary X-line for [%s] %sexpired", conf->name, |
2275 |
< |
conf->type == RXLINE_TYPE ? "(REGEX) " : ""); |
2156 |
> |
"Temporary X-line for [%s] sexpired", conf->name); |
2157 |
|
dlinkDelete(ptr, tklist); |
2158 |
|
free_dlink_node(ptr); |
2159 |
|
delete_conf_item(conf); |
2160 |
|
} |
2161 |
|
} |
2281 |
– |
else if (conf->type == RKLINE_TYPE) |
2282 |
– |
{ |
2283 |
– |
aconf = map_to_conf(conf); |
2284 |
– |
if (aconf->hold <= CurrentTime) |
2285 |
– |
{ |
2286 |
– |
if (ConfigFileEntry.tkline_expire_notices) |
2287 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
2288 |
– |
"Temporary K-line for [%s@%s] (REGEX) expired", |
2289 |
– |
(aconf->user) ? aconf->user : "*", |
2290 |
– |
(aconf->host) ? aconf->host : "*"); |
2291 |
– |
dlinkDelete(ptr, tklist); |
2292 |
– |
free_dlink_node(ptr); |
2293 |
– |
delete_conf_item(conf); |
2294 |
– |
} |
2295 |
– |
} |
2162 |
|
else if (conf->type == NRESV_TYPE) |
2163 |
|
{ |
2164 |
|
nconf = (struct MatchItem *)map_to_conf(conf); |
2195 |
|
static const struct oper_privs |
2196 |
|
{ |
2197 |
|
const unsigned int oprivs; |
2332 |
– |
const unsigned int hidden; |
2198 |
|
const unsigned char c; |
2199 |
|
} flag_list[] = { |
2200 |
< |
{ OPER_FLAG_ADMIN, OPER_FLAG_HIDDEN_ADMIN, 'A' }, |
2201 |
< |
{ OPER_FLAG_REMOTEBAN, 0, 'B' }, |
2202 |
< |
{ OPER_FLAG_DIE, 0, 'D' }, |
2203 |
< |
{ OPER_FLAG_GLINE, 0, 'G' }, |
2204 |
< |
{ OPER_FLAG_REHASH, 0, 'H' }, |
2205 |
< |
{ OPER_FLAG_K, 0, 'K' }, |
2206 |
< |
{ OPER_FLAG_OPERWALL, 0, 'L' }, |
2207 |
< |
{ OPER_FLAG_N, 0, 'N' }, |
2208 |
< |
{ OPER_FLAG_GLOBAL_KILL, 0, 'O' }, |
2209 |
< |
{ OPER_FLAG_REMOTE, 0, 'R' }, |
2210 |
< |
{ OPER_FLAG_OPER_SPY, 0, 'S' }, |
2211 |
< |
{ OPER_FLAG_UNKLINE, 0, 'U' }, |
2212 |
< |
{ OPER_FLAG_X, 0, 'X' }, |
2213 |
< |
{ 0, 0, '\0' } |
2200 |
> |
{ OPER_FLAG_ADMIN, 'A' }, |
2201 |
> |
{ OPER_FLAG_REMOTEBAN, 'B' }, |
2202 |
> |
{ OPER_FLAG_DIE, 'D' }, |
2203 |
> |
{ OPER_FLAG_GLINE, 'G' }, |
2204 |
> |
{ OPER_FLAG_REHASH, 'H' }, |
2205 |
> |
{ OPER_FLAG_K, 'K' }, |
2206 |
> |
{ OPER_FLAG_OPERWALL, 'L' }, |
2207 |
> |
{ OPER_FLAG_N, 'N' }, |
2208 |
> |
{ OPER_FLAG_GLOBAL_KILL, 'O' }, |
2209 |
> |
{ OPER_FLAG_REMOTE, 'R' }, |
2210 |
> |
{ OPER_FLAG_OPER_SPY, 'S' }, |
2211 |
> |
{ OPER_FLAG_UNKLINE, 'U' }, |
2212 |
> |
{ OPER_FLAG_X, 'X' }, |
2213 |
> |
{ 0, '\0' } |
2214 |
|
}; |
2215 |
|
|
2216 |
|
char * |
2222 |
|
|
2223 |
|
for (; flag_list[i].oprivs; ++i) |
2224 |
|
{ |
2225 |
< |
if ((port & flag_list[i].oprivs) && |
2361 |
< |
(port & flag_list[i].hidden) == 0) |
2225 |
> |
if (port & flag_list[i].oprivs) |
2226 |
|
*privs_ptr++ = flag_list[i].c; |
2227 |
|
else |
2228 |
|
*privs_ptr++ = ToLowerTab[flag_list[i].c]; |
2239 |
|
* "oper" is server name for remote opers |
2240 |
|
* Side effects: None. |
2241 |
|
*/ |
2242 |
< |
char * |
2242 |
> |
const char * |
2243 |
|
get_oper_name(const struct Client *client_p) |
2244 |
|
{ |
2245 |
< |
dlink_node *cnode; |
2382 |
< |
struct ConfItem *conf; |
2383 |
< |
struct AccessItem *aconf; |
2384 |
< |
|
2245 |
> |
dlink_node *cnode = NULL; |
2246 |
|
/* +5 for !,@,{,} and null */ |
2247 |
< |
static char buffer[NICKLEN+USERLEN+HOSTLEN+HOSTLEN+5]; |
2247 |
> |
static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5]; |
2248 |
|
|
2249 |
|
if (MyConnect(client_p)) |
2250 |
|
{ |
2251 |
< |
DLINK_FOREACH(cnode, client_p->localClient->confs.head) |
2251 |
> |
if ((cnode = client_p->localClient->confs.head)) |
2252 |
|
{ |
2253 |
< |
conf = cnode->data; |
2254 |
< |
aconf = map_to_conf(conf); |
2253 |
> |
struct ConfItem *conf = cnode->data; |
2254 |
> |
const struct AccessItem *aconf = map_to_conf(conf); |
2255 |
|
|
2256 |
|
if (IsConfOperator(aconf)) |
2257 |
|
{ |
2258 |
< |
ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name, |
2259 |
< |
client_p->username, client_p->host, |
2399 |
< |
conf->name); |
2258 |
> |
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
2259 |
> |
client_p->username, client_p->host, conf->name); |
2260 |
|
return buffer; |
2261 |
|
} |
2262 |
|
} |
2267 |
|
assert(0); /* Oper without oper conf! */ |
2268 |
|
} |
2269 |
|
|
2270 |
< |
ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name, |
2271 |
< |
client_p->username, client_p->host, client_p->servptr->name); |
2270 |
> |
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
2271 |
> |
client_p->username, client_p->host, client_p->servptr->name); |
2272 |
|
return buffer; |
2273 |
|
} |
2274 |
|
|
2285 |
|
char chanmodes[32]; |
2286 |
|
char chanlimit[32]; |
2287 |
|
|
2288 |
+ |
conf_parser_ctx.boot = cold; |
2289 |
|
filename = get_conf_name(CONF_TYPE); |
2290 |
|
|
2291 |
|
/* We need to know the initial filename for the yyerror() to report |
2296 |
|
*/ |
2297 |
|
strlcpy(conffilebuf, filename, sizeof(conffilebuf)); |
2298 |
|
|
2299 |
< |
if ((conf_fbfile_in = fbopen(filename, "r")) == NULL) |
2299 |
> |
if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL) |
2300 |
|
{ |
2301 |
|
if (cold) |
2302 |
|
{ |
2303 |
< |
ilog(L_CRIT, "Unable to read configuration file '%s': %s", |
2303 |
> |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
2304 |
|
filename, strerror(errno)); |
2305 |
|
exit(-1); |
2306 |
|
} |
2316 |
|
if (!cold) |
2317 |
|
clear_out_old_conf(); |
2318 |
|
|
2319 |
< |
read_conf(conf_fbfile_in); |
2320 |
< |
fbclose(conf_fbfile_in); |
2319 |
> |
read_conf(conf_parser_ctx.conf_file); |
2320 |
> |
fclose(conf_parser_ctx.conf_file); |
2321 |
|
|
2322 |
|
add_isupport("NETWORK", ServerInfo.network_name, -1); |
2323 |
< |
ircsprintf(chanmodes, "b%s%s:%d", ConfigChannel.use_except ? "e" : "", |
2324 |
< |
ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans); |
2323 |
> |
snprintf(chanmodes, sizeof(chanmodes), "b%s%s:%d", |
2324 |
> |
ConfigChannel.use_except ? "e" : "", |
2325 |
> |
ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans); |
2326 |
|
add_isupport("MAXLIST", chanmodes, -1); |
2327 |
|
add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets); |
2328 |
+ |
|
2329 |
|
if (ConfigChannel.disable_local_channels) |
2330 |
|
add_isupport("CHANTYPES", "#", -1); |
2331 |
|
else |
2332 |
|
add_isupport("CHANTYPES", "#&", -1); |
2333 |
< |
ircsprintf(chanlimit, "%s:%d", ConfigChannel.disable_local_channels ? "#" : "#&", |
2334 |
< |
ConfigChannel.max_chans_per_user); |
2333 |
> |
|
2334 |
> |
snprintf(chanlimit, sizeof(chanlimit), "%s:%d", |
2335 |
> |
ConfigChannel.disable_local_channels ? "#" : "#&", |
2336 |
> |
ConfigChannel.max_chans_per_user); |
2337 |
|
add_isupport("CHANLIMIT", chanlimit, -1); |
2338 |
< |
ircsprintf(chanmodes, "%s%s%s", ConfigChannel.use_except ? "e" : "", |
2339 |
< |
ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpst"); |
2338 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s%s%s", |
2339 |
> |
ConfigChannel.use_except ? "e" : "", |
2340 |
> |
ConfigChannel.use_invex ? "I" : "", "b,k,l,imnprstORS"); |
2341 |
|
add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN); |
2342 |
+ |
|
2343 |
|
if (ConfigChannel.use_except) |
2344 |
|
add_isupport("EXCEPTS", "e", -1); |
2345 |
|
if (ConfigChannel.use_invex) |
2352 |
|
*/ |
2353 |
|
rebuild_isupport_message_line(); |
2354 |
|
|
2355 |
< |
parse_conf_file(KLINE_TYPE, cold); |
2355 |
> |
#ifdef HAVE_LIBPCRE |
2356 |
|
parse_conf_file(RKLINE_TYPE, cold); |
2357 |
+ |
parse_conf_file(RXLINE_TYPE, cold); |
2358 |
+ |
#endif |
2359 |
+ |
parse_conf_file(KLINE_TYPE, cold); |
2360 |
|
parse_conf_file(DLINE_TYPE, cold); |
2361 |
|
parse_conf_file(XLINE_TYPE, cold); |
2492 |
– |
parse_conf_file(RXLINE_TYPE, cold); |
2362 |
|
parse_conf_file(NRESV_TYPE, cold); |
2363 |
|
parse_conf_file(CRESV_TYPE, cold); |
2364 |
|
} |
2372 |
|
static void |
2373 |
|
parse_conf_file(int type, int cold) |
2374 |
|
{ |
2375 |
< |
FBFILE *file = NULL; |
2375 |
> |
FILE *file = NULL; |
2376 |
|
const char *filename = get_conf_name(type); |
2377 |
|
|
2378 |
< |
if ((file = fbopen(filename, "r")) == NULL) |
2378 |
> |
if ((file = fopen(filename, "r")) == NULL) |
2379 |
|
{ |
2380 |
|
if (cold) |
2381 |
< |
ilog(L_ERROR, "Unable to read configuration file '%s': %s", |
2381 |
> |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
2382 |
|
filename, strerror(errno)); |
2383 |
|
else |
2384 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
2388 |
|
else |
2389 |
|
{ |
2390 |
|
parse_csv_file(file, type); |
2391 |
< |
fbclose(file); |
2391 |
> |
fclose(file); |
2392 |
|
} |
2393 |
|
} |
2394 |
|
|
2407 |
|
struct ClassItem *cltmp; |
2408 |
|
struct MatchItem *match_item; |
2409 |
|
dlink_list *free_items [] = { |
2410 |
< |
&server_items, &oconf_items, &hub_items, &leaf_items, |
2410 |
> |
&server_items, &oconf_items, |
2411 |
|
&uconf_items, &xconf_items, &rxconf_items, &rkconf_items, |
2412 |
< |
&nresv_items, &cluster_items, &gdeny_items, NULL |
2412 |
> |
&nresv_items, &cluster_items, &gdeny_items, &service_items, NULL |
2413 |
|
}; |
2414 |
|
|
2415 |
|
dlink_list ** iterator = free_items; /* C is dumb */ |
2452 |
|
delete_conf_item(conf); |
2453 |
|
} |
2454 |
|
} |
2586 |
– |
else if (conf->type == CLIENT_TYPE) |
2587 |
– |
{ |
2588 |
– |
aconf = map_to_conf(conf); |
2589 |
– |
|
2590 |
– |
if (aconf->clients != 0) |
2591 |
– |
{ |
2592 |
– |
SetConfIllegal(aconf); |
2593 |
– |
} |
2594 |
– |
else |
2595 |
– |
{ |
2596 |
– |
delete_conf_item(conf); |
2597 |
– |
} |
2598 |
– |
} |
2455 |
|
else if (conf->type == XLINE_TYPE || |
2456 |
|
conf->type == RXLINE_TYPE || |
2457 |
|
conf->type == RKLINE_TYPE) |
2465 |
|
} |
2466 |
|
else |
2467 |
|
{ |
2612 |
– |
if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE)) |
2613 |
– |
{ |
2614 |
– |
match_item = map_to_conf(conf); |
2615 |
– |
if (match_item->ref_count <= 0) |
2616 |
– |
delete_conf_item(conf); |
2617 |
– |
else |
2618 |
– |
{ |
2619 |
– |
match_item->illegal = 1; |
2620 |
– |
dlinkDelete(&conf->node, *iterator); |
2621 |
– |
} |
2622 |
– |
} |
2623 |
– |
else |
2468 |
|
delete_conf_item(conf); |
2469 |
|
} |
2470 |
|
} |
2485 |
|
clear_out_address_conf(); |
2486 |
|
|
2487 |
|
/* clean out module paths */ |
2644 |
– |
#ifndef STATIC_MODULES |
2488 |
|
mod_clear_paths(); |
2646 |
– |
#endif |
2489 |
|
|
2490 |
|
/* clean out ServerInfo */ |
2491 |
|
MyFree(ServerInfo.description); |
2505 |
|
|
2506 |
|
MyFree(ServerInfo.rsa_private_key_file); |
2507 |
|
ServerInfo.rsa_private_key_file = NULL; |
2508 |
+ |
|
2509 |
+ |
if (ServerInfo.server_ctx) |
2510 |
+ |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2| |
2511 |
+ |
SSL_OP_NO_SSLv3| |
2512 |
+ |
SSL_OP_NO_TLSv1); |
2513 |
+ |
if (ServerInfo.client_ctx) |
2514 |
+ |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2| |
2515 |
+ |
SSL_OP_NO_SSLv3| |
2516 |
+ |
SSL_OP_NO_TLSv1); |
2517 |
|
#endif |
2518 |
|
|
2519 |
|
/* clean out old resvs from the conf */ |
2536 |
|
*/ |
2537 |
|
|
2538 |
|
/* clean out general */ |
2539 |
< |
MyFree(ConfigFileEntry.servlink_path); |
2540 |
< |
ConfigFileEntry.servlink_path = NULL; |
2541 |
< |
#ifdef HAVE_LIBCRYPTO |
2691 |
< |
ConfigFileEntry.default_cipher_preference = NULL; |
2692 |
< |
#endif /* HAVE_LIBCRYPTO */ |
2539 |
> |
MyFree(ConfigFileEntry.service_name); |
2540 |
> |
ConfigFileEntry.service_name = NULL; |
2541 |
> |
|
2542 |
|
delete_isupport("INVEX"); |
2543 |
|
delete_isupport("EXCEPTS"); |
2544 |
|
} |
2649 |
|
if (aconf->class_ptr != NULL) |
2650 |
|
{ |
2651 |
|
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
2652 |
< |
*pingwarn = PingWarning(aclass); |
2653 |
< |
return PingFreq(aclass); |
2652 |
> |
*pingwarn = aclass->ping_warning; |
2653 |
> |
return aclass->ping_freq; |
2654 |
|
} |
2655 |
|
} |
2656 |
|
|
2666 |
|
const char * |
2667 |
|
get_client_class(struct Client *target_p) |
2668 |
|
{ |
2669 |
< |
dlink_node *ptr; |
2670 |
< |
struct ConfItem *conf; |
2822 |
< |
struct AccessItem *aconf; |
2669 |
> |
dlink_node *cnode = NULL; |
2670 |
> |
struct AccessItem *aconf = NULL; |
2671 |
|
|
2672 |
< |
if (target_p != NULL && !IsMe(target_p) && |
2673 |
< |
target_p->localClient->confs.head != NULL) |
2672 |
> |
assert(!IsMe(target_p)); |
2673 |
> |
|
2674 |
> |
if ((cnode = target_p->localClient->confs.head)) |
2675 |
|
{ |
2676 |
< |
DLINK_FOREACH(ptr, target_p->localClient->confs.head) |
2828 |
< |
{ |
2829 |
< |
conf = ptr->data; |
2676 |
> |
struct ConfItem *conf = cnode->data; |
2677 |
|
|
2678 |
< |
if (conf->type == CLIENT_TYPE || conf->type == SERVER_TYPE || |
2679 |
< |
conf->type == OPER_TYPE) |
2680 |
< |
{ |
2681 |
< |
aconf = (struct AccessItem *) map_to_conf(conf); |
2682 |
< |
if (aconf->class_ptr != NULL) |
2683 |
< |
return aconf->class_ptr->name; |
2837 |
< |
} |
2838 |
< |
} |
2678 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
2679 |
> |
(conf->type == OPER_TYPE)); |
2680 |
> |
|
2681 |
> |
aconf = map_to_conf(conf); |
2682 |
> |
if (aconf->class_ptr != NULL) |
2683 |
> |
return aconf->class_ptr->name; |
2684 |
|
} |
2685 |
|
|
2686 |
|
return "default"; |
2696 |
|
int |
2697 |
|
get_client_ping(struct Client *target_p, int *pingwarn) |
2698 |
|
{ |
2699 |
< |
int ping; |
2700 |
< |
struct ConfItem *conf; |
2856 |
< |
dlink_node *nlink; |
2699 |
> |
int ping = 0; |
2700 |
> |
dlink_node *cnode = NULL; |
2701 |
|
|
2702 |
< |
if (target_p->localClient->confs.head != NULL) |
2703 |
< |
DLINK_FOREACH(nlink, target_p->localClient->confs.head) |
2704 |
< |
{ |
2861 |
< |
conf = nlink->data; |
2702 |
> |
if ((cnode = target_p->localClient->confs.head)) |
2703 |
> |
{ |
2704 |
> |
struct ConfItem *conf = cnode->data; |
2705 |
|
|
2706 |
< |
if ((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
2707 |
< |
(conf->type == OPER_TYPE)) |
2708 |
< |
{ |
2709 |
< |
ping = get_conf_ping(conf, pingwarn); |
2710 |
< |
if (ping > 0) |
2711 |
< |
return ping; |
2712 |
< |
} |
2870 |
< |
} |
2706 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
2707 |
> |
(conf->type == OPER_TYPE)); |
2708 |
> |
|
2709 |
> |
ping = get_conf_ping(conf, pingwarn); |
2710 |
> |
if (ping > 0) |
2711 |
> |
return ping; |
2712 |
> |
} |
2713 |
|
|
2714 |
|
*pingwarn = 0; |
2715 |
|
return DEFAULT_PINGFREQUENCY; |
2726 |
|
{ |
2727 |
|
struct ConfItem *conf; |
2728 |
|
|
2729 |
< |
if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL) |
2729 |
> |
if ((conf = find_exact_name_conf(CLASS_TYPE, NULL, classname, NULL, NULL)) != NULL) |
2730 |
|
return conf; |
2731 |
|
|
2732 |
|
return class_default; |
2747 |
|
{ |
2748 |
|
struct ClassItem *aclass = map_to_conf(ptr->data); |
2749 |
|
|
2750 |
< |
if (!aclass->active && !CurrUserCount(aclass)) |
2750 |
> |
if (!aclass->active && !aclass->curr_user_count) |
2751 |
|
{ |
2752 |
|
destroy_cidr_class(aclass); |
2753 |
|
delete_conf_item(ptr->data); |
2771 |
|
aclass = map_to_conf(class_default); |
2772 |
|
aclass->active = 1; |
2773 |
|
DupString(class_default->name, "default"); |
2774 |
< |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
2775 |
< |
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
2776 |
< |
MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT; |
2777 |
< |
MaxSendq(aclass) = DEFAULT_SENDQ; |
2774 |
> |
aclass->con_freq = DEFAULT_CONNECTFREQUENCY; |
2775 |
> |
aclass->ping_freq = DEFAULT_PINGFREQUENCY; |
2776 |
> |
aclass->max_total = MAXIMUM_LINKS_DEFAULT; |
2777 |
> |
aclass->max_sendq = DEFAULT_SENDQ; |
2778 |
|
|
2779 |
|
client_check_cb = register_callback("check_client", check_client); |
2780 |
|
} |
2785 |
|
* output - sendq for this client as found from its class |
2786 |
|
* side effects - NONE |
2787 |
|
*/ |
2788 |
< |
unsigned long |
2788 |
> |
unsigned int |
2789 |
|
get_sendq(struct Client *client_p) |
2790 |
|
{ |
2791 |
< |
unsigned long sendq = DEFAULT_SENDQ; |
2792 |
< |
dlink_node *ptr; |
2951 |
< |
struct ConfItem *conf; |
2791 |
> |
unsigned int sendq = DEFAULT_SENDQ; |
2792 |
> |
dlink_node *cnode; |
2793 |
|
struct ConfItem *class_conf; |
2794 |
|
struct ClassItem *aclass; |
2795 |
|
struct AccessItem *aconf; |
2796 |
|
|
2797 |
< |
if (client_p && !IsMe(client_p) && (client_p->localClient->confs.head)) |
2797 |
> |
assert(!IsMe(client_p)); |
2798 |
> |
|
2799 |
> |
if ((cnode = client_p->localClient->confs.head)) |
2800 |
|
{ |
2801 |
< |
DLINK_FOREACH(ptr, client_p->localClient->confs.head) |
2802 |
< |
{ |
2803 |
< |
conf = ptr->data; |
2804 |
< |
if ((conf->type == SERVER_TYPE) || (conf->type == OPER_TYPE) |
2805 |
< |
|| (conf->type == CLIENT_TYPE)) |
2806 |
< |
{ |
2807 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
2808 |
< |
if ((class_conf = aconf->class_ptr) == NULL) |
2809 |
< |
continue; |
2810 |
< |
aclass = (struct ClassItem *)map_to_conf(class_conf); |
2811 |
< |
sendq = MaxSendq(aclass); |
2812 |
< |
return sendq; |
2813 |
< |
} |
2971 |
< |
} |
2801 |
> |
struct ConfItem *conf = cnode->data; |
2802 |
> |
|
2803 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
2804 |
> |
(conf->type == OPER_TYPE)); |
2805 |
> |
|
2806 |
> |
aconf = map_to_conf(conf); |
2807 |
> |
|
2808 |
> |
if ((class_conf = aconf->class_ptr) == NULL) |
2809 |
> |
return DEFAULT_SENDQ; /* TBV: shouldn't be possible at all */ |
2810 |
> |
|
2811 |
> |
aclass = map_to_conf(class_conf); |
2812 |
> |
sendq = aclass->max_sendq; |
2813 |
> |
return sendq; |
2814 |
|
} |
2815 |
+ |
|
2816 |
|
/* XXX return a default? |
2817 |
|
* if here, then there wasn't an attached conf with a sendq |
2818 |
|
* that is very bad -Dianora |
2875 |
|
int |
2876 |
|
conf_add_server(struct ConfItem *conf, const char *class_name) |
2877 |
|
{ |
2878 |
< |
struct AccessItem *aconf; |
3036 |
< |
struct split_nuh_item nuh; |
3037 |
< |
char conf_user[USERLEN + 1]; |
3038 |
< |
char conf_host[HOSTLEN + 1]; |
3039 |
< |
|
3040 |
< |
aconf = map_to_conf(conf); |
2878 |
> |
struct AccessItem *aconf = map_to_conf(conf); |
2879 |
|
|
2880 |
|
conf_add_class_to_conf(conf, class_name); |
2881 |
|
|
2882 |
|
if (!aconf->host || !conf->name) |
2883 |
|
{ |
2884 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block"); |
2885 |
< |
ilog(L_WARN, "Bad connect block"); |
2885 |
> |
ilog(LOG_TYPE_IRCD, "Bad connect block"); |
2886 |
|
return -1; |
2887 |
|
} |
2888 |
|
|
2889 |
< |
if (EmptyString(aconf->passwd) && !IsConfCryptLink(aconf)) |
2889 |
> |
if (EmptyString(aconf->passwd)) |
2890 |
|
{ |
2891 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block, name %s", |
2892 |
|
conf->name); |
2893 |
< |
ilog(L_WARN, "Bad connect block, host %s", conf->name); |
2893 |
> |
ilog(LOG_TYPE_IRCD, "Bad connect block, host %s", conf->name); |
2894 |
|
return -1; |
2895 |
|
} |
2896 |
|
|
3059 |
– |
nuh.nuhmask = aconf->host; |
3060 |
– |
nuh.nickptr = NULL; |
3061 |
– |
nuh.userptr = conf_user; |
3062 |
– |
nuh.hostptr = conf_host; |
3063 |
– |
|
3064 |
– |
nuh.nicksize = 0; |
3065 |
– |
nuh.usersize = sizeof(conf_user); |
3066 |
– |
nuh.hostsize = sizeof(conf_host); |
3067 |
– |
|
3068 |
– |
split_nuh(&nuh); |
3069 |
– |
|
3070 |
– |
MyFree(aconf->host); |
3071 |
– |
aconf->host = NULL; |
3072 |
– |
|
3073 |
– |
DupString(aconf->user, conf_user); /* somehow username checking for servers |
3074 |
– |
got lost in H6/7, will have to be re-added */ |
3075 |
– |
DupString(aconf->host, conf_host); |
3076 |
– |
|
2897 |
|
lookup_confhost(conf); |
2898 |
|
|
2899 |
|
return 0; |
2900 |
|
} |
2901 |
|
|
3082 |
– |
/* conf_add_d_conf() |
3083 |
– |
* |
3084 |
– |
* inputs - pointer to config item |
3085 |
– |
* output - NONE |
3086 |
– |
* side effects - Add a d/D line |
3087 |
– |
*/ |
3088 |
– |
void |
3089 |
– |
conf_add_d_conf(struct AccessItem *aconf) |
3090 |
– |
{ |
3091 |
– |
if (aconf->host == NULL) |
3092 |
– |
return; |
3093 |
– |
|
3094 |
– |
aconf->user = NULL; |
3095 |
– |
|
3096 |
– |
/* XXX - Should 'd' ever be in the old conf? For new conf we don't |
3097 |
– |
* need this anyway, so I will disable it for now... -A1kmm |
3098 |
– |
*/ |
3099 |
– |
if (parse_netmask(aconf->host, NULL, NULL) == HM_HOST) |
3100 |
– |
{ |
3101 |
– |
ilog(L_WARN, "Invalid Dline %s ignored", aconf->host); |
3102 |
– |
free_access_item(aconf); |
3103 |
– |
} |
3104 |
– |
else |
3105 |
– |
{ |
3106 |
– |
/* XXX ensure user is NULL */ |
3107 |
– |
MyFree(aconf->user); |
3108 |
– |
aconf->user = NULL; |
3109 |
– |
add_conf_by_address(CONF_DLINE, aconf); |
3110 |
– |
} |
3111 |
– |
} |
3112 |
– |
|
2902 |
|
/* yyerror() |
2903 |
|
* |
2904 |
|
* inputs - message from parser |
2910 |
|
{ |
2911 |
|
char newlinebuf[IRCD_BUFSIZE]; |
2912 |
|
|
2913 |
< |
if (ypass != 1) |
2913 |
> |
if (conf_parser_ctx.pass != 1) |
2914 |
|
return; |
2915 |
|
|
2916 |
|
strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf)); |
2917 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "\"%s\", line %u: %s: %s", |
2918 |
|
conffilebuf, lineno + 1, msg, newlinebuf); |
2919 |
< |
ilog(L_WARN, "\"%s\", line %u: %s: %s", |
2919 |
> |
ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s", |
2920 |
|
conffilebuf, lineno + 1, msg, newlinebuf); |
2921 |
|
} |
2922 |
|
|
3134 |
– |
int |
3135 |
– |
conf_fbgets(char *lbuf, unsigned int max_size, FBFILE *fb) |
3136 |
– |
{ |
3137 |
– |
if (fbgets(lbuf, max_size, fb) == NULL) |
3138 |
– |
return 0; |
3139 |
– |
|
3140 |
– |
return strlen(lbuf); |
3141 |
– |
} |
3142 |
– |
|
3143 |
– |
int |
3144 |
– |
conf_yy_fatal_error(const char *msg) |
3145 |
– |
{ |
3146 |
– |
return 0; |
3147 |
– |
} |
3148 |
– |
|
2923 |
|
/* |
2924 |
|
* valid_tkline() |
2925 |
|
* |
2931 |
|
* Originally written by Dianora (Diane, db@db.net) |
2932 |
|
*/ |
2933 |
|
time_t |
2934 |
< |
valid_tkline(char *p, int minutes) |
2934 |
> |
valid_tkline(const char *p, int minutes) |
2935 |
|
{ |
2936 |
|
time_t result = 0; |
2937 |
|
|
2938 |
< |
while (*p) |
2938 |
> |
for (; *p; ++p) |
2939 |
|
{ |
2940 |
< |
if (IsDigit(*p)) |
3167 |
< |
{ |
3168 |
< |
result *= 10; |
3169 |
< |
result += ((*p) & 0xF); |
3170 |
< |
p++; |
3171 |
< |
} |
3172 |
< |
else |
2940 |
> |
if (!IsDigit(*p)) |
2941 |
|
return 0; |
2942 |
+ |
|
2943 |
+ |
result *= 10; |
2944 |
+ |
result += ((*p) & 0xF); |
2945 |
|
} |
2946 |
|
|
2947 |
< |
/* in the degenerate case where oper does a /quote kline 0 user@host :reason |
2947 |
> |
/* |
2948 |
> |
* In the degenerate case where oper does a /quote kline 0 user@host :reason |
2949 |
|
* i.e. they specifically use 0, I am going to return 1 instead |
2950 |
|
* as a return value of non-zero is used to flag it as a temporary kline |
2951 |
|
*/ |
3180 |
– |
|
2952 |
|
if (result == 0) |
2953 |
|
result = 1; |
2954 |
|
|
3049 |
|
* if target_server is NULL and an "ON" is found error |
3050 |
|
* is reported. |
3051 |
|
* if reason pointer is NULL ignore pointer, |
3052 |
< |
* this allows usee of parse_a_line in unkline etc. |
3052 |
> |
* this allows use of parse_a_line in unkline etc. |
3053 |
|
* |
3054 |
|
* - Dianora |
3055 |
|
*/ |
3119 |
|
return -1; |
3120 |
|
} |
3121 |
|
|
3122 |
< |
if (!IsOperRemoteBan(source_p)) |
3122 |
> |
if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN)) |
3123 |
|
{ |
3124 |
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
3125 |
|
me.name, source_p->name, "remoteban"); |
3156 |
|
return -1; |
3157 |
|
} |
3158 |
|
|
3159 |
< |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 2, *up_p, *h_p)) |
3159 |
> |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p)) |
3160 |
|
return -1; |
3161 |
|
} |
3162 |
|
else |
3163 |
< |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 1, *up_p)) |
3163 |
> |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p)) |
3164 |
|
return -1; |
3165 |
|
|
3166 |
|
if (reason != NULL) |
3168 |
|
if (parc != 0 && !EmptyString(*parv)) |
3169 |
|
{ |
3170 |
|
*reason = *parv; |
3171 |
< |
if (!valid_comment(source_p, *reason, YES)) |
3171 |
> |
if (!valid_comment(source_p, *reason, 1)) |
3172 |
|
return -1; |
3173 |
|
} |
3174 |
|
else |
3299 |
|
{ |
3300 |
|
const char *encr = NULL; |
3301 |
|
|
3302 |
< |
if (password == NULL || aconf->passwd == NULL) |
3302 |
> |
if (EmptyString(password) || EmptyString(aconf->passwd)) |
3303 |
|
return 0; |
3304 |
|
|
3305 |
|
if (aconf->flags & CONF_FLAGS_ENCRYPTED) |
3306 |
< |
{ |
3536 |
< |
/* use first two chars of the password they send in as salt */ |
3537 |
< |
/* If the password in the conf is MD5, and ircd is linked |
3538 |
< |
* to scrypt on FreeBSD, or the standard crypt library on |
3539 |
< |
* glibc Linux, then this code will work fine on generating |
3540 |
< |
* the proper encrypted hash for comparison. |
3541 |
< |
*/ |
3542 |
< |
if (*aconf->passwd) |
3543 |
< |
encr = crypt(password, aconf->passwd); |
3544 |
< |
else |
3545 |
< |
encr = ""; |
3546 |
< |
} |
3306 |
> |
encr = crypt(password, aconf->passwd); |
3307 |
|
else |
3308 |
|
encr = password; |
3309 |
|
|
3316 |
|
* inputs - client sending the cluster |
3317 |
|
* - command name "KLINE" "XLINE" etc. |
3318 |
|
* - capab -- CAP_KLN etc. from s_serv.h |
3319 |
< |
* - cluster type -- CLUSTER_KLINE etc. from s_conf.h |
3319 |
> |
* - cluster type -- CLUSTER_KLINE etc. from conf.h |
3320 |
|
* - pattern and args to send along |
3321 |
|
* output - none |
3322 |
|
* side effects - Take source_p send the pattern with args given |
3476 |
|
dlink_node *ptr = NULL; |
3477 |
|
struct CidrItem *cidr; |
3478 |
|
|
3479 |
< |
if (NumberPerCidr(aclass) <= 0) |
3479 |
> |
if (aclass->number_per_cidr <= 0) |
3480 |
|
return 0; |
3481 |
|
|
3482 |
|
if (ip->ss.ss_family == AF_INET) |
3483 |
|
{ |
3484 |
< |
if (CidrBitlenIPV4(aclass) <= 0) |
3484 |
> |
if (aclass->cidr_bitlen_ipv4 <= 0) |
3485 |
|
return 0; |
3486 |
|
|
3487 |
|
DLINK_FOREACH(ptr, aclass->list_ipv4.head) |
3488 |
|
{ |
3489 |
|
cidr = ptr->data; |
3490 |
< |
if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass))) |
3490 |
> |
if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4)) |
3491 |
|
{ |
3492 |
< |
if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass))) |
3492 |
> |
if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr)) |
3493 |
|
return -1; |
3494 |
|
cidr->number_on_this_cidr++; |
3495 |
|
return 0; |
3498 |
|
cidr = MyMalloc(sizeof(struct CidrItem)); |
3499 |
|
cidr->number_on_this_cidr = 1; |
3500 |
|
cidr->mask = *ip; |
3501 |
< |
mask_addr(&cidr->mask, CidrBitlenIPV4(aclass)); |
3501 |
> |
mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv4); |
3502 |
|
dlinkAdd(cidr, &cidr->node, &aclass->list_ipv4); |
3503 |
|
} |
3504 |
|
#ifdef IPV6 |
3505 |
< |
else if (CidrBitlenIPV6(aclass) > 0) |
3505 |
> |
else if (aclass->cidr_bitlen_ipv6 > 0) |
3506 |
|
{ |
3507 |
|
DLINK_FOREACH(ptr, aclass->list_ipv6.head) |
3508 |
|
{ |
3509 |
|
cidr = ptr->data; |
3510 |
< |
if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass))) |
3510 |
> |
if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6)) |
3511 |
|
{ |
3512 |
< |
if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass))) |
3512 |
> |
if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr)) |
3513 |
|
return -1; |
3514 |
|
cidr->number_on_this_cidr++; |
3515 |
|
return 0; |
3518 |
|
cidr = MyMalloc(sizeof(struct CidrItem)); |
3519 |
|
cidr->number_on_this_cidr = 1; |
3520 |
|
cidr->mask = *ip; |
3521 |
< |
mask_addr(&cidr->mask, CidrBitlenIPV6(aclass)); |
3521 |
> |
mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv6); |
3522 |
|
dlinkAdd(cidr, &cidr->node, &aclass->list_ipv6); |
3523 |
|
} |
3524 |
|
#endif |
3540 |
|
dlink_node *next_ptr = NULL; |
3541 |
|
struct CidrItem *cidr; |
3542 |
|
|
3543 |
< |
if (NumberPerCidr(aclass) == 0) |
3543 |
> |
if (aclass->number_per_cidr == 0) |
3544 |
|
return; |
3545 |
|
|
3546 |
|
if (ip->ss.ss_family == AF_INET) |
3547 |
|
{ |
3548 |
< |
if (CidrBitlenIPV4(aclass) <= 0) |
3548 |
> |
if (aclass->cidr_bitlen_ipv4 <= 0) |
3549 |
|
return; |
3550 |
|
|
3551 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head) |
3552 |
|
{ |
3553 |
|
cidr = ptr->data; |
3554 |
< |
if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass))) |
3554 |
> |
if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4)) |
3555 |
|
{ |
3556 |
|
cidr->number_on_this_cidr--; |
3557 |
|
if (cidr->number_on_this_cidr == 0) |
3564 |
|
} |
3565 |
|
} |
3566 |
|
#ifdef IPV6 |
3567 |
< |
else if (CidrBitlenIPV6(aclass) > 0) |
3567 |
> |
else if (aclass->cidr_bitlen_ipv6 > 0) |
3568 |
|
{ |
3569 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head) |
3570 |
|
{ |
3571 |
|
cidr = ptr->data; |
3572 |
< |
if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass))) |
3572 |
> |
if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6)) |
3573 |
|
{ |
3574 |
|
cidr->number_on_this_cidr--; |
3575 |
|
if (cidr->number_on_this_cidr == 0) |
3632 |
|
{ |
3633 |
|
struct ClassItem *old_class = map_to_conf(conf); |
3634 |
|
|
3635 |
< |
if (NumberPerCidr(old_class) > 0 && NumberPerCidr(new_class) > 0) |
3635 |
> |
if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0) |
3636 |
|
{ |
3637 |
< |
if (CidrBitlenIPV4(old_class) > 0 && CidrBitlenIPV4(new_class) > 0) |
3637 |
> |
if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0) |
3638 |
|
rebuild_cidr_list(AF_INET, conf, new_class, |
3639 |
|
&old_class->list_ipv4, &new_class->list_ipv4, |
3640 |
< |
CidrBitlenIPV4(old_class) != CidrBitlenIPV4(new_class)); |
3640 |
> |
old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4); |
3641 |
|
|
3642 |
|
#ifdef IPV6 |
3643 |
< |
if (CidrBitlenIPV6(old_class) > 0 && CidrBitlenIPV6(new_class) > 0) |
3643 |
> |
if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0) |
3644 |
|
rebuild_cidr_list(AF_INET6, conf, new_class, |
3645 |
|
&old_class->list_ipv6, &new_class->list_ipv6, |
3646 |
< |
CidrBitlenIPV6(old_class) != CidrBitlenIPV6(new_class)); |
3646 |
> |
old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6); |
3647 |
|
#endif |
3648 |
|
} |
3649 |
|
|