| 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" |
| 31 |
– |
#include "s_stats.h" |
| 32 |
|
#include "channel.h" |
| 33 |
|
#include "client.h" |
| 34 |
– |
#include "common.h" |
| 34 |
|
#include "event.h" |
| 36 |
– |
#include "hash.h" |
| 35 |
|
#include "hook.h" |
| 36 |
|
#include "irc_string.h" |
| 39 |
– |
#include "sprintf_irc.h" |
| 37 |
|
#include "s_bsd.h" |
| 41 |
– |
#include "irc_getnameinfo.h" |
| 42 |
– |
#include "irc_getaddrinfo.h" |
| 38 |
|
#include "ircd.h" |
| 44 |
– |
#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" |
| 53 |
– |
#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 }; |
| 66 |
– |
dlink_list hub_items = { NULL, NULL, 0 }; |
| 67 |
– |
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 |
|
|
| 77 |
– |
dlink_list temporary_klines = { NULL, NULL, 0 }; |
| 78 |
– |
dlink_list temporary_dlines = { NULL, NULL, 0 }; |
| 71 |
|
dlink_list temporary_xlines = { NULL, NULL, 0 }; |
| 80 |
– |
dlink_list temporary_rklines = { NULL, NULL, 0 }; |
| 81 |
– |
dlink_list temporary_glines = { NULL, NULL, 0 }; |
| 82 |
– |
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]; |
| 88 |
– |
extern char yytext[]; |
| 77 |
|
extern int yyparse(); /* defined in y.tab.c */ |
| 78 |
< |
unsigned int scount = 0; /* used by yyparse(), etc */ |
| 79 |
< |
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 *); |
| 95 |
< |
static void set_default_conf(void); |
| 96 |
< |
static void validate_conf(void); |
| 97 |
< |
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 |
|
|
| 120 |
– |
FBFILE *conf_fbfile_in = NULL; |
| 121 |
– |
|
| 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; |
| 177 |
< |
struct ConfItem *conf; |
| 159 |
> |
struct AccessItem *aconf = vptr; |
| 160 |
|
|
| 161 |
< |
MyFree(aconf->dns_query); |
| 180 |
< |
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", |
| 186 |
< |
aconf->host); |
| 187 |
< |
conf = unmap_conf_item(aconf); |
| 188 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 189 |
< |
"Ignoring connect{} block for %s - host not found", |
| 190 |
< |
conf->name); |
| 191 |
< |
delete_conf_item(conf); |
| 192 |
< |
} |
| 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; |
| 208 |
< |
aconf->dns_query->callback = conf_dns_callback; |
| 209 |
< |
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 |
|
|
| 280 |
– |
case LEAF_TYPE: |
| 281 |
– |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
| 282 |
– |
sizeof(struct MatchItem)); |
| 283 |
– |
dlinkAdd(conf, &conf->node, &leaf_items); |
| 284 |
– |
break; |
| 285 |
– |
|
| 286 |
– |
case HUB_TYPE: |
| 287 |
– |
conf = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
| 288 |
– |
sizeof(struct MatchItem)); |
| 289 |
– |
dlinkAdd(conf, &conf->node, &hub_items); |
| 290 |
– |
break; |
| 291 |
– |
|
| 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 = (struct ConfItem *)MyMalloc(sizeof(struct ConfItem) + |
| 308 |
< |
sizeof(struct ClassItem)); |
| 307 |
> |
conf = MyMalloc(sizeof(struct ConfItem) + |
| 308 |
> |
sizeof(struct ClassItem)); |
| 309 |
|
dlinkAdd(conf, &conf->node, &class_items); |
| 310 |
< |
aclass = (struct ClassItem *)map_to_conf(conf); |
| 311 |
< |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
| 312 |
< |
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
| 313 |
< |
MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT; |
| 314 |
< |
MaxSendq(aclass) = DEFAULT_SENDQ; |
| 315 |
< |
CurrUserCount(aclass) = 0; |
| 310 |
> |
|
| 311 |
> |
aclass = map_to_conf(conf); |
| 312 |
> |
aclass->active = 1; |
| 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 |
|
|
| 320 |
|
default: |
| 325 |
|
/* XXX Yes, this will core if default is hit. I want it to for now - db */ |
| 326 |
|
conf->type = type; |
| 327 |
|
|
| 328 |
< |
return(conf); |
| 328 |
> |
return conf; |
| 329 |
|
} |
| 330 |
|
|
| 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 |
< |
{ |
| 387 |
< |
delete_resolver_queries(aconf->dns_query); |
| 388 |
< |
MyFree(aconf->dns_query); |
| 389 |
< |
} |
| 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); |
| 367 |
< |
MyFree(aconf->fakename); |
| 367 |
> |
MyFree(aconf->cipher_list); |
| 368 |
|
#ifdef HAVE_LIBCRYPTO |
| 369 |
|
if (aconf->rsa_public_key) |
| 370 |
|
RSA_free(aconf->rsa_public_key); |
| 391 |
|
|
| 392 |
|
case SERVER_TYPE: |
| 393 |
|
aconf = map_to_conf(conf); |
| 394 |
+ |
|
| 395 |
+ |
DLINK_FOREACH_SAFE(m, m_next, aconf->hub_list.head) |
| 396 |
+ |
{ |
| 397 |
+ |
MyFree(m->data); |
| 398 |
+ |
free_dlink_node(m); |
| 399 |
+ |
} |
| 400 |
+ |
|
| 401 |
+ |
DLINK_FOREACH_SAFE(m, m_next, aconf->leaf_list.head) |
| 402 |
+ |
{ |
| 403 |
+ |
MyFree(m->data); |
| 404 |
+ |
free_dlink_node(m); |
| 405 |
+ |
} |
| 406 |
+ |
|
| 407 |
|
if (!IsConfIllegal(aconf)) |
| 408 |
|
dlinkDelete(&conf->node, &server_items); |
| 409 |
|
MyFree(conf); |
| 414 |
|
} |
| 415 |
|
break; |
| 416 |
|
|
| 439 |
– |
case HUB_TYPE: |
| 440 |
– |
match_item = map_to_conf(conf); |
| 441 |
– |
MyFree(match_item->user); |
| 442 |
– |
MyFree(match_item->host); |
| 443 |
– |
MyFree(match_item->reason); |
| 444 |
– |
MyFree(match_item->oper_reason); |
| 445 |
– |
/* If marked illegal, its already been pulled off of the hub_items list */ |
| 446 |
– |
if (!match_item->illegal) |
| 447 |
– |
dlinkDelete(&conf->node, &hub_items); |
| 448 |
– |
MyFree(conf); |
| 449 |
– |
break; |
| 450 |
– |
|
| 451 |
– |
case LEAF_TYPE: |
| 452 |
– |
match_item = map_to_conf(conf); |
| 453 |
– |
MyFree(match_item->user); |
| 454 |
– |
MyFree(match_item->host); |
| 455 |
– |
MyFree(match_item->reason); |
| 456 |
– |
MyFree(match_item->oper_reason); |
| 457 |
– |
/* If marked illegal, its already been pulled off of the leaf_items list */ |
| 458 |
– |
if (!match_item->illegal) |
| 459 |
– |
dlinkDelete(&conf->node, &leaf_items); |
| 460 |
– |
MyFree(conf); |
| 461 |
– |
break; |
| 462 |
– |
|
| 417 |
|
case ULINE_TYPE: |
| 418 |
|
match_item = map_to_conf(conf); |
| 419 |
|
MyFree(match_item->user); |
| 433 |
|
dlinkDelete(&conf->node, &xconf_items); |
| 434 |
|
MyFree(conf); |
| 435 |
|
break; |
| 436 |
< |
|
| 436 |
> |
#ifdef HAVE_LIBPCRE |
| 437 |
|
case RKLINE_TYPE: |
| 438 |
|
aconf = map_to_conf(conf); |
| 439 |
|
MyFree(aconf->regexuser); |
| 456 |
|
dlinkDelete(&conf->node, &rxconf_items); |
| 457 |
|
MyFree(conf); |
| 458 |
|
break; |
| 459 |
< |
|
| 459 |
> |
#endif |
| 460 |
|
case NRESV_TYPE: |
| 461 |
|
match_item = map_to_conf(conf); |
| 462 |
|
MyFree(match_item->user); |
| 498 |
|
MyFree(conf); |
| 499 |
|
break; |
| 500 |
|
|
| 501 |
+ |
case SERVICE_TYPE: |
| 502 |
+ |
dlinkDelete(&conf->node, &service_items); |
| 503 |
+ |
MyFree(conf); |
| 504 |
+ |
break; |
| 505 |
+ |
|
| 506 |
|
default: |
| 507 |
|
break; |
| 508 |
|
} |
| 536 |
|
* side effects - |
| 537 |
|
*/ |
| 538 |
|
void |
| 539 |
< |
report_confitem_types(struct Client *source_p, ConfType type, int temp) |
| 539 |
> |
report_confitem_types(struct Client *source_p, ConfType type) |
| 540 |
|
{ |
| 541 |
< |
dlink_node *ptr = NULL; |
| 541 |
> |
dlink_node *ptr = NULL, *dptr = NULL; |
| 542 |
|
struct ConfItem *conf = NULL; |
| 543 |
|
struct AccessItem *aconf = NULL; |
| 544 |
|
struct MatchItem *matchitem = NULL; |
| 587 |
|
} |
| 588 |
|
break; |
| 589 |
|
|
| 590 |
+ |
#ifdef HAVE_LIBPCRE |
| 591 |
|
case RXLINE_TYPE: |
| 592 |
|
DLINK_FOREACH(ptr, rxconf_items.head) |
| 593 |
|
{ |
| 596 |
|
|
| 597 |
|
sendto_one(source_p, form_str(RPL_STATSXLINE), |
| 598 |
|
me.name, source_p->name, |
| 599 |
< |
matchitem->hold ? "xR": "XR", matchitem->count, |
| 599 |
> |
"XR", matchitem->count, |
| 600 |
|
conf->name, matchitem->reason); |
| 601 |
|
} |
| 602 |
|
break; |
| 603 |
|
|
| 604 |
|
case RKLINE_TYPE: |
| 645 |
– |
p = temp ? "Rk" : "RK"; |
| 646 |
– |
|
| 605 |
|
DLINK_FOREACH(ptr, rkconf_items.head) |
| 606 |
|
{ |
| 607 |
|
aconf = map_to_conf((conf = ptr->data)); |
| 608 |
|
|
| 651 |
– |
if (temp && !(conf->flags & CONF_FLAGS_TEMPORARY)) |
| 652 |
– |
continue; |
| 653 |
– |
|
| 609 |
|
sendto_one(source_p, form_str(RPL_STATSKLINE), me.name, |
| 610 |
< |
source_p->name, p, aconf->host, aconf->user, |
| 610 |
> |
source_p->name, "KR", aconf->host, aconf->user, |
| 611 |
|
aconf->reason, aconf->oper_reason ? aconf->oper_reason : ""); |
| 612 |
|
} |
| 613 |
|
break; |
| 614 |
+ |
#endif |
| 615 |
|
|
| 616 |
|
case ULINE_TYPE: |
| 617 |
|
DLINK_FOREACH(ptr, uconf_items.head) |
| 656 |
|
aconf = map_to_conf(conf); |
| 657 |
|
|
| 658 |
|
/* Don't allow non opers to see oper privs */ |
| 659 |
< |
if (IsOper(source_p)) |
| 659 |
> |
if (HasUMode(source_p, UMODE_OPER)) |
| 660 |
|
sendto_one(source_p, form_str(RPL_STATSOLINE), |
| 661 |
|
me.name, source_p->name, 'O', aconf->user, aconf->host, |
| 662 |
|
conf->name, oper_privs_as_string(aconf->port), |
| 676 |
|
classitem = map_to_conf(conf); |
| 677 |
|
sendto_one(source_p, form_str(RPL_STATSYLINE), |
| 678 |
|
me.name, source_p->name, 'Y', |
| 679 |
< |
conf->name, PingFreq(classitem), |
| 680 |
< |
ConFreq(classitem), |
| 681 |
< |
MaxTotal(classitem), MaxSendq(classitem)); |
| 679 |
> |
conf->name, classitem->ping_freq, |
| 680 |
> |
classitem->con_freq, |
| 681 |
> |
classitem->max_total, classitem->max_sendq, |
| 682 |
> |
classitem->curr_user_count, |
| 683 |
> |
classitem->active ? "active" : "disabled"); |
| 684 |
|
} |
| 685 |
|
break; |
| 686 |
|
|
| 688 |
|
case CLIENT_TYPE: |
| 689 |
|
break; |
| 690 |
|
|
| 691 |
+ |
case SERVICE_TYPE: |
| 692 |
+ |
DLINK_FOREACH(ptr, service_items.head) |
| 693 |
+ |
{ |
| 694 |
+ |
conf = ptr->data; |
| 695 |
+ |
sendto_one(source_p, form_str(RPL_STATSSERVICE), |
| 696 |
+ |
me.name, source_p->name, 'S', "*", conf->name, 0, 0); |
| 697 |
+ |
} |
| 698 |
+ |
break; |
| 699 |
+ |
|
| 700 |
|
case SERVER_TYPE: |
| 701 |
|
DLINK_FOREACH(ptr, server_items.head) |
| 702 |
|
{ |
| 709 |
|
|
| 710 |
|
if (IsConfAllowAutoConn(aconf)) |
| 711 |
|
*p++ = 'A'; |
| 712 |
< |
if (IsConfCryptLink(aconf)) |
| 713 |
< |
*p++ = 'C'; |
| 747 |
< |
if (IsConfLazyLink(aconf)) |
| 748 |
< |
*p++ = 'L'; |
| 749 |
< |
if (aconf->fakename) |
| 750 |
< |
*p++ = 'M'; |
| 712 |
> |
if (IsConfSSL(aconf)) |
| 713 |
> |
*p++ = 'S'; |
| 714 |
|
if (IsConfTopicBurst(aconf)) |
| 715 |
|
*p++ = 'T'; |
| 753 |
– |
if (IsConfCompressed(aconf)) |
| 754 |
– |
*p++ = 'Z'; |
| 716 |
|
if (buf[0] == '\0') |
| 717 |
|
*p++ = '*'; |
| 718 |
|
|
| 719 |
|
*p = '\0'; |
| 720 |
|
|
| 721 |
< |
/* Allow admins to see actual ips |
| 722 |
< |
* unless hide_server_ips is enabled |
| 721 |
> |
/* |
| 722 |
> |
* Allow admins to see actual ips unless hide_server_ips is enabled |
| 723 |
|
*/ |
| 724 |
< |
if (!ConfigServerHide.hide_server_ips && IsAdmin(source_p)) |
| 724 |
> |
if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN)) |
| 725 |
|
sendto_one(source_p, form_str(RPL_STATSCLINE), |
| 726 |
|
me.name, source_p->name, 'C', aconf->host, |
| 727 |
|
buf, conf->name, aconf->port, |
| 735 |
|
break; |
| 736 |
|
|
| 737 |
|
case HUB_TYPE: |
| 738 |
< |
DLINK_FOREACH(ptr, hub_items.head) |
| 738 |
> |
DLINK_FOREACH(ptr, server_items.head) |
| 739 |
|
{ |
| 740 |
|
conf = ptr->data; |
| 741 |
< |
matchitem = map_to_conf(conf); |
| 742 |
< |
sendto_one(source_p, form_str(RPL_STATSHLINE), me.name, |
| 743 |
< |
source_p->name, 'H', matchitem->host, conf->name, 0, "*"); |
| 741 |
> |
aconf = map_to_conf(conf); |
| 742 |
> |
|
| 743 |
> |
DLINK_FOREACH(dptr, aconf->hub_list.head) |
| 744 |
> |
sendto_one(source_p, form_str(RPL_STATSHLINE), me.name, |
| 745 |
> |
source_p->name, 'H', dptr->data, conf->name, 0, "*"); |
| 746 |
|
} |
| 747 |
|
break; |
| 748 |
|
|
| 749 |
|
case LEAF_TYPE: |
| 750 |
< |
DLINK_FOREACH(ptr, leaf_items.head) |
| 750 |
> |
DLINK_FOREACH(ptr, server_items.head) |
| 751 |
|
{ |
| 752 |
|
conf = ptr->data; |
| 753 |
< |
matchitem = map_to_conf(conf); |
| 754 |
< |
sendto_one(source_p, form_str(RPL_STATSLLINE), me.name, |
| 755 |
< |
source_p->name, 'L', matchitem->host, conf->name, 0, "*"); |
| 753 |
> |
aconf = map_to_conf(conf); |
| 754 |
> |
|
| 755 |
> |
DLINK_FOREACH(dptr, aconf->leaf_list.head) |
| 756 |
> |
sendto_one(source_p, form_str(RPL_STATSLLINE), me.name, |
| 757 |
> |
source_p->name, 'L', dptr->data, conf->name, 0, "*"); |
| 758 |
|
} |
| 759 |
|
break; |
| 760 |
|
|
| 765 |
|
case CRESV_TYPE: |
| 766 |
|
case NRESV_TYPE: |
| 767 |
|
case CLUSTER_TYPE: |
| 768 |
+ |
default: |
| 769 |
|
break; |
| 770 |
|
} |
| 771 |
|
} |
| 792 |
|
|
| 793 |
|
/* I'm already in big trouble if source_p->localClient is NULL -db */ |
| 794 |
|
if ((i = verify_access(source_p, username))) |
| 795 |
< |
{ |
| 830 |
< |
ilog(L_INFO, "Access denied: %s[%s]", |
| 795 |
> |
ilog(LOG_TYPE_IRCD, "Access denied: %s[%s]", |
| 796 |
|
source_p->name, source_p->sockhost); |
| 832 |
– |
} |
| 797 |
|
|
| 798 |
|
switch (i) |
| 799 |
|
{ |
| 836 |
– |
case IRCD_SOCKET_ERROR: |
| 837 |
– |
exit_client(source_p, &me, "Socket Error"); |
| 838 |
– |
break; |
| 839 |
– |
|
| 800 |
|
case TOO_MANY: |
| 801 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, |
| 802 |
|
"Too many on IP for %s (%s).", |
| 803 |
|
get_client_name(source_p, SHOW_IP), |
| 804 |
|
source_p->sockhost); |
| 805 |
< |
ilog(L_INFO,"Too many connections on IP from %s.", |
| 805 |
> |
ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.", |
| 806 |
|
get_client_name(source_p, SHOW_IP)); |
| 807 |
< |
ServerStats->is_ref++; |
| 807 |
> |
++ServerStats.is_ref; |
| 808 |
|
exit_client(source_p, &me, "No more connections allowed on that IP"); |
| 809 |
|
break; |
| 810 |
|
|
| 813 |
|
"I-line is full for %s (%s).", |
| 814 |
|
get_client_name(source_p, SHOW_IP), |
| 815 |
|
source_p->sockhost); |
| 816 |
< |
ilog(L_INFO,"Too many connections from %s.", |
| 816 |
> |
ilog(LOG_TYPE_IRCD, "Too many connections from %s.", |
| 817 |
|
get_client_name(source_p, SHOW_IP)); |
| 818 |
< |
ServerStats->is_ref++; |
| 818 |
> |
++ServerStats.is_ref; |
| 819 |
|
exit_client(source_p, &me, |
| 820 |
|
"No more connections allowed in your connection class"); |
| 821 |
|
break; |
| 822 |
|
|
| 823 |
|
case NOT_AUTHORIZED: |
| 824 |
< |
{ |
| 865 |
< |
static char ipaddr[HOSTIPLEN]; |
| 866 |
< |
ServerStats->is_ref++; |
| 824 |
> |
++ServerStats.is_ref; |
| 825 |
|
/* jdc - lists server name & port connections are on */ |
| 826 |
|
/* a purely cosmetical change */ |
| 869 |
– |
irc_getnameinfo((struct sockaddr*)&source_p->localClient->ip, |
| 870 |
– |
source_p->localClient->ip.ss_len, ipaddr, HOSTIPLEN, NULL, 0, |
| 871 |
– |
NI_NUMERICHOST); |
| 827 |
|
sendto_realops_flags(UMODE_UNAUTH, L_ALL, |
| 828 |
|
"Unauthorized client connection from %s [%s] on [%s/%u].", |
| 829 |
|
get_client_name(source_p, SHOW_IP), |
| 830 |
< |
ipaddr, |
| 830 |
> |
source_p->sockhost, |
| 831 |
|
source_p->localClient->listener->name, |
| 832 |
|
source_p->localClient->listener->port); |
| 833 |
< |
ilog(L_INFO, |
| 833 |
> |
ilog(LOG_TYPE_IRCD, |
| 834 |
|
"Unauthorized client connection from %s on [%s/%u].", |
| 835 |
|
get_client_name(source_p, SHOW_IP), |
| 836 |
|
source_p->localClient->listener->name, |
| 840 |
|
* capture reject code here or rely on the connecting too fast code. |
| 841 |
|
* - Dianora |
| 842 |
|
*/ |
| 843 |
< |
if(REJECT_HOLD_TIME > 0) |
| 843 |
> |
if (REJECT_HOLD_TIME > 0) |
| 844 |
|
{ |
| 845 |
|
sendto_one(source_p, ":%s NOTICE %s :You are not authorized to use this server", |
| 846 |
|
me.name, source_p->name); |
| 850 |
|
else |
| 851 |
|
exit_client(source_p, &me, "You are not authorized to use this server"); |
| 852 |
|
break; |
| 853 |
< |
} |
| 899 |
< |
|
| 853 |
> |
|
| 854 |
|
case BANNED_CLIENT: |
| 855 |
|
/* |
| 856 |
|
* Don't exit them immediately, play with them a bit. |
| 863 |
|
} |
| 864 |
|
else |
| 865 |
|
exit_client(source_p, &me, "Banned"); |
| 866 |
< |
ServerStats->is_ref++; |
| 866 |
> |
++ServerStats.is_ref; |
| 867 |
|
break; |
| 868 |
|
|
| 869 |
|
case 0: |
| 980 |
|
ip_found->count++; |
| 981 |
|
SetIpHash(client_p); |
| 982 |
|
|
| 983 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 983 |
> |
aconf = map_to_conf(conf); |
| 984 |
|
if (aconf->class_ptr == NULL) |
| 985 |
|
return NOT_AUTHORIZED; /* If class is missing, this is best */ |
| 986 |
|
|
| 987 |
< |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
| 987 |
> |
aclass = map_to_conf(aconf->class_ptr); |
| 988 |
|
|
| 989 |
|
count_user_host(client_p->username, client_p->host, |
| 990 |
|
&global, &local, &ident); |
| 993 |
|
* setting a_limit_reached if any limit is reached. |
| 994 |
|
* - Dianora |
| 995 |
|
*/ |
| 996 |
< |
if (MaxTotal(aclass) != 0 && CurrUserCount(aclass) >= MaxTotal(aclass)) |
| 996 |
> |
if (aclass->max_total != 0 && aclass->curr_user_count >= aclass->max_total) |
| 997 |
|
a_limit_reached = 1; |
| 998 |
< |
else if (MaxPerIp(aclass) != 0 && ip_found->count >= MaxPerIp(aclass)) |
| 998 |
> |
else if (aclass->max_perip != 0 && ip_found->count > aclass->max_perip) |
| 999 |
|
a_limit_reached = 1; |
| 1000 |
< |
else if (MaxLocal(aclass) != 0 && local >= MaxLocal(aclass)) |
| 1000 |
> |
else if (aclass->max_local != 0 && local >= aclass->max_local) |
| 1001 |
|
a_limit_reached = 1; |
| 1002 |
< |
else if (MaxGlobal(aclass) != 0 && global >= MaxGlobal(aclass)) |
| 1002 |
> |
else if (aclass->max_global != 0 && global >= aclass->max_global) |
| 1003 |
|
a_limit_reached = 1; |
| 1004 |
< |
else if (MaxIdent(aclass) != 0 && ident >= MaxIdent(aclass) && |
| 1004 |
> |
else if (aclass->max_ident != 0 && ident >= aclass->max_ident && |
| 1005 |
|
client_p->username[0] != '~') |
| 1006 |
|
a_limit_reached = 1; |
| 1007 |
|
|
| 1008 |
|
if (a_limit_reached) |
| 1009 |
|
{ |
| 1010 |
|
if (!IsConfExemptLimits(aconf)) |
| 1011 |
< |
return TOO_MANY; /* Already at maximum allowed */ |
| 1011 |
> |
return TOO_MANY; /* Already at maximum allowed */ |
| 1012 |
|
|
| 1013 |
|
sendto_one(client_p, |
| 1014 |
|
":%s NOTICE %s :*** Your connection class is full, " |
| 1157 |
|
{ |
| 1158 |
|
struct sockaddr_in *v4 = (struct sockaddr_in *)addr; |
| 1159 |
|
int hash; |
| 1160 |
< |
u_int32_t ip; |
| 1160 |
> |
uint32_t ip; |
| 1161 |
|
|
| 1162 |
|
ip = ntohl(v4->sin_addr.s_addr); |
| 1163 |
|
hash = ((ip >> 12) + ip) & (IP_HASH_SIZE-1); |
| 1168 |
|
{ |
| 1169 |
|
int hash; |
| 1170 |
|
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr; |
| 1171 |
< |
u_int32_t *ip = (u_int32_t *)&v6->sin6_addr.s6_addr; |
| 1171 |
> |
uint32_t *ip = (uint32_t *)&v6->sin6_addr.s6_addr; |
| 1172 |
|
|
| 1173 |
|
hash = ip[0] ^ ip[3]; |
| 1174 |
|
hash ^= hash >> 16; |
| 1192 |
|
* used in the hash. |
| 1193 |
|
*/ |
| 1194 |
|
void |
| 1195 |
< |
count_ip_hash(int *number_ips_stored, unsigned long *mem_ips_stored) |
| 1195 |
> |
count_ip_hash(unsigned int *number_ips_stored, uint64_t *mem_ips_stored) |
| 1196 |
|
{ |
| 1197 |
|
struct ip_entry *ptr; |
| 1198 |
|
int i; |
| 1280 |
|
case CLIENT_TYPE: |
| 1281 |
|
case OPER_TYPE: |
| 1282 |
|
case SERVER_TYPE: |
| 1283 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 1284 |
< |
if ((aclass_conf = ClassPtr(aconf)) != NULL) |
| 1283 |
> |
aconf = map_to_conf(conf); |
| 1284 |
> |
|
| 1285 |
> |
assert(aconf->clients > 0); |
| 1286 |
> |
|
| 1287 |
> |
if ((aclass_conf = aconf->class_ptr) != NULL) |
| 1288 |
|
{ |
| 1289 |
< |
aclass = (struct ClassItem *)map_to_conf(aclass_conf); |
| 1289 |
> |
aclass = map_to_conf(aclass_conf); |
| 1290 |
> |
|
| 1291 |
> |
assert(aclass->curr_user_count > 0); |
| 1292 |
|
|
| 1293 |
|
if (conf->type == CLIENT_TYPE) |
| 1294 |
|
remove_from_cidr_check(&client_p->localClient->ip, aclass); |
| 1295 |
< |
|
| 1337 |
< |
if (CurrUserCount(aclass) > 0) |
| 1338 |
< |
aclass->curr_user_count--; |
| 1339 |
< |
if (MaxTotal(aclass) < 0 && CurrUserCount(aclass) <= 0) |
| 1295 |
> |
if (--aclass->curr_user_count == 0 && aclass->active == 0) |
| 1296 |
|
delete_conf_item(aclass_conf); |
| 1297 |
|
} |
| 1298 |
|
|
| 1299 |
< |
/* Please, no ioccc entries - Dianora */ |
| 1344 |
< |
if (aconf->clients > 0) |
| 1345 |
< |
--aconf->clients; |
| 1346 |
< |
if (aconf->clients == 0 && IsConfIllegal(aconf)) |
| 1347 |
< |
delete_conf_item(conf); |
| 1348 |
< |
break; |
| 1349 |
< |
case LEAF_TYPE: |
| 1350 |
< |
case HUB_TYPE: |
| 1351 |
< |
match_item = (struct MatchItem *)map_to_conf(conf); |
| 1352 |
< |
if (match_item->ref_count == 0 && match_item->illegal) |
| 1299 |
> |
if (--aconf->clients == 0 && IsConfIllegal(aconf)) |
| 1300 |
|
delete_conf_item(conf); |
| 1301 |
+ |
|
| 1302 |
|
break; |
| 1303 |
|
default: |
| 1304 |
|
break; |
| 1325 |
|
int |
| 1326 |
|
attach_conf(struct Client *client_p, struct ConfItem *conf) |
| 1327 |
|
{ |
| 1380 |
– |
struct AccessItem *aconf; |
| 1381 |
– |
struct MatchItem *match_item; |
| 1382 |
– |
|
| 1328 |
|
if (dlinkFind(&client_p->localClient->confs, conf) != NULL) |
| 1329 |
|
return 1; |
| 1330 |
|
|
| 1332 |
|
conf->type == SERVER_TYPE || |
| 1333 |
|
conf->type == OPER_TYPE) |
| 1334 |
|
{ |
| 1335 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 1335 |
> |
struct AccessItem *aconf = map_to_conf(conf); |
| 1336 |
> |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
| 1337 |
|
|
| 1338 |
|
if (IsConfIllegal(aconf)) |
| 1339 |
|
return NOT_AUTHORIZED; |
| 1340 |
|
|
| 1341 |
|
if (conf->type == CLIENT_TYPE) |
| 1396 |
– |
{ |
| 1397 |
– |
struct ClassItem *aclass; |
| 1398 |
– |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
| 1399 |
– |
|
| 1342 |
|
if (cidr_limit_reached(IsConfExemptLimits(aconf), |
| 1343 |
|
&client_p->localClient->ip, aclass)) |
| 1344 |
< |
return TOO_MANY; /* Already at maximum allowed */ |
| 1403 |
< |
|
| 1404 |
< |
CurrUserCount(aclass)++; |
| 1405 |
< |
} |
| 1344 |
> |
return TOO_MANY; /* Already at maximum allowed */ |
| 1345 |
|
|
| 1346 |
+ |
aclass->curr_user_count++; |
| 1347 |
|
aconf->clients++; |
| 1348 |
|
} |
| 1409 |
– |
else if (conf->type == HUB_TYPE || conf->type == LEAF_TYPE) |
| 1410 |
– |
{ |
| 1411 |
– |
match_item = (struct MatchItem *)map_to_conf(conf); |
| 1412 |
– |
match_item->ref_count++; |
| 1413 |
– |
} |
| 1349 |
|
|
| 1350 |
|
dlinkAdd(conf, make_dlink_node(), &client_p->localClient->confs); |
| 1351 |
|
|
| 1377 |
|
DLINK_FOREACH(ptr, server_items.head) |
| 1378 |
|
{ |
| 1379 |
|
conf = ptr->data; |
| 1380 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 1380 |
> |
aconf = map_to_conf(conf); |
| 1381 |
|
|
| 1382 |
|
if (match(conf->name, name) == 0 || match(aconf->host, host) == 0) |
| 1383 |
|
continue; |
| 1417 |
|
|
| 1418 |
|
if (conf->name == NULL) |
| 1419 |
|
continue; |
| 1420 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 1420 |
> |
aconf = map_to_conf(conf); |
| 1421 |
|
if (aconf->host == NULL) |
| 1422 |
|
continue; |
| 1423 |
|
if (irccmp(conf->name, name) != 0) |
| 1428 |
|
** socket host) matches *either* host or name field |
| 1429 |
|
** of the configuration. |
| 1430 |
|
*/ |
| 1431 |
< |
if (!match(aconf->host, host) || !match(aconf->user,user) |
| 1497 |
< |
|| irccmp(conf->name, name) ) |
| 1431 |
> |
if (!match(aconf->host, host) || !match(aconf->user, user)) |
| 1432 |
|
continue; |
| 1433 |
|
if (type == OPER_TYPE) |
| 1434 |
|
{ |
| 1435 |
< |
struct ClassItem *aclass; |
| 1435 |
> |
struct ClassItem *aclass = map_to_conf(aconf->class_ptr); |
| 1436 |
|
|
| 1437 |
< |
aclass = (struct ClassItem *)aconf->class_ptr; |
| 1504 |
< |
if (aconf->clients < MaxTotal(aclass)) |
| 1505 |
< |
return conf; |
| 1506 |
< |
else |
| 1437 |
> |
if (aconf->clients >= aclass->max_total) |
| 1438 |
|
continue; |
| 1439 |
|
} |
| 1440 |
< |
else |
| 1441 |
< |
return conf; |
| 1440 |
> |
|
| 1441 |
> |
return conf; |
| 1442 |
|
} |
| 1443 |
+ |
|
| 1444 |
|
return NULL; |
| 1445 |
|
} |
| 1446 |
|
|
| 1506 |
|
case SERVER_TYPE: |
| 1507 |
|
return(&server_items); |
| 1508 |
|
break; |
| 1509 |
+ |
case SERVICE_TYPE: |
| 1510 |
+ |
return(&service_items); |
| 1511 |
+ |
break; |
| 1512 |
|
case CLUSTER_TYPE: |
| 1513 |
|
return(&cluster_items); |
| 1514 |
|
break; |
| 1544 |
|
|
| 1545 |
|
switch (type) |
| 1546 |
|
{ |
| 1547 |
< |
case RXLINE_TYPE: |
| 1547 |
> |
#ifdef HAVE_LIBPCRE |
| 1548 |
> |
case RXLINE_TYPE: |
| 1549 |
|
DLINK_FOREACH(ptr, list_p->head) |
| 1550 |
|
{ |
| 1551 |
|
conf = ptr->data; |
| 1555 |
|
return conf; |
| 1556 |
|
} |
| 1557 |
|
break; |
| 1558 |
+ |
#endif |
| 1559 |
+ |
case SERVICE_TYPE: |
| 1560 |
+ |
DLINK_FOREACH(ptr, list_p->head) |
| 1561 |
+ |
{ |
| 1562 |
+ |
conf = ptr->data; |
| 1563 |
+ |
|
| 1564 |
+ |
if (EmptyString(conf->name)) |
| 1565 |
+ |
continue; |
| 1566 |
+ |
if ((name != NULL) && !irccmp(name, conf->name)) |
| 1567 |
+ |
return conf; |
| 1568 |
+ |
} |
| 1569 |
+ |
break; |
| 1570 |
|
|
| 1571 |
|
case XLINE_TYPE: |
| 1572 |
|
case ULINE_TYPE: |
| 1621 |
|
* side effects - looks for an exact match on name field |
| 1622 |
|
*/ |
| 1623 |
|
struct ConfItem * |
| 1624 |
< |
find_exact_name_conf(ConfType type, const char *name, |
| 1624 |
> |
find_exact_name_conf(ConfType type, const struct Client *who, const char *name, |
| 1625 |
|
const char *user, const char *host) |
| 1626 |
|
{ |
| 1627 |
|
dlink_node *ptr = NULL; |
| 1662 |
|
DLINK_FOREACH(ptr, list_p->head) |
| 1663 |
|
{ |
| 1664 |
|
conf = ptr->data; |
| 1665 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 1665 |
> |
aconf = map_to_conf(conf); |
| 1666 |
> |
|
| 1667 |
|
if (EmptyString(conf->name)) |
| 1668 |
< |
continue; |
| 1669 |
< |
|
| 1670 |
< |
if (irccmp(conf->name, name) == 0) |
| 1668 |
> |
continue; |
| 1669 |
> |
|
| 1670 |
> |
if (!irccmp(conf->name, name)) |
| 1671 |
|
{ |
| 1672 |
< |
if ((user == NULL && (host == NULL))) |
| 1673 |
< |
return (conf); |
| 1674 |
< |
if (EmptyString(aconf->user) || EmptyString(aconf->host)) |
| 1675 |
< |
return (conf); |
| 1676 |
< |
if (match(aconf->user, user) && match(aconf->host, host)) |
| 1677 |
< |
return (conf); |
| 1672 |
> |
if (!who) |
| 1673 |
> |
return conf; |
| 1674 |
> |
if (EmptyString(aconf->user) || EmptyString(aconf->host)) |
| 1675 |
> |
return conf; |
| 1676 |
> |
if (match(aconf->user, who->username)) |
| 1677 |
> |
{ |
| 1678 |
> |
switch (aconf->type) |
| 1679 |
> |
{ |
| 1680 |
> |
case HM_HOST: |
| 1681 |
> |
if (match(aconf->host, who->host) || match(aconf->host, who->sockhost)) |
| 1682 |
> |
return conf; |
| 1683 |
> |
break; |
| 1684 |
> |
case HM_IPV4: |
| 1685 |
> |
if (who->localClient->aftype == AF_INET) |
| 1686 |
> |
if (match_ipv4(&who->localClient->ip, &aconf->addr, aconf->bits)) |
| 1687 |
> |
return conf; |
| 1688 |
> |
break; |
| 1689 |
> |
#ifdef IPV6 |
| 1690 |
> |
case HM_IPV6: |
| 1691 |
> |
if (who->localClient->aftype == AF_INET6) |
| 1692 |
> |
if (match_ipv6(&who->localClient->ip, &aconf->addr, aconf->bits)) |
| 1693 |
> |
return conf; |
| 1694 |
> |
break; |
| 1695 |
> |
#endif |
| 1696 |
> |
default: |
| 1697 |
> |
assert(0); |
| 1698 |
> |
} |
| 1699 |
> |
} |
| 1700 |
|
} |
| 1701 |
|
} |
| 1702 |
+ |
|
| 1703 |
|
break; |
| 1704 |
|
|
| 1705 |
|
case SERVER_TYPE: |
| 1755 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 1756 |
|
"Got signal SIGHUP, reloading ircd.conf file"); |
| 1757 |
|
|
| 1786 |
– |
#ifndef _WIN32 |
| 1758 |
|
restart_resolver(); |
| 1759 |
< |
#endif |
| 1759 |
> |
|
| 1760 |
|
/* don't close listeners until we know we can go ahead with the rehash */ |
| 1761 |
|
|
| 1762 |
|
/* Check to see if we magically got(or lost) IPv6 support */ |
| 1767 |
|
if (ServerInfo.description != NULL) |
| 1768 |
|
strlcpy(me.info, ServerInfo.description, sizeof(me.info)); |
| 1769 |
|
|
| 1799 |
– |
#ifndef STATIC_MODULES |
| 1770 |
|
load_conf_modules(); |
| 1801 |
– |
#endif |
| 1771 |
|
|
| 1772 |
|
flush_deleted_I_P(); |
| 1773 |
|
|
| 1774 |
|
rehashed_klines = 1; |
| 1775 |
< |
|
| 1775 |
> |
/* XXX */ |
| 1776 |
|
if (ConfigLoggingEntry.use_logging) |
| 1777 |
< |
reopen_log(logFileName); |
| 1777 |
> |
log_close_all(); |
| 1778 |
|
|
| 1779 |
|
return(0); |
| 1780 |
|
} |
| 1813 |
|
ServerInfo.specific_ipv6_vhost = 0; |
| 1814 |
|
|
| 1815 |
|
ServerInfo.max_clients = MAXCLIENTS_MAX; |
| 1816 |
< |
/* Don't reset hub, as that will break lazylinks */ |
| 1817 |
< |
/* ServerInfo.hub = NO; */ |
| 1816 |
> |
|
| 1817 |
> |
ServerInfo.hub = 0; |
| 1818 |
|
ServerInfo.dns_host.sin_addr.s_addr = 0; |
| 1819 |
|
ServerInfo.dns_host.sin_port = 0; |
| 1820 |
|
AdminInfo.name = NULL; |
| 1821 |
|
AdminInfo.email = NULL; |
| 1822 |
|
AdminInfo.description = NULL; |
| 1823 |
|
|
| 1824 |
< |
set_log_level(L_NOTICE); |
| 1824 |
> |
log_close_all(); |
| 1825 |
> |
|
| 1826 |
|
ConfigLoggingEntry.use_logging = 1; |
| 1827 |
< |
ConfigLoggingEntry.operlog[0] = '\0'; |
| 1828 |
< |
ConfigLoggingEntry.userlog[0] = '\0'; |
| 1829 |
< |
ConfigLoggingEntry.klinelog[0] = '\0'; |
| 1830 |
< |
ConfigLoggingEntry.glinelog[0] = '\0'; |
| 1831 |
< |
ConfigLoggingEntry.killlog[0] = '\0'; |
| 1832 |
< |
ConfigLoggingEntry.operspylog[0] = '\0'; |
| 1833 |
< |
ConfigLoggingEntry.ioerrlog[0] = '\0'; |
| 1864 |
< |
ConfigLoggingEntry.failed_operlog[0] = '\0'; |
| 1865 |
< |
|
| 1866 |
< |
ConfigChannel.restrict_channels = NO; |
| 1867 |
< |
ConfigChannel.disable_local_channels = NO; |
| 1868 |
< |
ConfigChannel.use_invex = YES; |
| 1869 |
< |
ConfigChannel.use_except = YES; |
| 1870 |
< |
ConfigChannel.use_knock = YES; |
| 1827 |
> |
|
| 1828 |
> |
ConfigChannel.disable_fake_channels = 0; |
| 1829 |
> |
ConfigChannel.restrict_channels = 0; |
| 1830 |
> |
ConfigChannel.disable_local_channels = 0; |
| 1831 |
> |
ConfigChannel.use_invex = 1; |
| 1832 |
> |
ConfigChannel.use_except = 1; |
| 1833 |
> |
ConfigChannel.use_knock = 1; |
| 1834 |
|
ConfigChannel.knock_delay = 300; |
| 1835 |
|
ConfigChannel.knock_delay_channel = 60; |
| 1836 |
|
ConfigChannel.max_chans_per_user = 15; |
| 1837 |
< |
ConfigChannel.quiet_on_ban = YES; |
| 1837 |
> |
ConfigChannel.quiet_on_ban = 1; |
| 1838 |
|
ConfigChannel.max_bans = 25; |
| 1839 |
|
ConfigChannel.default_split_user_count = 0; |
| 1840 |
|
ConfigChannel.default_split_server_count = 0; |
| 1841 |
< |
ConfigChannel.no_join_on_split = NO; |
| 1842 |
< |
ConfigChannel.no_create_on_split = NO; |
| 1843 |
< |
ConfigChannel.burst_topicwho = YES; |
| 1841 |
> |
ConfigChannel.no_join_on_split = 0; |
| 1842 |
> |
ConfigChannel.no_create_on_split = 0; |
| 1843 |
> |
ConfigChannel.burst_topicwho = 1; |
| 1844 |
|
|
| 1845 |
< |
ConfigServerHide.flatten_links = NO; |
| 1845 |
> |
ConfigServerHide.flatten_links = 0; |
| 1846 |
|
ConfigServerHide.links_delay = 300; |
| 1847 |
< |
ConfigServerHide.hidden = NO; |
| 1848 |
< |
ConfigServerHide.disable_hidden = NO; |
| 1849 |
< |
ConfigServerHide.hide_servers = NO; |
| 1847 |
> |
ConfigServerHide.hidden = 0; |
| 1848 |
> |
ConfigServerHide.disable_hidden = 0; |
| 1849 |
> |
ConfigServerHide.hide_servers = 0; |
| 1850 |
|
DupString(ConfigServerHide.hidden_name, NETWORK_NAME_DEFAULT); |
| 1851 |
< |
ConfigServerHide.hide_server_ips = NO; |
| 1851 |
> |
ConfigServerHide.hide_server_ips = 0; |
| 1852 |
|
|
| 1853 |
+ |
|
| 1854 |
+ |
DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT); |
| 1855 |
+ |
ConfigFileEntry.max_watch = WATCHSIZE_DEFAULT; |
| 1856 |
|
ConfigFileEntry.gline_min_cidr = 16; |
| 1857 |
|
ConfigFileEntry.gline_min_cidr6 = 48; |
| 1858 |
< |
ConfigFileEntry.invisible_on_connect = YES; |
| 1859 |
< |
ConfigFileEntry.burst_away = NO; |
| 1860 |
< |
ConfigFileEntry.use_whois_actually = YES; |
| 1861 |
< |
ConfigFileEntry.tkline_expire_notices = YES; |
| 1862 |
< |
ConfigFileEntry.hide_spoof_ips = YES; |
| 1863 |
< |
ConfigFileEntry.ignore_bogus_ts = NO; |
| 1864 |
< |
ConfigFileEntry.disable_auth = NO; |
| 1865 |
< |
ConfigFileEntry.disable_remote = NO; |
| 1858 |
> |
ConfigFileEntry.invisible_on_connect = 1; |
| 1859 |
> |
ConfigFileEntry.burst_away = 0; |
| 1860 |
> |
ConfigFileEntry.use_whois_actually = 1; |
| 1861 |
> |
ConfigFileEntry.tkline_expire_notices = 1; |
| 1862 |
> |
ConfigFileEntry.hide_spoof_ips = 1; |
| 1863 |
> |
ConfigFileEntry.ignore_bogus_ts = 0; |
| 1864 |
> |
ConfigFileEntry.disable_auth = 0; |
| 1865 |
> |
ConfigFileEntry.disable_remote = 0; |
| 1866 |
|
ConfigFileEntry.kill_chase_time_limit = 90; |
| 1867 |
< |
ConfigFileEntry.default_floodcount = 8; /* XXX */ |
| 1868 |
< |
ConfigFileEntry.failed_oper_notice = YES; |
| 1869 |
< |
ConfigFileEntry.dots_in_ident = 0; /* XXX */ |
| 1904 |
< |
ConfigFileEntry.dot_in_ip6_addr = YES; |
| 1867 |
> |
ConfigFileEntry.default_floodcount = 8; |
| 1868 |
> |
ConfigFileEntry.failed_oper_notice = 1; |
| 1869 |
> |
ConfigFileEntry.dots_in_ident = 0; |
| 1870 |
|
ConfigFileEntry.min_nonwildcard = 4; |
| 1871 |
|
ConfigFileEntry.min_nonwildcard_simple = 3; |
| 1872 |
|
ConfigFileEntry.max_accept = 20; |
| 1873 |
< |
ConfigFileEntry.anti_nick_flood = NO; /* XXX */ |
| 1873 |
> |
ConfigFileEntry.anti_nick_flood = 0; |
| 1874 |
|
ConfigFileEntry.max_nick_time = 20; |
| 1875 |
|
ConfigFileEntry.max_nick_changes = 5; |
| 1876 |
< |
ConfigFileEntry.anti_spam_exit_message_time = 0; /* XXX */ |
| 1876 |
> |
ConfigFileEntry.anti_spam_exit_message_time = 0; |
| 1877 |
|
ConfigFileEntry.ts_warn_delta = TS_WARN_DELTA_DEFAULT; |
| 1878 |
< |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; /* XXX */ |
| 1879 |
< |
ConfigFileEntry.kline_with_reason = YES; |
| 1878 |
> |
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
| 1879 |
> |
ConfigFileEntry.kline_with_reason = 1; |
| 1880 |
|
ConfigFileEntry.kline_reason = NULL; |
| 1881 |
< |
ConfigFileEntry.warn_no_nline = YES; |
| 1882 |
< |
ConfigFileEntry.stats_o_oper_only = NO; /* XXX */ |
| 1881 |
> |
ConfigFileEntry.warn_no_nline = 1; |
| 1882 |
> |
ConfigFileEntry.stats_o_oper_only = 0; |
| 1883 |
|
ConfigFileEntry.stats_k_oper_only = 1; /* masked */ |
| 1884 |
|
ConfigFileEntry.stats_i_oper_only = 1; /* masked */ |
| 1885 |
< |
ConfigFileEntry.stats_P_oper_only = NO; |
| 1885 |
> |
ConfigFileEntry.stats_P_oper_only = 0; |
| 1886 |
|
ConfigFileEntry.caller_id_wait = 60; |
| 1887 |
< |
ConfigFileEntry.opers_bypass_callerid = NO; |
| 1887 |
> |
ConfigFileEntry.opers_bypass_callerid = 0; |
| 1888 |
|
ConfigFileEntry.pace_wait = 10; |
| 1889 |
|
ConfigFileEntry.pace_wait_simple = 1; |
| 1890 |
< |
ConfigFileEntry.short_motd = NO; |
| 1891 |
< |
ConfigFileEntry.ping_cookie = NO; |
| 1892 |
< |
ConfigFileEntry.no_oper_flood = NO; /* XXX */ |
| 1893 |
< |
ConfigFileEntry.true_no_oper_flood = NO; /* XXX */ |
| 1894 |
< |
ConfigFileEntry.oper_pass_resv = YES; |
| 1895 |
< |
ConfigFileEntry.glines = NO; /* XXX */ |
| 1896 |
< |
ConfigFileEntry.gline_time = 12 * 3600; /* XXX */ |
| 1932 |
< |
ConfigFileEntry.idletime = 0; |
| 1890 |
> |
ConfigFileEntry.short_motd = 0; |
| 1891 |
> |
ConfigFileEntry.ping_cookie = 0; |
| 1892 |
> |
ConfigFileEntry.no_oper_flood = 0; |
| 1893 |
> |
ConfigFileEntry.true_no_oper_flood = 0; |
| 1894 |
> |
ConfigFileEntry.oper_pass_resv = 1; |
| 1895 |
> |
ConfigFileEntry.glines = 0; |
| 1896 |
> |
ConfigFileEntry.gline_time = 12 * 3600; |
| 1897 |
|
ConfigFileEntry.max_targets = MAX_TARGETS_DEFAULT; |
| 1898 |
|
ConfigFileEntry.client_flood = CLIENT_FLOOD_DEFAULT; |
| 1899 |
< |
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; /* XXX */ |
| 1899 |
> |
ConfigFileEntry.oper_only_umodes = UMODE_DEBUG; |
| 1900 |
|
ConfigFileEntry.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | |
| 1901 |
< |
UMODE_OPERWALL | UMODE_WALLOP; /* XXX */ |
| 1902 |
< |
DupString(ConfigFileEntry.servlink_path, SLPATH); |
| 1939 |
< |
#ifdef HAVE_LIBCRYPTO |
| 1940 |
< |
/* jdc -- This is our default value for a cipher. According to the |
| 1941 |
< |
* CRYPTLINK document (doc/cryptlink.txt), BF/128 must be supported |
| 1942 |
< |
* under all circumstances if cryptlinks are enabled. So, |
| 1943 |
< |
* this will be our default. |
| 1944 |
< |
* |
| 1945 |
< |
* NOTE: I apologise for the hard-coded value of "1" (BF/128). |
| 1946 |
< |
* This should be moved into a find_cipher() routine. |
| 1947 |
< |
*/ |
| 1948 |
< |
ConfigFileEntry.default_cipher_preference = &CipherTable[1]; |
| 1949 |
< |
#endif |
| 1950 |
< |
ConfigFileEntry.use_egd = NO; |
| 1901 |
> |
UMODE_OPERWALL | UMODE_WALLOP; |
| 1902 |
> |
ConfigFileEntry.use_egd = 0; |
| 1903 |
|
ConfigFileEntry.egdpool_path = NULL; |
| 1952 |
– |
#ifdef HAVE_LIBZ |
| 1953 |
– |
ConfigFileEntry.compression_level = 0; |
| 1954 |
– |
#endif |
| 1904 |
|
ConfigFileEntry.throttle_time = 10; |
| 1905 |
|
} |
| 1906 |
|
|
| 1958 |
– |
/* read_conf() |
| 1959 |
– |
* |
| 1960 |
– |
* inputs - file descriptor pointing to config file to use |
| 1961 |
– |
* output - None |
| 1962 |
– |
* side effects - Read configuration file. |
| 1963 |
– |
*/ |
| 1964 |
– |
static void |
| 1965 |
– |
read_conf(FBFILE *file) |
| 1966 |
– |
{ |
| 1967 |
– |
scount = lineno = 0; |
| 1968 |
– |
|
| 1969 |
– |
set_default_conf(); /* Set default values prior to conf parsing */ |
| 1970 |
– |
ypass = 1; |
| 1971 |
– |
yyparse(); /* pick up the classes first */ |
| 1972 |
– |
|
| 1973 |
– |
fbrewind(file); |
| 1974 |
– |
|
| 1975 |
– |
ypass = 2; |
| 1976 |
– |
yyparse(); /* Load the values from the conf */ |
| 1977 |
– |
validate_conf(); /* Check to make sure some values are still okay. */ |
| 1978 |
– |
/* Some global values are also loaded here. */ |
| 1979 |
– |
check_class(); /* Make sure classes are valid */ |
| 1980 |
– |
} |
| 1981 |
– |
|
| 1907 |
|
static void |
| 1908 |
|
validate_conf(void) |
| 1909 |
|
{ |
| 1913 |
|
if (ConfigFileEntry.ts_max_delta < TS_MAX_DELTA_MIN) |
| 1914 |
|
ConfigFileEntry.ts_max_delta = TS_MAX_DELTA_DEFAULT; |
| 1915 |
|
|
| 1991 |
– |
if (ConfigFileEntry.servlink_path == NULL) |
| 1992 |
– |
DupString(ConfigFileEntry.servlink_path, SLPATH); |
| 1993 |
– |
|
| 1916 |
|
if (ServerInfo.network_name == NULL) |
| 1917 |
|
DupString(ServerInfo.network_name,NETWORK_NAME_DEFAULT); |
| 1918 |
|
|
| 1919 |
|
if (ServerInfo.network_desc == NULL) |
| 1920 |
|
DupString(ServerInfo.network_desc,NETWORK_DESC_DEFAULT); |
| 1921 |
|
|
| 1922 |
+ |
if (ConfigFileEntry.service_name == NULL) |
| 1923 |
+ |
DupString(ConfigFileEntry.service_name, SERVICE_NAME_DEFAULT); |
| 1924 |
+ |
|
| 1925 |
|
if ((ConfigFileEntry.client_flood < CLIENT_FLOOD_MIN) || |
| 1926 |
|
(ConfigFileEntry.client_flood > CLIENT_FLOOD_MAX)) |
| 1927 |
|
ConfigFileEntry.client_flood = CLIENT_FLOOD_MAX; |
| 1928 |
+ |
|
| 1929 |
+ |
ConfigFileEntry.max_watch = IRCD_MAX(ConfigFileEntry.max_watch, WATCHSIZE_MIN); |
| 1930 |
+ |
} |
| 1931 |
+ |
|
| 1932 |
+ |
/* read_conf() |
| 1933 |
+ |
* |
| 1934 |
+ |
* inputs - file descriptor pointing to config file to use |
| 1935 |
+ |
* output - None |
| 1936 |
+ |
* side effects - Read configuration file. |
| 1937 |
+ |
*/ |
| 1938 |
+ |
static void |
| 1939 |
+ |
read_conf(FILE *file) |
| 1940 |
+ |
{ |
| 1941 |
+ |
lineno = 0; |
| 1942 |
+ |
|
| 1943 |
+ |
set_default_conf(); /* Set default values prior to conf parsing */ |
| 1944 |
+ |
conf_parser_ctx.pass = 1; |
| 1945 |
+ |
yyparse(); /* pick up the classes first */ |
| 1946 |
+ |
|
| 1947 |
+ |
rewind(file); |
| 1948 |
+ |
|
| 1949 |
+ |
conf_parser_ctx.pass = 2; |
| 1950 |
+ |
yyparse(); /* Load the values from the conf */ |
| 1951 |
+ |
validate_conf(); /* Check to make sure some values are still okay. */ |
| 1952 |
+ |
/* Some global values are also loaded here. */ |
| 1953 |
+ |
check_class(); /* Make sure classes are valid */ |
| 1954 |
|
} |
| 1955 |
|
|
| 1956 |
|
/* lookup_confhost() |
| 1969 |
|
if (EmptyString(aconf->host) || |
| 1970 |
|
EmptyString(aconf->user)) |
| 1971 |
|
{ |
| 1972 |
< |
ilog(L_ERROR, "Host/server name error: (%s) (%s)", |
| 1972 |
> |
ilog(LOG_TYPE_IRCD, "Host/server name error: (%s) (%s)", |
| 1973 |
|
aconf->host, conf->name); |
| 1974 |
|
return; |
| 1975 |
|
} |
| 1989 |
|
/* Get us ready for a bind() and don't bother doing dns lookup */ |
| 1990 |
|
hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; |
| 1991 |
|
|
| 1992 |
< |
if (irc_getaddrinfo(aconf->host, NULL, &hints, &res)) |
| 1992 |
> |
if (getaddrinfo(aconf->host, NULL, &hints, &res)) |
| 1993 |
|
{ |
| 1994 |
|
conf_dns_lookup(aconf); |
| 1995 |
|
return; |
| 1997 |
|
|
| 1998 |
|
assert(res != NULL); |
| 1999 |
|
|
| 2000 |
< |
memcpy(&aconf->ipnum, res->ai_addr, res->ai_addrlen); |
| 2001 |
< |
aconf->ipnum.ss_len = res->ai_addrlen; |
| 2002 |
< |
aconf->ipnum.ss.ss_family = res->ai_family; |
| 2003 |
< |
irc_freeaddrinfo(res); |
| 2000 |
> |
memcpy(&aconf->addr, res->ai_addr, res->ai_addrlen); |
| 2001 |
> |
aconf->addr.ss_len = res->ai_addrlen; |
| 2002 |
> |
aconf->addr.ss.ss_family = res->ai_family; |
| 2003 |
> |
freeaddrinfo(res); |
| 2004 |
|
} |
| 2005 |
|
|
| 2006 |
|
/* conf_connect_allowed() |
| 2039 |
|
static struct AccessItem * |
| 2040 |
|
find_regexp_kline(const char *uhi[]) |
| 2041 |
|
{ |
| 2042 |
+ |
#ifdef HAVE_LIBPCRE |
| 2043 |
|
const dlink_node *ptr = NULL; |
| 2044 |
|
|
| 2045 |
|
DLINK_FOREACH(ptr, rkconf_items.head) |
| 2054 |
|
!ircd_pcre_exec(aptr->regexhost, uhi[2]))) |
| 2055 |
|
return aptr; |
| 2056 |
|
} |
| 2057 |
< |
|
| 2057 |
> |
#endif |
| 2058 |
|
return NULL; |
| 2059 |
|
} |
| 2060 |
|
|
| 2077 |
|
|
| 2078 |
|
assert(client_p != NULL); |
| 2079 |
|
|
| 2080 |
< |
aconf = find_kline_conf(client_p->host, client_p->username, |
| 2081 |
< |
&client_p->localClient->ip, |
| 2082 |
< |
client_p->localClient->aftype); |
| 2080 |
> |
aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
| 2081 |
> |
CONF_KLINE, client_p->localClient->aftype, |
| 2082 |
> |
client_p->username, NULL, 1); |
| 2083 |
|
if (aconf == NULL) |
| 2084 |
|
aconf = find_regexp_kline(uhi); |
| 2085 |
|
|
| 2086 |
< |
if (aconf && (aconf->status & CONF_KLINE)) |
| 2135 |
< |
return aconf; |
| 2136 |
< |
|
| 2137 |
< |
return NULL; |
| 2086 |
> |
return aconf; |
| 2087 |
|
} |
| 2088 |
|
|
| 2089 |
|
struct AccessItem * |
| 2093 |
|
|
| 2094 |
|
assert(client_p != NULL); |
| 2095 |
|
|
| 2096 |
< |
aconf = find_gline_conf(client_p->host, client_p->username, |
| 2097 |
< |
&client_p->localClient->ip, |
| 2098 |
< |
client_p->localClient->aftype); |
| 2099 |
< |
|
| 2151 |
< |
if (aconf && (aconf->status & CONF_GLINE)) |
| 2152 |
< |
return aconf; |
| 2153 |
< |
|
| 2154 |
< |
return NULL; |
| 2096 |
> |
aconf = find_conf_by_address(client_p->host, &client_p->localClient->ip, |
| 2097 |
> |
CONF_GLINE, client_p->localClient->aftype, |
| 2098 |
> |
client_p->username, NULL, 1); |
| 2099 |
> |
return aconf; |
| 2100 |
|
} |
| 2101 |
|
|
| 2102 |
|
/* add_temp_line() |
| 2109 |
|
void |
| 2110 |
|
add_temp_line(struct ConfItem *conf) |
| 2111 |
|
{ |
| 2112 |
< |
struct AccessItem *aconf; |
| 2168 |
< |
|
| 2169 |
< |
if (conf->type == DLINE_TYPE) |
| 2170 |
< |
{ |
| 2171 |
< |
aconf = map_to_conf(conf); |
| 2172 |
< |
SetConfTemporary(aconf); |
| 2173 |
< |
dlinkAdd(conf, &conf->node, &temporary_dlines); |
| 2174 |
< |
MyFree(aconf->user); |
| 2175 |
< |
aconf->user = NULL; |
| 2176 |
< |
add_conf_by_address(CONF_DLINE, aconf); |
| 2177 |
< |
} |
| 2178 |
< |
else if (conf->type == KLINE_TYPE) |
| 2179 |
< |
{ |
| 2180 |
< |
aconf = map_to_conf(conf); |
| 2181 |
< |
SetConfTemporary(aconf); |
| 2182 |
< |
dlinkAdd(conf, &conf->node, &temporary_klines); |
| 2183 |
< |
add_conf_by_address(CONF_KILL, aconf); |
| 2184 |
< |
} |
| 2185 |
< |
else if (conf->type == GLINE_TYPE) |
| 2186 |
< |
{ |
| 2187 |
< |
aconf = map_to_conf(conf); |
| 2188 |
< |
SetConfTemporary(aconf); |
| 2189 |
< |
dlinkAdd(conf, &conf->node, &temporary_glines); |
| 2190 |
< |
add_conf_by_address(CONF_GLINE, aconf); |
| 2191 |
< |
} |
| 2192 |
< |
else if (conf->type == XLINE_TYPE) |
| 2112 |
> |
if (conf->type == XLINE_TYPE) |
| 2113 |
|
{ |
| 2114 |
|
conf->flags |= CONF_FLAGS_TEMPORARY; |
| 2115 |
|
dlinkAdd(conf, make_dlink_node(), &temporary_xlines); |
| 2116 |
|
} |
| 2197 |
– |
else if (conf->type == RXLINE_TYPE) |
| 2198 |
– |
{ |
| 2199 |
– |
conf->flags |= CONF_FLAGS_TEMPORARY; |
| 2200 |
– |
dlinkAdd(conf, make_dlink_node(), &temporary_rxlines); |
| 2201 |
– |
} |
| 2202 |
– |
else if (conf->type == RKLINE_TYPE) |
| 2203 |
– |
{ |
| 2204 |
– |
conf->flags |= CONF_FLAGS_TEMPORARY; |
| 2205 |
– |
dlinkAdd(conf, make_dlink_node(), &temporary_rklines); |
| 2206 |
– |
} |
| 2117 |
|
else if ((conf->type == NRESV_TYPE) || (conf->type == CRESV_TYPE)) |
| 2118 |
|
{ |
| 2119 |
|
conf->flags |= CONF_FLAGS_TEMPORARY; |
| 2131 |
|
void |
| 2132 |
|
cleanup_tklines(void *notused) |
| 2133 |
|
{ |
| 2134 |
< |
expire_tklines(&temporary_glines); |
| 2225 |
< |
expire_tklines(&temporary_klines); |
| 2226 |
< |
expire_tklines(&temporary_dlines); |
| 2134 |
> |
hostmask_expire_temporary(); |
| 2135 |
|
expire_tklines(&temporary_xlines); |
| 2228 |
– |
expire_tklines(&temporary_rxlines); |
| 2229 |
– |
expire_tklines(&temporary_rklines); |
| 2136 |
|
expire_tklines(&temporary_resv); |
| 2137 |
|
} |
| 2138 |
|
|
| 2150 |
|
struct ConfItem *conf; |
| 2151 |
|
struct MatchItem *xconf; |
| 2152 |
|
struct MatchItem *nconf; |
| 2247 |
– |
struct AccessItem *aconf; |
| 2153 |
|
struct ResvChannel *cconf; |
| 2154 |
|
|
| 2155 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, tklist->head) |
| 2156 |
|
{ |
| 2157 |
|
conf = ptr->data; |
| 2253 |
– |
if (conf->type == GLINE_TYPE || |
| 2254 |
– |
conf->type == KLINE_TYPE || |
| 2255 |
– |
conf->type == DLINE_TYPE) |
| 2256 |
– |
{ |
| 2257 |
– |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 2258 |
– |
if (aconf->hold <= CurrentTime) |
| 2259 |
– |
{ |
| 2260 |
– |
/* XXX - Do we want GLINE expiry notices?? */ |
| 2261 |
– |
/* Alert opers that a TKline expired - Hwy */ |
| 2262 |
– |
if (ConfigFileEntry.tkline_expire_notices) |
| 2263 |
– |
{ |
| 2264 |
– |
if (aconf->status & CONF_KILL) |
| 2265 |
– |
{ |
| 2266 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 2267 |
– |
"Temporary K-line for [%s@%s] expired", |
| 2268 |
– |
(aconf->user) ? aconf->user : "*", |
| 2269 |
– |
(aconf->host) ? aconf->host : "*"); |
| 2270 |
– |
} |
| 2271 |
– |
else if (conf->type == DLINE_TYPE) |
| 2272 |
– |
{ |
| 2273 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 2274 |
– |
"Temporary D-line for [%s] expired", |
| 2275 |
– |
(aconf->host) ? aconf->host : "*"); |
| 2276 |
– |
} |
| 2277 |
– |
} |
| 2158 |
|
|
| 2159 |
< |
dlinkDelete(ptr, tklist); |
| 2280 |
< |
delete_one_address_conf(aconf->host, aconf); |
| 2281 |
< |
} |
| 2282 |
< |
} |
| 2283 |
< |
else if (conf->type == XLINE_TYPE || |
| 2284 |
< |
conf->type == RXLINE_TYPE) |
| 2159 |
> |
if (conf->type == XLINE_TYPE) |
| 2160 |
|
{ |
| 2161 |
|
xconf = (struct MatchItem *)map_to_conf(conf); |
| 2162 |
|
if (xconf->hold <= CurrentTime) |
| 2163 |
|
{ |
| 2164 |
|
if (ConfigFileEntry.tkline_expire_notices) |
| 2165 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 2166 |
< |
"Temporary X-line for [%s] %sexpired", conf->name, |
| 2292 |
< |
conf->type == RXLINE_TYPE ? "(REGEX) " : ""); |
| 2166 |
> |
"Temporary X-line for [%s] sexpired", conf->name); |
| 2167 |
|
dlinkDelete(ptr, tklist); |
| 2168 |
|
free_dlink_node(ptr); |
| 2169 |
|
delete_conf_item(conf); |
| 2170 |
|
} |
| 2171 |
|
} |
| 2298 |
– |
else if (conf->type == RKLINE_TYPE) |
| 2299 |
– |
{ |
| 2300 |
– |
aconf = map_to_conf(conf); |
| 2301 |
– |
if (aconf->hold <= CurrentTime) |
| 2302 |
– |
{ |
| 2303 |
– |
if (ConfigFileEntry.tkline_expire_notices) |
| 2304 |
– |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 2305 |
– |
"Temporary K-line for [%s@%s] (REGEX) expired", |
| 2306 |
– |
(aconf->user) ? aconf->user : "*", |
| 2307 |
– |
(aconf->host) ? aconf->host : "*"); |
| 2308 |
– |
dlinkDelete(ptr, tklist); |
| 2309 |
– |
free_dlink_node(ptr); |
| 2310 |
– |
delete_conf_item(conf); |
| 2311 |
– |
} |
| 2312 |
– |
} |
| 2172 |
|
else if (conf->type == NRESV_TYPE) |
| 2173 |
|
{ |
| 2174 |
|
nconf = (struct MatchItem *)map_to_conf(conf); |
| 2190 |
|
if (ConfigFileEntry.tkline_expire_notices) |
| 2191 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 2192 |
|
"Temporary RESV for [%s] expired", cconf->name); |
| 2193 |
< |
dlinkDelete(ptr, tklist); |
| 2335 |
< |
free_dlink_node(ptr); |
| 2336 |
< |
delete_conf_item(conf); |
| 2193 |
> |
delete_channel_resv(cconf); |
| 2194 |
|
} |
| 2195 |
|
} |
| 2196 |
|
} |
| 2205 |
|
static const struct oper_privs |
| 2206 |
|
{ |
| 2207 |
|
const unsigned int oprivs; |
| 2351 |
– |
const unsigned int hidden; |
| 2208 |
|
const unsigned char c; |
| 2209 |
|
} flag_list[] = { |
| 2210 |
< |
{ OPER_FLAG_ADMIN, OPER_FLAG_HIDDEN_ADMIN, 'A' }, |
| 2211 |
< |
{ OPER_FLAG_REMOTEBAN, 0, 'B' }, |
| 2212 |
< |
{ OPER_FLAG_DIE, 0, 'D' }, |
| 2213 |
< |
{ OPER_FLAG_GLINE, 0, 'G' }, |
| 2214 |
< |
{ OPER_FLAG_REHASH, 0, 'H' }, |
| 2215 |
< |
{ OPER_FLAG_K, 0, 'K' }, |
| 2216 |
< |
{ OPER_FLAG_OPERWALL, 0, 'L' }, |
| 2217 |
< |
{ OPER_FLAG_N, 0, 'N' }, |
| 2218 |
< |
{ OPER_FLAG_GLOBAL_KILL, 0, 'O' }, |
| 2219 |
< |
{ OPER_FLAG_REMOTE, 0, 'R' }, |
| 2220 |
< |
{ OPER_FLAG_OPER_SPY, 0, 'S' }, |
| 2221 |
< |
{ OPER_FLAG_UNKLINE, 0, 'U' }, |
| 2222 |
< |
{ OPER_FLAG_X, 0, 'X' }, |
| 2223 |
< |
{ 0, 0, '\0' } |
| 2210 |
> |
{ OPER_FLAG_ADMIN, 'A' }, |
| 2211 |
> |
{ OPER_FLAG_REMOTEBAN, 'B' }, |
| 2212 |
> |
{ OPER_FLAG_DIE, 'D' }, |
| 2213 |
> |
{ OPER_FLAG_GLINE, 'G' }, |
| 2214 |
> |
{ OPER_FLAG_REHASH, 'H' }, |
| 2215 |
> |
{ OPER_FLAG_K, 'K' }, |
| 2216 |
> |
{ OPER_FLAG_OPERWALL, 'L' }, |
| 2217 |
> |
{ OPER_FLAG_N, 'N' }, |
| 2218 |
> |
{ OPER_FLAG_GLOBAL_KILL, 'O' }, |
| 2219 |
> |
{ OPER_FLAG_REMOTE, 'R' }, |
| 2220 |
> |
{ OPER_FLAG_OPER_SPY, 'S' }, |
| 2221 |
> |
{ OPER_FLAG_UNKLINE, 'U' }, |
| 2222 |
> |
{ OPER_FLAG_X, 'X' }, |
| 2223 |
> |
{ 0, '\0' } |
| 2224 |
|
}; |
| 2225 |
|
|
| 2226 |
|
char * |
| 2232 |
|
|
| 2233 |
|
for (; flag_list[i].oprivs; ++i) |
| 2234 |
|
{ |
| 2235 |
< |
if ((port & flag_list[i].oprivs) && |
| 2380 |
< |
(port & flag_list[i].hidden) == 0) |
| 2235 |
> |
if (port & flag_list[i].oprivs) |
| 2236 |
|
*privs_ptr++ = flag_list[i].c; |
| 2237 |
|
else |
| 2238 |
|
*privs_ptr++ = ToLowerTab[flag_list[i].c]; |
| 2249 |
|
* "oper" is server name for remote opers |
| 2250 |
|
* Side effects: None. |
| 2251 |
|
*/ |
| 2252 |
< |
char * |
| 2252 |
> |
const char * |
| 2253 |
|
get_oper_name(const struct Client *client_p) |
| 2254 |
|
{ |
| 2255 |
< |
dlink_node *cnode; |
| 2401 |
< |
struct ConfItem *conf; |
| 2402 |
< |
struct AccessItem *aconf; |
| 2403 |
< |
|
| 2255 |
> |
dlink_node *cnode = NULL; |
| 2256 |
|
/* +5 for !,@,{,} and null */ |
| 2257 |
< |
static char buffer[NICKLEN+USERLEN+HOSTLEN+HOSTLEN+5]; |
| 2257 |
> |
static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5]; |
| 2258 |
|
|
| 2259 |
|
if (MyConnect(client_p)) |
| 2260 |
|
{ |
| 2261 |
< |
DLINK_FOREACH(cnode, client_p->localClient->confs.head) |
| 2261 |
> |
if ((cnode = client_p->localClient->confs.head)) |
| 2262 |
|
{ |
| 2263 |
< |
conf = cnode->data; |
| 2264 |
< |
aconf = map_to_conf(conf); |
| 2263 |
> |
struct ConfItem *conf = cnode->data; |
| 2264 |
> |
const struct AccessItem *aconf = map_to_conf(conf); |
| 2265 |
|
|
| 2266 |
|
if (IsConfOperator(aconf)) |
| 2267 |
|
{ |
| 2268 |
< |
ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name, |
| 2269 |
< |
client_p->username, client_p->host, |
| 2418 |
< |
conf->name); |
| 2268 |
> |
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
| 2269 |
> |
client_p->username, client_p->host, conf->name); |
| 2270 |
|
return buffer; |
| 2271 |
|
} |
| 2272 |
|
} |
| 2277 |
|
assert(0); /* Oper without oper conf! */ |
| 2278 |
|
} |
| 2279 |
|
|
| 2280 |
< |
ircsprintf(buffer, "%s!%s@%s{%s}", client_p->name, |
| 2281 |
< |
client_p->username, client_p->host, client_p->servptr->name); |
| 2280 |
> |
snprintf(buffer, sizeof(buffer), "%s!%s@%s{%s}", client_p->name, |
| 2281 |
> |
client_p->username, client_p->host, client_p->servptr->name); |
| 2282 |
|
return buffer; |
| 2283 |
|
} |
| 2284 |
|
|
| 2295 |
|
char chanmodes[32]; |
| 2296 |
|
char chanlimit[32]; |
| 2297 |
|
|
| 2298 |
+ |
conf_parser_ctx.boot = cold; |
| 2299 |
|
filename = get_conf_name(CONF_TYPE); |
| 2300 |
|
|
| 2301 |
|
/* We need to know the initial filename for the yyerror() to report |
| 2306 |
|
*/ |
| 2307 |
|
strlcpy(conffilebuf, filename, sizeof(conffilebuf)); |
| 2308 |
|
|
| 2309 |
< |
if ((conf_fbfile_in = fbopen(filename, "r")) == NULL) |
| 2309 |
> |
if ((conf_parser_ctx.conf_file = fopen(filename, "r")) == NULL) |
| 2310 |
|
{ |
| 2311 |
|
if (cold) |
| 2312 |
|
{ |
| 2313 |
< |
ilog(L_CRIT, "Unable to read configuration file '%s': %s", |
| 2313 |
> |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
| 2314 |
|
filename, strerror(errno)); |
| 2315 |
|
exit(-1); |
| 2316 |
|
} |
| 2326 |
|
if (!cold) |
| 2327 |
|
clear_out_old_conf(); |
| 2328 |
|
|
| 2329 |
< |
read_conf(conf_fbfile_in); |
| 2330 |
< |
fbclose(conf_fbfile_in); |
| 2329 |
> |
read_conf(conf_parser_ctx.conf_file); |
| 2330 |
> |
fclose(conf_parser_ctx.conf_file); |
| 2331 |
|
|
| 2332 |
|
add_isupport("NETWORK", ServerInfo.network_name, -1); |
| 2333 |
< |
ircsprintf(chanmodes, "b%s%s:%d", ConfigChannel.use_except ? "e" : "", |
| 2334 |
< |
ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans); |
| 2333 |
> |
snprintf(chanmodes, sizeof(chanmodes), "b%s%s:%d", |
| 2334 |
> |
ConfigChannel.use_except ? "e" : "", |
| 2335 |
> |
ConfigChannel.use_invex ? "I" : "", ConfigChannel.max_bans); |
| 2336 |
|
add_isupport("MAXLIST", chanmodes, -1); |
| 2337 |
|
add_isupport("MAXTARGETS", NULL, ConfigFileEntry.max_targets); |
| 2338 |
+ |
|
| 2339 |
|
if (ConfigChannel.disable_local_channels) |
| 2340 |
|
add_isupport("CHANTYPES", "#", -1); |
| 2341 |
|
else |
| 2342 |
|
add_isupport("CHANTYPES", "#&", -1); |
| 2343 |
< |
ircsprintf(chanlimit, "%s:%d", ConfigChannel.disable_local_channels ? "#" : "#&", |
| 2344 |
< |
ConfigChannel.max_chans_per_user); |
| 2343 |
> |
|
| 2344 |
> |
snprintf(chanlimit, sizeof(chanlimit), "%s:%d", |
| 2345 |
> |
ConfigChannel.disable_local_channels ? "#" : "#&", |
| 2346 |
> |
ConfigChannel.max_chans_per_user); |
| 2347 |
|
add_isupport("CHANLIMIT", chanlimit, -1); |
| 2348 |
< |
ircsprintf(chanmodes, "%s%s%s", ConfigChannel.use_except ? "e" : "", |
| 2349 |
< |
ConfigChannel.use_invex ? "I" : "", "b,k,l,imnpst"); |
| 2348 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s%s%s", |
| 2349 |
> |
ConfigChannel.use_except ? "e" : "", |
| 2350 |
> |
ConfigChannel.use_invex ? "I" : "", "b,k,l,imnprstORS"); |
| 2351 |
|
add_isupport("CHANNELLEN", NULL, LOCAL_CHANNELLEN); |
| 2352 |
+ |
|
| 2353 |
|
if (ConfigChannel.use_except) |
| 2354 |
|
add_isupport("EXCEPTS", "e", -1); |
| 2355 |
|
if (ConfigChannel.use_invex) |
| 2362 |
|
*/ |
| 2363 |
|
rebuild_isupport_message_line(); |
| 2364 |
|
|
| 2365 |
< |
parse_conf_file(KLINE_TYPE, cold); |
| 2365 |
> |
#ifdef HAVE_LIBPCRE |
| 2366 |
|
parse_conf_file(RKLINE_TYPE, cold); |
| 2367 |
+ |
parse_conf_file(RXLINE_TYPE, cold); |
| 2368 |
+ |
#endif |
| 2369 |
+ |
parse_conf_file(KLINE_TYPE, cold); |
| 2370 |
|
parse_conf_file(DLINE_TYPE, cold); |
| 2371 |
|
parse_conf_file(XLINE_TYPE, cold); |
| 2511 |
– |
parse_conf_file(RXLINE_TYPE, cold); |
| 2372 |
|
parse_conf_file(NRESV_TYPE, cold); |
| 2373 |
|
parse_conf_file(CRESV_TYPE, cold); |
| 2374 |
|
} |
| 2382 |
|
static void |
| 2383 |
|
parse_conf_file(int type, int cold) |
| 2384 |
|
{ |
| 2385 |
< |
FBFILE *file = NULL; |
| 2385 |
> |
FILE *file = NULL; |
| 2386 |
|
const char *filename = get_conf_name(type); |
| 2387 |
|
|
| 2388 |
< |
if ((file = fbopen(filename, "r")) == NULL) |
| 2388 |
> |
if ((file = fopen(filename, "r")) == NULL) |
| 2389 |
|
{ |
| 2390 |
|
if (cold) |
| 2391 |
< |
ilog(L_ERROR, "Unable to read configuration file '%s': %s", |
| 2391 |
> |
ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s", |
| 2392 |
|
filename, strerror(errno)); |
| 2393 |
|
else |
| 2394 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 2398 |
|
else |
| 2399 |
|
{ |
| 2400 |
|
parse_csv_file(file, type); |
| 2401 |
< |
fbclose(file); |
| 2401 |
> |
fclose(file); |
| 2402 |
|
} |
| 2403 |
|
} |
| 2404 |
|
|
| 2417 |
|
struct ClassItem *cltmp; |
| 2418 |
|
struct MatchItem *match_item; |
| 2419 |
|
dlink_list *free_items [] = { |
| 2420 |
< |
&server_items, &oconf_items, &hub_items, &leaf_items, |
| 2420 |
> |
&server_items, &oconf_items, |
| 2421 |
|
&uconf_items, &xconf_items, &rxconf_items, &rkconf_items, |
| 2422 |
< |
&nresv_items, &cluster_items, &gdeny_items, NULL |
| 2422 |
> |
&nresv_items, &cluster_items, &gdeny_items, &service_items, NULL |
| 2423 |
|
}; |
| 2424 |
|
|
| 2425 |
|
dlink_list ** iterator = free_items; /* C is dumb */ |
| 2436 |
|
/* XXX This is less than pretty */ |
| 2437 |
|
if (conf->type == SERVER_TYPE) |
| 2438 |
|
{ |
| 2439 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 2439 |
> |
aconf = map_to_conf(conf); |
| 2440 |
> |
|
| 2441 |
|
if (aconf->clients != 0) |
| 2442 |
|
{ |
| 2443 |
|
SetConfIllegal(aconf); |
| 2450 |
|
} |
| 2451 |
|
else if (conf->type == OPER_TYPE) |
| 2452 |
|
{ |
| 2453 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 2453 |
> |
aconf = map_to_conf(conf); |
| 2454 |
> |
|
| 2455 |
|
if (aconf->clients != 0) |
| 2456 |
|
{ |
| 2457 |
|
SetConfIllegal(aconf); |
| 2462 |
|
delete_conf_item(conf); |
| 2463 |
|
} |
| 2464 |
|
} |
| 2603 |
– |
else if (conf->type == CLIENT_TYPE) |
| 2604 |
– |
{ |
| 2605 |
– |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 2606 |
– |
if (aconf->clients != 0) |
| 2607 |
– |
{ |
| 2608 |
– |
SetConfIllegal(aconf); |
| 2609 |
– |
} |
| 2610 |
– |
else |
| 2611 |
– |
{ |
| 2612 |
– |
delete_conf_item(conf); |
| 2613 |
– |
} |
| 2614 |
– |
} |
| 2465 |
|
else if (conf->type == XLINE_TYPE || |
| 2466 |
|
conf->type == RXLINE_TYPE || |
| 2467 |
|
conf->type == RKLINE_TYPE) |
| 2475 |
|
} |
| 2476 |
|
else |
| 2477 |
|
{ |
| 2628 |
– |
if ((conf->type == LEAF_TYPE) || (conf->type == HUB_TYPE)) |
| 2629 |
– |
{ |
| 2630 |
– |
match_item = (struct MatchItem *)map_to_conf(conf); |
| 2631 |
– |
if ((match_item->ref_count <= 0)) |
| 2632 |
– |
delete_conf_item(conf); |
| 2633 |
– |
else |
| 2634 |
– |
{ |
| 2635 |
– |
match_item->illegal = 1; |
| 2636 |
– |
dlinkDelete(&conf->node, *iterator); |
| 2637 |
– |
} |
| 2638 |
– |
} |
| 2639 |
– |
else |
| 2478 |
|
delete_conf_item(conf); |
| 2479 |
|
} |
| 2480 |
|
} |
| 2481 |
|
} |
| 2482 |
|
|
| 2483 |
< |
/* don't delete the class table, rather mark all entries |
| 2483 |
> |
/* |
| 2484 |
> |
* don't delete the class table, rather mark all entries |
| 2485 |
|
* for deletion. The table is cleaned up by check_class. - avalon |
| 2486 |
|
*/ |
| 2487 |
|
DLINK_FOREACH(ptr, class_items.head) |
| 2488 |
|
{ |
| 2489 |
< |
conf = ptr->data; |
| 2490 |
< |
cltmp = (struct ClassItem *)map_to_conf(conf); |
| 2489 |
> |
cltmp = map_to_conf(ptr->data); |
| 2490 |
> |
|
| 2491 |
|
if (ptr != class_items.tail) /* never mark the "default" class */ |
| 2492 |
< |
MaxTotal(cltmp) = -1; |
| 2492 |
> |
cltmp->active = 0; |
| 2493 |
|
} |
| 2494 |
|
|
| 2495 |
|
clear_out_address_conf(); |
| 2496 |
|
|
| 2497 |
|
/* clean out module paths */ |
| 2659 |
– |
#ifndef STATIC_MODULES |
| 2498 |
|
mod_clear_paths(); |
| 2661 |
– |
#endif |
| 2499 |
|
|
| 2500 |
|
/* clean out ServerInfo */ |
| 2501 |
|
MyFree(ServerInfo.description); |
| 2515 |
|
|
| 2516 |
|
MyFree(ServerInfo.rsa_private_key_file); |
| 2517 |
|
ServerInfo.rsa_private_key_file = NULL; |
| 2518 |
+ |
|
| 2519 |
+ |
if (ServerInfo.server_ctx) |
| 2520 |
+ |
SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv2| |
| 2521 |
+ |
SSL_OP_NO_SSLv3| |
| 2522 |
+ |
SSL_OP_NO_TLSv1); |
| 2523 |
+ |
if (ServerInfo.client_ctx) |
| 2524 |
+ |
SSL_CTX_set_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv2| |
| 2525 |
+ |
SSL_OP_NO_SSLv3| |
| 2526 |
+ |
SSL_OP_NO_TLSv1); |
| 2527 |
|
#endif |
| 2528 |
|
|
| 2529 |
|
/* clean out old resvs from the conf */ |
| 2546 |
|
*/ |
| 2547 |
|
|
| 2548 |
|
/* clean out general */ |
| 2549 |
< |
MyFree(ConfigFileEntry.servlink_path); |
| 2550 |
< |
ConfigFileEntry.servlink_path = NULL; |
| 2551 |
< |
#ifdef HAVE_LIBCRYPTO |
| 2706 |
< |
ConfigFileEntry.default_cipher_preference = NULL; |
| 2707 |
< |
#endif /* HAVE_LIBCRYPTO */ |
| 2549 |
> |
MyFree(ConfigFileEntry.service_name); |
| 2550 |
> |
ConfigFileEntry.service_name = NULL; |
| 2551 |
> |
|
| 2552 |
|
delete_isupport("INVEX"); |
| 2553 |
|
delete_isupport("EXCEPTS"); |
| 2554 |
|
} |
| 2659 |
|
if (aconf->class_ptr != NULL) |
| 2660 |
|
{ |
| 2661 |
|
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
| 2662 |
< |
*pingwarn = PingWarning(aclass); |
| 2663 |
< |
return PingFreq(aclass); |
| 2662 |
> |
*pingwarn = aclass->ping_warning; |
| 2663 |
> |
return aclass->ping_freq; |
| 2664 |
|
} |
| 2665 |
|
} |
| 2666 |
|
|
| 2676 |
|
const char * |
| 2677 |
|
get_client_class(struct Client *target_p) |
| 2678 |
|
{ |
| 2679 |
< |
dlink_node *ptr; |
| 2680 |
< |
struct ConfItem *conf; |
| 2837 |
< |
struct AccessItem *aconf; |
| 2679 |
> |
dlink_node *cnode = NULL; |
| 2680 |
> |
struct AccessItem *aconf = NULL; |
| 2681 |
|
|
| 2682 |
< |
if (target_p != NULL && !IsMe(target_p) && |
| 2683 |
< |
target_p->localClient->confs.head != NULL) |
| 2682 |
> |
assert(!IsMe(target_p)); |
| 2683 |
> |
|
| 2684 |
> |
if ((cnode = target_p->localClient->confs.head)) |
| 2685 |
|
{ |
| 2686 |
< |
DLINK_FOREACH(ptr, target_p->localClient->confs.head) |
| 2843 |
< |
{ |
| 2844 |
< |
conf = ptr->data; |
| 2686 |
> |
struct ConfItem *conf = cnode->data; |
| 2687 |
|
|
| 2688 |
< |
if (conf->type == CLIENT_TYPE || conf->type == SERVER_TYPE || |
| 2689 |
< |
conf->type == OPER_TYPE) |
| 2690 |
< |
{ |
| 2691 |
< |
aconf = (struct AccessItem *) map_to_conf(conf); |
| 2692 |
< |
if (aconf->class_ptr != NULL) |
| 2693 |
< |
return aconf->class_ptr->name; |
| 2852 |
< |
} |
| 2853 |
< |
} |
| 2688 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
| 2689 |
> |
(conf->type == OPER_TYPE)); |
| 2690 |
> |
|
| 2691 |
> |
aconf = map_to_conf(conf); |
| 2692 |
> |
if (aconf->class_ptr != NULL) |
| 2693 |
> |
return aconf->class_ptr->name; |
| 2694 |
|
} |
| 2695 |
|
|
| 2696 |
|
return "default"; |
| 2706 |
|
int |
| 2707 |
|
get_client_ping(struct Client *target_p, int *pingwarn) |
| 2708 |
|
{ |
| 2709 |
< |
int ping; |
| 2710 |
< |
struct ConfItem *conf; |
| 2871 |
< |
dlink_node *nlink; |
| 2709 |
> |
int ping = 0; |
| 2710 |
> |
dlink_node *cnode = NULL; |
| 2711 |
|
|
| 2712 |
< |
if (target_p->localClient->confs.head != NULL) |
| 2713 |
< |
DLINK_FOREACH(nlink, target_p->localClient->confs.head) |
| 2714 |
< |
{ |
| 2876 |
< |
conf = nlink->data; |
| 2712 |
> |
if ((cnode = target_p->localClient->confs.head)) |
| 2713 |
> |
{ |
| 2714 |
> |
struct ConfItem *conf = cnode->data; |
| 2715 |
|
|
| 2716 |
< |
if ((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
| 2717 |
< |
(conf->type == OPER_TYPE)) |
| 2718 |
< |
{ |
| 2719 |
< |
ping = get_conf_ping(conf, pingwarn); |
| 2720 |
< |
if (ping > 0) |
| 2721 |
< |
return ping; |
| 2722 |
< |
} |
| 2885 |
< |
} |
| 2716 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
| 2717 |
> |
(conf->type == OPER_TYPE)); |
| 2718 |
> |
|
| 2719 |
> |
ping = get_conf_ping(conf, pingwarn); |
| 2720 |
> |
if (ping > 0) |
| 2721 |
> |
return ping; |
| 2722 |
> |
} |
| 2723 |
|
|
| 2724 |
|
*pingwarn = 0; |
| 2725 |
|
return DEFAULT_PINGFREQUENCY; |
| 2736 |
|
{ |
| 2737 |
|
struct ConfItem *conf; |
| 2738 |
|
|
| 2739 |
< |
if ((conf = find_exact_name_conf(CLASS_TYPE, classname, NULL, NULL)) != NULL) |
| 2740 |
< |
return(conf); |
| 2739 |
> |
if ((conf = find_exact_name_conf(CLASS_TYPE, NULL, classname, NULL, NULL)) != NULL) |
| 2740 |
> |
return conf; |
| 2741 |
|
|
| 2742 |
|
return class_default; |
| 2743 |
|
} |
| 2751 |
|
void |
| 2752 |
|
check_class(void) |
| 2753 |
|
{ |
| 2754 |
< |
dlink_node *ptr; |
| 2918 |
< |
dlink_node *next_ptr; |
| 2919 |
< |
struct ConfItem *conf; |
| 2920 |
< |
struct ClassItem *aclass; |
| 2754 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
| 2755 |
|
|
| 2756 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, class_items.head) |
| 2757 |
|
{ |
| 2758 |
< |
conf = ptr->data; |
| 2925 |
< |
aclass = (struct ClassItem *)map_to_conf(conf); |
| 2758 |
> |
struct ClassItem *aclass = map_to_conf(ptr->data); |
| 2759 |
|
|
| 2760 |
< |
if (MaxTotal(aclass) < 0) |
| 2760 |
> |
if (!aclass->active && !aclass->curr_user_count) |
| 2761 |
|
{ |
| 2762 |
|
destroy_cidr_class(aclass); |
| 2763 |
< |
if (CurrUserCount(aclass) > 0) |
| 2931 |
< |
dlinkDelete(&conf->node, &class_items); |
| 2932 |
< |
else |
| 2933 |
< |
delete_conf_item(conf); |
| 2763 |
> |
delete_conf_item(ptr->data); |
| 2764 |
|
} |
| 2765 |
|
} |
| 2766 |
|
} |
| 2777 |
|
struct ClassItem *aclass; |
| 2778 |
|
|
| 2779 |
|
class_default = make_conf_item(CLASS_TYPE); |
| 2780 |
< |
aclass = (struct ClassItem *)map_to_conf(class_default); |
| 2780 |
> |
|
| 2781 |
> |
aclass = map_to_conf(class_default); |
| 2782 |
> |
aclass->active = 1; |
| 2783 |
|
DupString(class_default->name, "default"); |
| 2784 |
< |
ConFreq(aclass) = DEFAULT_CONNECTFREQUENCY; |
| 2785 |
< |
PingFreq(aclass) = DEFAULT_PINGFREQUENCY; |
| 2786 |
< |
MaxTotal(aclass) = MAXIMUM_LINKS_DEFAULT; |
| 2787 |
< |
MaxSendq(aclass) = DEFAULT_SENDQ; |
| 2784 |
> |
aclass->con_freq = DEFAULT_CONNECTFREQUENCY; |
| 2785 |
> |
aclass->ping_freq = DEFAULT_PINGFREQUENCY; |
| 2786 |
> |
aclass->max_total = MAXIMUM_LINKS_DEFAULT; |
| 2787 |
> |
aclass->max_sendq = DEFAULT_SENDQ; |
| 2788 |
|
|
| 2789 |
|
client_check_cb = register_callback("check_client", check_client); |
| 2790 |
|
} |
| 2795 |
|
* output - sendq for this client as found from its class |
| 2796 |
|
* side effects - NONE |
| 2797 |
|
*/ |
| 2798 |
< |
unsigned long |
| 2798 |
> |
unsigned int |
| 2799 |
|
get_sendq(struct Client *client_p) |
| 2800 |
|
{ |
| 2801 |
< |
unsigned long sendq = DEFAULT_SENDQ; |
| 2802 |
< |
dlink_node *ptr; |
| 2971 |
< |
struct ConfItem *conf; |
| 2801 |
> |
unsigned int sendq = DEFAULT_SENDQ; |
| 2802 |
> |
dlink_node *cnode; |
| 2803 |
|
struct ConfItem *class_conf; |
| 2804 |
|
struct ClassItem *aclass; |
| 2805 |
|
struct AccessItem *aconf; |
| 2806 |
|
|
| 2807 |
< |
if (client_p && !IsMe(client_p) && (client_p->localClient->confs.head)) |
| 2807 |
> |
assert(!IsMe(client_p)); |
| 2808 |
> |
|
| 2809 |
> |
if ((cnode = client_p->localClient->confs.head)) |
| 2810 |
|
{ |
| 2811 |
< |
DLINK_FOREACH(ptr, client_p->localClient->confs.head) |
| 2812 |
< |
{ |
| 2813 |
< |
conf = ptr->data; |
| 2814 |
< |
if ((conf->type == SERVER_TYPE) || (conf->type == OPER_TYPE) |
| 2815 |
< |
|| (conf->type == CLIENT_TYPE)) |
| 2816 |
< |
{ |
| 2817 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 2818 |
< |
if ((class_conf = aconf->class_ptr) == NULL) |
| 2819 |
< |
continue; |
| 2820 |
< |
aclass = (struct ClassItem *)map_to_conf(class_conf); |
| 2821 |
< |
sendq = MaxSendq(aclass); |
| 2822 |
< |
return sendq; |
| 2823 |
< |
} |
| 2991 |
< |
} |
| 2811 |
> |
struct ConfItem *conf = cnode->data; |
| 2812 |
> |
|
| 2813 |
> |
assert((conf->type == CLIENT_TYPE) || (conf->type == SERVER_TYPE) || |
| 2814 |
> |
(conf->type == OPER_TYPE)); |
| 2815 |
> |
|
| 2816 |
> |
aconf = map_to_conf(conf); |
| 2817 |
> |
|
| 2818 |
> |
if ((class_conf = aconf->class_ptr) == NULL) |
| 2819 |
> |
return DEFAULT_SENDQ; /* TBV: shouldn't be possible at all */ |
| 2820 |
> |
|
| 2821 |
> |
aclass = map_to_conf(class_conf); |
| 2822 |
> |
sendq = aclass->max_sendq; |
| 2823 |
> |
return sendq; |
| 2824 |
|
} |
| 2825 |
+ |
|
| 2826 |
|
/* XXX return a default? |
| 2827 |
|
* if here, then there wasn't an attached conf with a sendq |
| 2828 |
|
* that is very bad -Dianora |
| 2839 |
|
void |
| 2840 |
|
conf_add_class_to_conf(struct ConfItem *conf, const char *class_name) |
| 2841 |
|
{ |
| 2842 |
< |
struct AccessItem *aconf; |
| 2843 |
< |
struct ClassItem *aclass; |
| 3011 |
< |
|
| 3012 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 2842 |
> |
struct AccessItem *aconf = map_to_conf(conf); |
| 2843 |
> |
struct ClassItem *class = NULL; |
| 2844 |
|
|
| 2845 |
|
if (class_name == NULL) |
| 2846 |
|
{ |
| 2847 |
|
aconf->class_ptr = class_default; |
| 2848 |
+ |
|
| 2849 |
|
if (conf->type == CLIENT_TYPE) |
| 2850 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 2851 |
|
"Warning *** Defaulting to default class for %s@%s", |
| 2856 |
|
conf->name); |
| 2857 |
|
} |
| 2858 |
|
else |
| 3027 |
– |
{ |
| 2859 |
|
aconf->class_ptr = find_class(class_name); |
| 3029 |
– |
} |
| 2860 |
|
|
| 2861 |
< |
if (aconf->class_ptr == NULL) |
| 2861 |
> |
if (aconf->class_ptr) |
| 2862 |
> |
class = map_to_conf(aconf->class_ptr); |
| 2863 |
> |
|
| 2864 |
> |
if (aconf->class_ptr == NULL || !class->active) |
| 2865 |
|
{ |
| 2866 |
|
if (conf->type == CLIENT_TYPE) |
| 2867 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 2873 |
|
conf->name); |
| 2874 |
|
aconf->class_ptr = class_default; |
| 2875 |
|
} |
| 3043 |
– |
else |
| 3044 |
– |
{ |
| 3045 |
– |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
| 3046 |
– |
if (MaxTotal(aclass) < 0) |
| 3047 |
– |
{ |
| 3048 |
– |
aconf->class_ptr = class_default; |
| 3049 |
– |
} |
| 3050 |
– |
} |
| 2876 |
|
} |
| 2877 |
|
|
| 3053 |
– |
#define MAXCONFLINKS 150 |
| 3054 |
– |
|
| 2878 |
|
/* conf_add_server() |
| 2879 |
|
* |
| 2880 |
|
* inputs - pointer to config item |
| 2883 |
|
* side effects - Add a connect block |
| 2884 |
|
*/ |
| 2885 |
|
int |
| 2886 |
< |
conf_add_server(struct ConfItem *conf, unsigned int lcount, const char *class_name) |
| 2886 |
> |
conf_add_server(struct ConfItem *conf, const char *class_name) |
| 2887 |
|
{ |
| 2888 |
< |
struct AccessItem *aconf; |
| 3066 |
< |
char *orig_host; |
| 3067 |
< |
|
| 3068 |
< |
aconf = map_to_conf(conf); |
| 2888 |
> |
struct AccessItem *aconf = map_to_conf(conf); |
| 2889 |
|
|
| 2890 |
|
conf_add_class_to_conf(conf, class_name); |
| 2891 |
|
|
| 2892 |
< |
if (lcount > MAXCONFLINKS || !aconf->host || !conf->name) |
| 2892 |
> |
if (!aconf->host || !conf->name) |
| 2893 |
|
{ |
| 2894 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block"); |
| 2895 |
< |
ilog(L_WARN, "Bad connect block"); |
| 2895 |
> |
ilog(LOG_TYPE_IRCD, "Bad connect block"); |
| 2896 |
|
return -1; |
| 2897 |
|
} |
| 2898 |
|
|
| 2899 |
< |
if (EmptyString(aconf->passwd) && !IsConfCryptLink(aconf)) |
| 2899 |
> |
if (EmptyString(aconf->passwd)) |
| 2900 |
|
{ |
| 2901 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block, name %s", |
| 2902 |
|
conf->name); |
| 2903 |
< |
ilog(L_WARN, "Bad connect block, host %s", conf->name); |
| 2903 |
> |
ilog(LOG_TYPE_IRCD, "Bad connect block, host %s", conf->name); |
| 2904 |
|
return -1; |
| 2905 |
|
} |
| 2906 |
|
|
| 3087 |
– |
orig_host = aconf->host; |
| 3088 |
– |
split_nuh(orig_host, NULL, &aconf->user, &aconf->host); |
| 3089 |
– |
MyFree(orig_host); |
| 2907 |
|
lookup_confhost(conf); |
| 2908 |
|
|
| 2909 |
|
return 0; |
| 2910 |
|
} |
| 2911 |
|
|
| 3095 |
– |
/* conf_add_d_conf() |
| 3096 |
– |
* |
| 3097 |
– |
* inputs - pointer to config item |
| 3098 |
– |
* output - NONE |
| 3099 |
– |
* side effects - Add a d/D line |
| 3100 |
– |
*/ |
| 3101 |
– |
void |
| 3102 |
– |
conf_add_d_conf(struct AccessItem *aconf) |
| 3103 |
– |
{ |
| 3104 |
– |
if (aconf->host == NULL) |
| 3105 |
– |
return; |
| 3106 |
– |
|
| 3107 |
– |
aconf->user = NULL; |
| 3108 |
– |
|
| 3109 |
– |
/* XXX - Should 'd' ever be in the old conf? For new conf we don't |
| 3110 |
– |
* need this anyway, so I will disable it for now... -A1kmm |
| 3111 |
– |
*/ |
| 3112 |
– |
if (parse_netmask(aconf->host, NULL, NULL) == HM_HOST) |
| 3113 |
– |
{ |
| 3114 |
– |
ilog(L_WARN, "Invalid Dline %s ignored", aconf->host); |
| 3115 |
– |
free_access_item(aconf); |
| 3116 |
– |
} |
| 3117 |
– |
else |
| 3118 |
– |
{ |
| 3119 |
– |
/* XXX ensure user is NULL */ |
| 3120 |
– |
MyFree(aconf->user); |
| 3121 |
– |
aconf->user = NULL; |
| 3122 |
– |
add_conf_by_address(CONF_DLINE, aconf); |
| 3123 |
– |
} |
| 3124 |
– |
} |
| 3125 |
– |
|
| 2912 |
|
/* yyerror() |
| 2913 |
|
* |
| 2914 |
|
* inputs - message from parser |
| 2920 |
|
{ |
| 2921 |
|
char newlinebuf[IRCD_BUFSIZE]; |
| 2922 |
|
|
| 2923 |
< |
if (ypass != 1) |
| 2923 |
> |
if (conf_parser_ctx.pass != 1) |
| 2924 |
|
return; |
| 2925 |
|
|
| 2926 |
|
strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf)); |
| 2927 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, "\"%s\", line %u: %s: %s", |
| 2928 |
|
conffilebuf, lineno + 1, msg, newlinebuf); |
| 2929 |
< |
ilog(L_WARN, "\"%s\", line %u: %s: %s", |
| 2929 |
> |
ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s", |
| 2930 |
|
conffilebuf, lineno + 1, msg, newlinebuf); |
| 2931 |
|
} |
| 2932 |
|
|
| 3147 |
– |
int |
| 3148 |
– |
conf_fbgets(char *lbuf, unsigned int max_size, FBFILE *fb) |
| 3149 |
– |
{ |
| 3150 |
– |
if (fbgets(lbuf, max_size, fb) == NULL) |
| 3151 |
– |
return 0; |
| 3152 |
– |
|
| 3153 |
– |
return strlen(lbuf); |
| 3154 |
– |
} |
| 3155 |
– |
|
| 3156 |
– |
int |
| 3157 |
– |
conf_yy_fatal_error(const char *msg) |
| 3158 |
– |
{ |
| 3159 |
– |
return 0; |
| 3160 |
– |
} |
| 3161 |
– |
|
| 2933 |
|
/* |
| 2934 |
|
* valid_tkline() |
| 2935 |
|
* |
| 2941 |
|
* Originally written by Dianora (Diane, db@db.net) |
| 2942 |
|
*/ |
| 2943 |
|
time_t |
| 2944 |
< |
valid_tkline(char *p, int minutes) |
| 2944 |
> |
valid_tkline(const char *p, int minutes) |
| 2945 |
|
{ |
| 2946 |
|
time_t result = 0; |
| 2947 |
|
|
| 2948 |
< |
while (*p) |
| 2948 |
> |
for (; *p; ++p) |
| 2949 |
|
{ |
| 2950 |
< |
if (IsDigit(*p)) |
| 3180 |
< |
{ |
| 3181 |
< |
result *= 10; |
| 3182 |
< |
result += ((*p) & 0xF); |
| 3183 |
< |
p++; |
| 3184 |
< |
} |
| 3185 |
< |
else |
| 2950 |
> |
if (!IsDigit(*p)) |
| 2951 |
|
return 0; |
| 2952 |
+ |
|
| 2953 |
+ |
result *= 10; |
| 2954 |
+ |
result += ((*p) & 0xF); |
| 2955 |
|
} |
| 2956 |
|
|
| 2957 |
< |
/* in the degenerate case where oper does a /quote kline 0 user@host :reason |
| 2957 |
> |
/* |
| 2958 |
> |
* In the degenerate case where oper does a /quote kline 0 user@host :reason |
| 2959 |
|
* i.e. they specifically use 0, I am going to return 1 instead |
| 2960 |
|
* as a return value of non-zero is used to flag it as a temporary kline |
| 2961 |
|
*/ |
| 3193 |
– |
|
| 2962 |
|
if (result == 0) |
| 2963 |
|
result = 1; |
| 2964 |
|
|
| 3059 |
|
* if target_server is NULL and an "ON" is found error |
| 3060 |
|
* is reported. |
| 3061 |
|
* if reason pointer is NULL ignore pointer, |
| 3062 |
< |
* this allows usee of parse_a_line in unkline etc. |
| 3062 |
> |
* this allows use of parse_a_line in unkline etc. |
| 3063 |
|
* |
| 3064 |
|
* - Dianora |
| 3065 |
|
*/ |
| 3129 |
|
return -1; |
| 3130 |
|
} |
| 3131 |
|
|
| 3132 |
< |
if (!IsOperRemoteBan(source_p)) |
| 3132 |
> |
if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN)) |
| 3133 |
|
{ |
| 3134 |
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
| 3135 |
|
me.name, source_p->name, "remoteban"); |
| 3166 |
|
return -1; |
| 3167 |
|
} |
| 3168 |
|
|
| 3169 |
< |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 2, *up_p, *h_p)) |
| 3169 |
> |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p)) |
| 3170 |
|
return -1; |
| 3171 |
|
} |
| 3172 |
|
else |
| 3173 |
< |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, YES, 1, *up_p)) |
| 3173 |
> |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p)) |
| 3174 |
|
return -1; |
| 3175 |
|
|
| 3176 |
|
if (reason != NULL) |
| 3177 |
|
{ |
| 3178 |
< |
if (parc != 0) |
| 3178 |
> |
if (parc != 0 && !EmptyString(*parv)) |
| 3179 |
|
{ |
| 3180 |
|
*reason = *parv; |
| 3181 |
< |
if (!valid_comment(source_p, *reason, YES)) |
| 3181 |
> |
if (!valid_comment(source_p, *reason, 1)) |
| 3182 |
|
return -1; |
| 3183 |
|
} |
| 3184 |
|
else |
| 3214 |
|
{ |
| 3215 |
|
/* Explicit user@host mask given */ |
| 3216 |
|
|
| 3217 |
< |
if(hostp != NULL) /* I'm a little user@host */ |
| 3217 |
> |
if (hostp != NULL) /* I'm a little user@host */ |
| 3218 |
|
{ |
| 3219 |
|
*(hostp++) = '\0'; /* short and squat */ |
| 3220 |
|
if (*user_host_or_nick) |
| 3309 |
|
{ |
| 3310 |
|
const char *encr = NULL; |
| 3311 |
|
|
| 3312 |
< |
if (password == NULL || aconf->passwd == NULL) |
| 3312 |
> |
if (EmptyString(password) || EmptyString(aconf->passwd)) |
| 3313 |
|
return 0; |
| 3314 |
|
|
| 3315 |
|
if (aconf->flags & CONF_FLAGS_ENCRYPTED) |
| 3316 |
< |
{ |
| 3549 |
< |
/* use first two chars of the password they send in as salt */ |
| 3550 |
< |
/* If the password in the conf is MD5, and ircd is linked |
| 3551 |
< |
* to scrypt on FreeBSD, or the standard crypt library on |
| 3552 |
< |
* glibc Linux, then this code will work fine on generating |
| 3553 |
< |
* the proper encrypted hash for comparison. |
| 3554 |
< |
*/ |
| 3555 |
< |
if (*aconf->passwd) |
| 3556 |
< |
encr = crypt(password, aconf->passwd); |
| 3557 |
< |
else |
| 3558 |
< |
encr = ""; |
| 3559 |
< |
} |
| 3316 |
> |
encr = crypt(password, aconf->passwd); |
| 3317 |
|
else |
| 3318 |
|
encr = password; |
| 3319 |
|
|
| 3326 |
|
* inputs - client sending the cluster |
| 3327 |
|
* - command name "KLINE" "XLINE" etc. |
| 3328 |
|
* - capab -- CAP_KLN etc. from s_serv.h |
| 3329 |
< |
* - cluster type -- CLUSTER_KLINE etc. from s_conf.h |
| 3329 |
> |
* - cluster type -- CLUSTER_KLINE etc. from conf.h |
| 3330 |
|
* - pattern and args to send along |
| 3331 |
|
* output - none |
| 3332 |
|
* side effects - Take source_p send the pattern with args given |
| 3334 |
|
*/ |
| 3335 |
|
void |
| 3336 |
|
cluster_a_line(struct Client *source_p, const char *command, |
| 3337 |
< |
int capab, int cluster_type, const char *pattern, ...) |
| 3337 |
> |
int capab, int cluster_type, const char *pattern, ...) |
| 3338 |
|
{ |
| 3339 |
|
va_list args; |
| 3340 |
|
char buffer[IRCD_BUFSIZE]; |
| 3341 |
< |
struct ConfItem *conf; |
| 3585 |
< |
dlink_node *ptr; |
| 3341 |
> |
const dlink_node *ptr = NULL; |
| 3342 |
|
|
| 3343 |
|
va_start(args, pattern); |
| 3344 |
|
vsnprintf(buffer, sizeof(buffer), pattern, args); |
| 3346 |
|
|
| 3347 |
|
DLINK_FOREACH(ptr, cluster_items.head) |
| 3348 |
|
{ |
| 3349 |
< |
conf = ptr->data; |
| 3349 |
> |
const struct ConfItem *conf = ptr->data; |
| 3350 |
|
|
| 3351 |
|
if (conf->flags & cluster_type) |
| 3596 |
– |
{ |
| 3352 |
|
sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab, |
| 3353 |
|
"%s %s %s", command, conf->name, buffer); |
| 3599 |
– |
} |
| 3354 |
|
} |
| 3355 |
|
} |
| 3356 |
|
|
| 3382 |
|
* @ * * * |
| 3383 |
|
* ! * * * |
| 3384 |
|
*/ |
| 3631 |
– |
|
| 3385 |
|
void |
| 3386 |
< |
split_nuh(char *mask, char **nick, char **user, char **host) |
| 3386 |
> |
split_nuh(struct split_nuh_item *const iptr) |
| 3387 |
|
{ |
| 3388 |
|
char *p = NULL, *q = NULL; |
| 3389 |
|
|
| 3390 |
< |
if ((p = strchr(mask, '!')) != NULL) |
| 3390 |
> |
if (iptr->nickptr) |
| 3391 |
> |
strlcpy(iptr->nickptr, "*", iptr->nicksize); |
| 3392 |
> |
if (iptr->userptr) |
| 3393 |
> |
strlcpy(iptr->userptr, "*", iptr->usersize); |
| 3394 |
> |
if (iptr->hostptr) |
| 3395 |
> |
strlcpy(iptr->hostptr, "*", iptr->hostsize); |
| 3396 |
> |
|
| 3397 |
> |
if ((p = strchr(iptr->nuhmask, '!'))) |
| 3398 |
|
{ |
| 3399 |
|
*p = '\0'; |
| 3640 |
– |
if (nick != NULL) |
| 3641 |
– |
{ |
| 3642 |
– |
if (*mask != '\0') |
| 3643 |
– |
*nick = xstrldup(mask, NICKLEN); |
| 3644 |
– |
else |
| 3645 |
– |
DupString(*nick, "*"); |
| 3646 |
– |
} |
| 3400 |
|
|
| 3401 |
< |
if ((q = strchr(++p, '@')) != NULL) |
| 3402 |
< |
{ |
| 3403 |
< |
*q = '\0'; |
| 3401 |
> |
if (iptr->nickptr && *iptr->nuhmask != '\0') |
| 3402 |
> |
strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize); |
| 3403 |
> |
|
| 3404 |
> |
if ((q = strchr(++p, '@'))) { |
| 3405 |
> |
*q++ = '\0'; |
| 3406 |
|
|
| 3407 |
|
if (*p != '\0') |
| 3408 |
< |
*user = xstrldup(p, USERLEN+1); |
| 3654 |
< |
else |
| 3655 |
< |
DupString(*user, "*"); |
| 3408 |
> |
strlcpy(iptr->userptr, p, iptr->usersize); |
| 3409 |
|
|
| 3410 |
< |
if (*++q != '\0') |
| 3411 |
< |
*host = xstrldup(q, HOSTLEN+1); |
| 3659 |
< |
else |
| 3660 |
< |
DupString(*host, "*"); |
| 3410 |
> |
if (*q != '\0') |
| 3411 |
> |
strlcpy(iptr->hostptr, q, iptr->hostsize); |
| 3412 |
|
} |
| 3413 |
|
else |
| 3414 |
|
{ |
| 3415 |
|
if (*p != '\0') |
| 3416 |
< |
*user = xstrldup(p, USERLEN+1); |
| 3666 |
< |
else |
| 3667 |
< |
DupString(*user, "*"); |
| 3668 |
< |
|
| 3669 |
< |
DupString(*host, "*"); |
| 3416 |
> |
strlcpy(iptr->userptr, p, iptr->usersize); |
| 3417 |
|
} |
| 3418 |
|
} |
| 3419 |
< |
else /* No ! found so lets look for a user@host */ |
| 3419 |
> |
else |
| 3420 |
|
{ |
| 3421 |
< |
if ((p = strchr(mask, '@')) != NULL) /* if found a @ */ |
| 3421 |
> |
/* No ! found so lets look for a user@host */ |
| 3422 |
> |
if ((p = strchr(iptr->nuhmask, '@'))) |
| 3423 |
|
{ |
| 3424 |
< |
if (nick != NULL) |
| 3425 |
< |
DupString(*nick, "*"); |
| 3678 |
< |
*p = '\0'; |
| 3424 |
> |
/* if found a @ */ |
| 3425 |
> |
*p++ = '\0'; |
| 3426 |
|
|
| 3427 |
< |
if (*mask != '\0') |
| 3428 |
< |
*user = xstrldup(mask, USERLEN+1); |
| 3682 |
< |
else |
| 3683 |
< |
DupString(*user, "*"); |
| 3427 |
> |
if (*iptr->nuhmask != '\0') |
| 3428 |
> |
strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize); |
| 3429 |
|
|
| 3430 |
< |
if (*++p != '\0') |
| 3431 |
< |
*host = xstrldup(p, HOSTLEN+1); |
| 3687 |
< |
else |
| 3688 |
< |
DupString(*host, "*"); |
| 3430 |
> |
if (*p != '\0') |
| 3431 |
> |
strlcpy(iptr->hostptr, p, iptr->hostsize); |
| 3432 |
|
} |
| 3433 |
< |
else /* no @ found */ |
| 3433 |
> |
else |
| 3434 |
|
{ |
| 3435 |
< |
if (nick != NULL) |
| 3436 |
< |
{ |
| 3437 |
< |
if (strpbrk(mask, ".:")) |
| 3695 |
< |
{ |
| 3696 |
< |
DupString(*nick, "*"); |
| 3697 |
< |
*host = xstrldup(mask, HOSTLEN+1); |
| 3698 |
< |
} |
| 3699 |
< |
else |
| 3700 |
< |
{ |
| 3701 |
< |
*nick = xstrldup(mask, NICKLEN); |
| 3702 |
< |
DupString(*host, "*"); |
| 3703 |
< |
} |
| 3704 |
< |
|
| 3705 |
< |
DupString(*user, "*"); |
| 3706 |
< |
} |
| 3435 |
> |
/* no @ found */ |
| 3436 |
> |
if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:")) |
| 3437 |
> |
strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize); |
| 3438 |
|
else |
| 3439 |
< |
{ |
| 3709 |
< |
DupString(*user, "*"); |
| 3710 |
< |
*host = xstrldup(mask, HOSTLEN+1); |
| 3711 |
< |
} |
| 3439 |
> |
strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize); |
| 3440 |
|
} |
| 3441 |
|
} |
| 3442 |
|
} |
| 3463 |
|
{ |
| 3464 |
|
if (flags & mask) |
| 3465 |
|
*p++ = bit_table[i]; |
| 3466 |
< |
else if(lowerit) |
| 3466 |
> |
else if (lowerit) |
| 3467 |
|
*p++ = ToLower(bit_table[i]); |
| 3468 |
|
} |
| 3469 |
|
*p = '\0'; |
| 3486 |
|
dlink_node *ptr = NULL; |
| 3487 |
|
struct CidrItem *cidr; |
| 3488 |
|
|
| 3489 |
< |
if (NumberPerCidr(aclass) <= 0) |
| 3489 |
> |
if (aclass->number_per_cidr <= 0) |
| 3490 |
|
return 0; |
| 3491 |
|
|
| 3492 |
|
if (ip->ss.ss_family == AF_INET) |
| 3493 |
|
{ |
| 3494 |
< |
if (CidrBitlenIPV4(aclass) <= 0) |
| 3494 |
> |
if (aclass->cidr_bitlen_ipv4 <= 0) |
| 3495 |
|
return 0; |
| 3496 |
|
|
| 3497 |
|
DLINK_FOREACH(ptr, aclass->list_ipv4.head) |
| 3498 |
|
{ |
| 3499 |
|
cidr = ptr->data; |
| 3500 |
< |
if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass))) |
| 3500 |
> |
if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4)) |
| 3501 |
|
{ |
| 3502 |
< |
if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass))) |
| 3502 |
> |
if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr)) |
| 3503 |
|
return -1; |
| 3504 |
|
cidr->number_on_this_cidr++; |
| 3505 |
|
return 0; |
| 3508 |
|
cidr = MyMalloc(sizeof(struct CidrItem)); |
| 3509 |
|
cidr->number_on_this_cidr = 1; |
| 3510 |
|
cidr->mask = *ip; |
| 3511 |
< |
mask_addr(&cidr->mask, CidrBitlenIPV4(aclass)); |
| 3511 |
> |
mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv4); |
| 3512 |
|
dlinkAdd(cidr, &cidr->node, &aclass->list_ipv4); |
| 3513 |
|
} |
| 3514 |
|
#ifdef IPV6 |
| 3515 |
< |
else if (CidrBitlenIPV6(aclass) > 0) |
| 3515 |
> |
else if (aclass->cidr_bitlen_ipv6 > 0) |
| 3516 |
|
{ |
| 3517 |
|
DLINK_FOREACH(ptr, aclass->list_ipv6.head) |
| 3518 |
|
{ |
| 3519 |
|
cidr = ptr->data; |
| 3520 |
< |
if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass))) |
| 3520 |
> |
if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6)) |
| 3521 |
|
{ |
| 3522 |
< |
if (!over_rule && (cidr->number_on_this_cidr >= NumberPerCidr(aclass))) |
| 3522 |
> |
if (!over_rule && (cidr->number_on_this_cidr >= aclass->number_per_cidr)) |
| 3523 |
|
return -1; |
| 3524 |
|
cidr->number_on_this_cidr++; |
| 3525 |
|
return 0; |
| 3528 |
|
cidr = MyMalloc(sizeof(struct CidrItem)); |
| 3529 |
|
cidr->number_on_this_cidr = 1; |
| 3530 |
|
cidr->mask = *ip; |
| 3531 |
< |
mask_addr(&cidr->mask, CidrBitlenIPV6(aclass)); |
| 3531 |
> |
mask_addr(&cidr->mask, aclass->cidr_bitlen_ipv6); |
| 3532 |
|
dlinkAdd(cidr, &cidr->node, &aclass->list_ipv6); |
| 3533 |
|
} |
| 3534 |
|
#endif |
| 3550 |
|
dlink_node *next_ptr = NULL; |
| 3551 |
|
struct CidrItem *cidr; |
| 3552 |
|
|
| 3553 |
< |
if (NumberPerCidr(aclass) == 0) |
| 3553 |
> |
if (aclass->number_per_cidr == 0) |
| 3554 |
|
return; |
| 3555 |
|
|
| 3556 |
|
if (ip->ss.ss_family == AF_INET) |
| 3557 |
|
{ |
| 3558 |
< |
if (CidrBitlenIPV4(aclass) <= 0) |
| 3558 |
> |
if (aclass->cidr_bitlen_ipv4 <= 0) |
| 3559 |
|
return; |
| 3560 |
|
|
| 3561 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv4.head) |
| 3562 |
|
{ |
| 3563 |
|
cidr = ptr->data; |
| 3564 |
< |
if (match_ipv4(ip, &cidr->mask, CidrBitlenIPV4(aclass))) |
| 3564 |
> |
if (match_ipv4(ip, &cidr->mask, aclass->cidr_bitlen_ipv4)) |
| 3565 |
|
{ |
| 3566 |
|
cidr->number_on_this_cidr--; |
| 3567 |
|
if (cidr->number_on_this_cidr == 0) |
| 3574 |
|
} |
| 3575 |
|
} |
| 3576 |
|
#ifdef IPV6 |
| 3577 |
< |
else if (CidrBitlenIPV6(aclass) > 0) |
| 3577 |
> |
else if (aclass->cidr_bitlen_ipv6 > 0) |
| 3578 |
|
{ |
| 3579 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head) |
| 3580 |
|
{ |
| 3581 |
|
cidr = ptr->data; |
| 3582 |
< |
if (match_ipv6(ip, &cidr->mask, CidrBitlenIPV6(aclass))) |
| 3582 |
> |
if (match_ipv6(ip, &cidr->mask, aclass->cidr_bitlen_ipv6)) |
| 3583 |
|
{ |
| 3584 |
|
cidr->number_on_this_cidr--; |
| 3585 |
|
if (cidr->number_on_this_cidr == 0) |
| 3642 |
|
{ |
| 3643 |
|
struct ClassItem *old_class = map_to_conf(conf); |
| 3644 |
|
|
| 3645 |
< |
if (NumberPerCidr(old_class) > 0 && NumberPerCidr(new_class) > 0) |
| 3645 |
> |
if (old_class->number_per_cidr > 0 && new_class->number_per_cidr > 0) |
| 3646 |
|
{ |
| 3647 |
< |
if (CidrBitlenIPV4(old_class) > 0 && CidrBitlenIPV4(new_class) > 0) |
| 3647 |
> |
if (old_class->cidr_bitlen_ipv4 > 0 && new_class->cidr_bitlen_ipv4 > 0) |
| 3648 |
|
rebuild_cidr_list(AF_INET, conf, new_class, |
| 3649 |
|
&old_class->list_ipv4, &new_class->list_ipv4, |
| 3650 |
< |
CidrBitlenIPV4(old_class) != CidrBitlenIPV4(new_class)); |
| 3650 |
> |
old_class->cidr_bitlen_ipv4 != new_class->cidr_bitlen_ipv4); |
| 3651 |
|
|
| 3652 |
|
#ifdef IPV6 |
| 3653 |
< |
if (CidrBitlenIPV6(old_class) > 0 && CidrBitlenIPV6(new_class) > 0) |
| 3653 |
> |
if (old_class->cidr_bitlen_ipv6 > 0 && new_class->cidr_bitlen_ipv6 > 0) |
| 3654 |
|
rebuild_cidr_list(AF_INET6, conf, new_class, |
| 3655 |
|
&old_class->list_ipv6, &new_class->list_ipv6, |
| 3656 |
< |
CidrBitlenIPV6(old_class) != CidrBitlenIPV6(new_class)); |
| 3656 |
> |
old_class->cidr_bitlen_ipv6 != new_class->cidr_bitlen_ipv6); |
| 3657 |
|
#endif |
| 3658 |
|
} |
| 3659 |
|
|
| 3670 |
|
static void |
| 3671 |
|
destroy_cidr_list(dlink_list *list) |
| 3672 |
|
{ |
| 3673 |
< |
dlink_node *ptr = NULL; |
| 3946 |
< |
dlink_node *next_ptr = NULL; |
| 3947 |
< |
struct CidrItem *cidr; |
| 3673 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
| 3674 |
|
|
| 3675 |
|
DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) |
| 3676 |
|
{ |
| 3951 |
– |
cidr = ptr->data; |
| 3677 |
|
dlinkDelete(ptr, list); |
| 3678 |
< |
MyFree(cidr); |
| 3678 |
> |
MyFree(ptr->data); |
| 3679 |
|
} |
| 3680 |
|
} |
| 3681 |
|
|