| 31 |
|
#include "sprintf_irc.h" |
| 32 |
|
#include "ircd.h" |
| 33 |
|
#include "numeric.h" |
| 34 |
< |
#include "s_log.h" |
| 34 |
> |
#include "log.h" |
| 35 |
|
#include "send.h" |
| 36 |
< |
#include "s_conf.h" |
| 36 |
> |
#include "conf.h" |
| 37 |
|
#include "memory.h" |
| 38 |
|
#include "s_user.h" |
| 39 |
|
#include "s_serv.h" |
| 102 |
|
* NOTE: parse() should not be called recursively by other functions! |
| 103 |
|
*/ |
| 104 |
|
static char *sender; |
| 105 |
< |
static char *para[MAXPARA + 1]; |
| 105 |
> |
static char *para[MAXPARA + 2]; /* <prefix> + <params> + NULL */ |
| 106 |
|
static char buffer[1024]; |
| 107 |
|
|
| 108 |
|
static int cancel_clients(struct Client *, struct Client *, char *); |
| 109 |
|
static void remove_unknown(struct Client *, char *, char *); |
| 110 |
|
static void handle_numeric(char[], struct Client *, struct Client *, int, char *[]); |
| 111 |
|
static void handle_command(struct Message *, struct Client *, struct Client *, unsigned int, char *[]); |
| 112 |
– |
static void add_msg_element(struct MessageTree *, struct Message *, const char *); |
| 113 |
– |
static void del_msg_element(struct MessageTree *, const char *); |
| 112 |
|
|
| 113 |
|
|
| 114 |
|
/* |
| 301 |
|
*/ |
| 302 |
|
static void |
| 303 |
|
handle_command(struct Message *mptr, struct Client *client_p, |
| 304 |
< |
struct Client *from, unsigned int i, char *hpara[MAXPARA]) |
| 304 |
> |
struct Client *from, unsigned int i, char *hpara[]) |
| 305 |
|
{ |
| 306 |
|
MessageHandler handler = 0; |
| 307 |
|
|
| 310 |
|
|
| 311 |
|
mptr->count++; |
| 312 |
|
|
| 315 |
– |
/* New patch to avoid server flooding from unregistered connects |
| 316 |
– |
* - Pie-Man 07/27/2000 */ |
| 317 |
– |
if (!IsRegistered(client_p)) |
| 318 |
– |
{ |
| 319 |
– |
/* if its from a possible server connection |
| 320 |
– |
* ignore it.. more than likely its a header thats sneaked through |
| 321 |
– |
*/ |
| 322 |
– |
if ((IsHandshake(client_p) || IsConnecting(client_p) || |
| 323 |
– |
IsServer(client_p)) && !(mptr->flags & MFLG_UNREG)) |
| 324 |
– |
return; |
| 325 |
– |
} |
| 326 |
– |
|
| 313 |
|
handler = mptr->handlers[client_p->handler]; |
| 314 |
|
|
| 315 |
|
/* check right amount of params is passed... --is */ |
| 317 |
|
{ |
| 318 |
|
if (!IsServer(client_p)) |
| 319 |
|
{ |
| 320 |
< |
sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS), |
| 321 |
< |
me.name, EmptyString(hpara[0]) ? "*" : hpara[0], mptr->cmd); |
| 320 |
> |
sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS), me.name, |
| 321 |
> |
EmptyString(hpara[0]) ? "*" : hpara[0], mptr->cmd); |
| 322 |
|
} |
| 323 |
|
else |
| 324 |
|
{ |
| 325 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 325 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 326 |
|
"Dropping server %s due to (invalid) command '%s' " |
| 327 |
|
"with only %d arguments (expecting %d).", |
| 328 |
|
client_p->name, mptr->cmd, i, mptr->args_min); |
| 336 |
|
(*handler)(client_p, from, i, hpara); |
| 337 |
|
} |
| 338 |
|
|
| 353 |
– |
/* clear_tree_parse() |
| 354 |
– |
* |
| 355 |
– |
* inputs - NONE |
| 356 |
– |
* output - NONE |
| 357 |
– |
* side effects - MUST MUST be called at startup ONCE before |
| 358 |
– |
* any other keyword routine is used. |
| 359 |
– |
*/ |
| 360 |
– |
void |
| 361 |
– |
clear_tree_parse(void) |
| 362 |
– |
{ |
| 363 |
– |
memset(&msg_tree, 0, sizeof(msg_tree)); |
| 364 |
– |
} |
| 365 |
– |
|
| 339 |
|
/* add_msg_element() |
| 340 |
|
* |
| 341 |
|
* inputs - pointer to MessageTree |
| 357 |
|
* in the parent. |
| 358 |
|
*/ |
| 359 |
|
static void |
| 360 |
< |
add_msg_element(struct MessageTree *mtree_p, |
| 361 |
< |
struct Message *msg_p, const char *cmd) |
| 360 |
> |
add_msg_element(struct MessageTree *mtree_p, struct Message *msg_p, |
| 361 |
> |
const char *cmd) |
| 362 |
|
{ |
| 363 |
|
struct MessageTree *ntree_p; |
| 364 |
|
|
| 365 |
|
if (*cmd == '\0') |
| 366 |
|
{ |
| 367 |
|
mtree_p->msg = msg_p; |
| 368 |
< |
mtree_p->links++; /* Have msg pointer, so up ref count */ |
| 368 |
> |
mtree_p->links++; /* Have msg pointer, so up ref count */ |
| 369 |
|
} |
| 370 |
|
else |
| 371 |
|
{ |
| 380 |
|
ntree_p = MyMalloc(sizeof(struct MessageTree)); |
| 381 |
|
mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = ntree_p; |
| 382 |
|
|
| 383 |
< |
mtree_p->links++; /* Have new pointer, so up ref count */ |
| 383 |
> |
mtree_p->links++; /* Have new pointer, so up ref count */ |
| 384 |
|
} |
| 385 |
|
|
| 386 |
|
add_msg_element(ntree_p, msg_p, cmd + 1); |
| 433 |
|
|
| 434 |
|
if (ntree_p->links == 0) |
| 435 |
|
{ |
| 436 |
< |
mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = NULL; |
| 437 |
< |
mtree_p->links--; |
| 438 |
< |
MyFree(ntree_p); |
| 436 |
> |
mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = NULL; |
| 437 |
> |
mtree_p->links--; |
| 438 |
> |
MyFree(ntree_p); |
| 439 |
|
} |
| 440 |
|
} |
| 441 |
|
} |
| 449 |
|
* side effects - none |
| 450 |
|
*/ |
| 451 |
|
static struct Message * |
| 452 |
< |
msg_tree_parse(const char *cmd, struct MessageTree *root) |
| 452 |
> |
msg_tree_parse(const char *cmd) |
| 453 |
|
{ |
| 454 |
< |
struct MessageTree *mtree = root; |
| 454 |
> |
struct MessageTree *mtree = &msg_tree; |
| 455 |
|
assert(cmd && *cmd); |
| 456 |
|
|
| 457 |
|
while (IsAlpha(*cmd) && (mtree = mtree->pointers[*cmd & (MAXPTRLEN - 1)])) |
| 475 |
|
assert(msg && msg->cmd); |
| 476 |
|
|
| 477 |
|
/* command already added? */ |
| 478 |
< |
if (msg_tree_parse(msg->cmd, &msg_tree)) |
| 478 |
> |
if (msg_tree_parse(msg->cmd)) |
| 479 |
|
return; |
| 480 |
|
|
| 481 |
|
add_msg_element(&msg_tree, msg, msg->cmd); |
| 505 |
|
struct Message * |
| 506 |
|
find_command(const char *cmd) |
| 507 |
|
{ |
| 508 |
< |
return msg_tree_parse(cmd, &msg_tree); |
| 508 |
> |
return msg_tree_parse(cmd); |
| 509 |
|
} |
| 510 |
|
|
| 511 |
|
static void |
| 572 |
|
*/ |
| 573 |
|
if (IsServer(source_p) || IsMe(source_p)) |
| 574 |
|
{ |
| 575 |
< |
sendto_realops_flags(UMODE_DEBUG, L_ADMIN, "Message for %s[%s] from %s", |
| 575 |
> |
sendto_realops_flags(UMODE_DEBUG, L_ADMIN, SEND_NOTICE, |
| 576 |
> |
"Message for %s[%s] from %s", |
| 577 |
|
source_p->name, source_p->from->name, |
| 578 |
|
get_client_name(client_p, SHOW_IP)); |
| 579 |
< |
sendto_realops_flags(UMODE_DEBUG, L_OPER, "Message for %s[%s] from %s", |
| 579 |
> |
sendto_realops_flags(UMODE_DEBUG, L_OPER, SEND_NOTICE, |
| 580 |
> |
"Message for %s[%s] from %s", |
| 581 |
|
source_p->name, source_p->from->name, |
| 582 |
|
get_client_name(client_p, MASK_IP)); |
| 583 |
< |
sendto_realops_flags(UMODE_DEBUG, L_ALL, |
| 583 |
> |
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE, |
| 584 |
|
"Not dropping server %s (%s) for Fake Direction", |
| 585 |
|
client_p->name, source_p->name); |
| 586 |
|
return -1; |
| 596 |
|
* |
| 597 |
|
* all servers must be TS these days --is |
| 598 |
|
*/ |
| 599 |
< |
sendto_realops_flags(UMODE_DEBUG, L_ADMIN, |
| 599 |
> |
sendto_realops_flags(UMODE_DEBUG, L_ADMIN, SEND_NOTICE, |
| 600 |
|
"Message for %s[%s@%s!%s] from %s (TS, ignored)", |
| 601 |
|
source_p->name, source_p->username, source_p->host, |
| 602 |
|
source_p->from->name, get_client_name(client_p, SHOW_IP)); |
| 603 |
< |
sendto_realops_flags(UMODE_DEBUG, L_OPER, |
| 603 |
> |
sendto_realops_flags(UMODE_DEBUG, L_OPER, SEND_NOTICE, |
| 604 |
|
"Message for %s[%s@%s!%s] from %s (TS, ignored)", |
| 605 |
|
source_p->name, source_p->username, source_p->host, |
| 606 |
|
source_p->from->name, get_client_name(client_p, MASK_IP)); |
| 628 |
|
if ((IsDigit(*lsender) && strlen(lsender) <= IRC_MAXSID) || |
| 629 |
|
strchr(lsender, '.') != NULL) |
| 630 |
|
{ |
| 631 |
< |
sendto_realops_flags(UMODE_DEBUG, L_ADMIN, |
| 631 |
> |
sendto_realops_flags(UMODE_DEBUG, L_ADMIN, SEND_NOTICE, |
| 632 |
|
"Unknown prefix (%s) from %s, Squitting %s", |
| 633 |
|
lbuffer, get_client_name(client_p, SHOW_IP), lsender); |
| 634 |
< |
sendto_realops_flags(UMODE_DEBUG, L_OPER, |
| 634 |
> |
sendto_realops_flags(UMODE_DEBUG, L_OPER, SEND_NOTICE, |
| 635 |
|
"Unknown prefix (%s) from %s, Squitting %s", |
| 636 |
|
lbuffer, client_p->name, lsender); |
| 637 |
|
sendto_one(client_p, ":%s SQUIT %s :(Unknown prefix (%s) from %s)", |
| 712 |
|
* unfortunately, it did not work. --Dianora |
| 713 |
|
*/ |
| 714 |
|
|
| 715 |
+ |
|
| 716 |
+ |
/* |
| 717 |
+ |
* Also ignoring ERR_NOTREGISTERED for now. A connecting server may send this |
| 718 |
+ |
* in response to the "NOTICE AUTH ..." message upon registration. Normally |
| 719 |
+ |
* the !IsServer() test in handle_numeric() would take care of this situation, |
| 720 |
+ |
* but due to the fact that read_packet() in s_auth.c:release_auth_client() is |
| 721 |
+ |
* called for the very first time _after_ ident/dns registration, it looks like |
| 722 |
+ |
* the numeric (451) messages are queued up whereas meanwhile the serverlink |
| 723 |
+ |
* succesfully establishes. Right after that, after IsServer() is true, the queued |
| 724 |
+ |
* numeric messages will then be processed, and a notice is falsely sent to operators. |
| 725 |
+ |
* The I/O engine will be rewritten soon (a mixture of libevent), so maybe this also |
| 726 |
+ |
* will fix described behavior above, but for now we're just going to drop this message |
| 727 |
+ |
* (no problem at all, we propably shouldn't process numeric destined to servers anyway) |
| 728 |
+ |
* -Michael |
| 729 |
+ |
*/ |
| 730 |
|
/* Yes, a good compiler would have optimised this, but |
| 731 |
|
* this is probably easier to read. -db |
| 732 |
|
*/ |
| 733 |
|
num = atoi(numeric); |
| 734 |
|
|
| 735 |
< |
if ((num != ERR_NOSUCHNICK)) |
| 736 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
| 737 |
< |
"*** %s(via %s) sent a %s numeric to me: %s", |
| 738 |
< |
source_p->name, client_p->name, numeric, buffer); |
| 735 |
> |
if ((num != ERR_NOSUCHNICK) && (num != ERR_NOTREGISTERED)) |
| 736 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 737 |
> |
"*** %s(via %s) sent a %s numeric to me: %s", |
| 738 |
> |
source_p->name, client_p->name, numeric, buffer); |
| 739 |
|
return; |
| 740 |
|
} |
| 741 |
|
else if (target_p->from == client_p) |
| 760 |
|
return; |
| 761 |
|
} |
| 762 |
|
else if ((chptr = hash_find_channel(parv[1])) != NULL) |
| 763 |
< |
sendto_channel_local(ALL_MEMBERS, 0, chptr, |
| 764 |
< |
":%s %s %s %s", |
| 765 |
< |
source_p->name, |
| 776 |
< |
numeric, chptr->chname, buffer); |
| 763 |
> |
sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s %s %s %s", |
| 764 |
> |
source_p->name, |
| 765 |
> |
numeric, chptr->chname, buffer); |
| 766 |
|
} |
| 767 |
|
|
| 768 |
|
/* m_not_oper() |
| 814 |
|
|
| 815 |
|
if (client_p == source_p) |
| 816 |
|
{ |
| 817 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s -- %s", |
| 817 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 818 |
> |
"ERROR :from %s -- %s", |
| 819 |
|
get_client_name(client_p, HIDE_IP), in_para); |
| 820 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, "ERROR :from %s -- %s", |
| 820 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 821 |
> |
"ERROR :from %s -- %s", |
| 822 |
|
get_client_name(client_p, MASK_IP), in_para); |
| 823 |
|
} |
| 824 |
|
else |
| 825 |
|
{ |
| 826 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, "ERROR :from %s via %s -- %s", |
| 827 |
< |
source_p->name, get_client_name(client_p, MASK_IP), in_para); |
| 837 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s via %s -- %s", |
| 826 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 827 |
> |
"ERROR :from %s via %s -- %s", |
| 828 |
|
source_p->name, get_client_name(client_p, HIDE_IP), in_para); |
| 829 |
+ |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 830 |
+ |
"ERROR :from %s via %s -- %s", |
| 831 |
+ |
source_p->name, get_client_name(client_p, MASK_IP), in_para); |
| 832 |
|
} |
| 833 |
|
|
| 834 |
|
if (MyClient(source_p)) |