23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
< |
#include "tools.h" |
26 |
> |
#include "list.h" |
27 |
|
#include "s_user.h" |
28 |
|
#include "s_misc.h" |
29 |
|
#include "channel.h" |
35 |
|
#include "irc_string.h" |
36 |
|
#include "sprintf_irc.h" |
37 |
|
#include "s_bsd.h" |
38 |
– |
#include "irc_getnameinfo.h" |
38 |
|
#include "ircd.h" |
40 |
– |
#include "list.h" |
39 |
|
#include "listener.h" |
40 |
|
#include "motd.h" |
41 |
|
#include "numeric.h" |
42 |
|
#include "s_conf.h" |
43 |
|
#include "s_log.h" |
44 |
|
#include "s_serv.h" |
47 |
– |
#include "s_stats.h" |
45 |
|
#include "send.h" |
46 |
|
#include "supported.h" |
47 |
|
#include "whowas.h" |
48 |
|
#include "memory.h" |
49 |
|
#include "packet.h" |
50 |
+ |
#include "rng_mt.h" |
51 |
|
#include "userhost.h" |
52 |
|
#include "hook.h" |
53 |
|
#include "s_misc.h" |
54 |
|
#include "msg.h" |
55 |
< |
#include "pcre.h" |
55 |
> |
#include "watch.h" |
56 |
|
|
57 |
< |
int MaxClientCount = 1; |
58 |
< |
int MaxConnectionCount = 1; |
57 |
> |
unsigned int MaxClientCount = 1; |
58 |
> |
unsigned int MaxConnectionCount = 1; |
59 |
|
struct Callback *entering_umode_cb = NULL; |
60 |
|
struct Callback *umode_cb = NULL; |
63 |
– |
struct Callback *uid_get_cb = NULL; |
61 |
|
|
62 |
|
static char umode_buffer[IRCD_BUFSIZE]; |
63 |
|
|
64 |
|
static void user_welcome(struct Client *); |
65 |
|
static void report_and_set_user_flags(struct Client *, const struct AccessItem *); |
66 |
|
static int check_xline(struct Client *); |
67 |
< |
static int check_regexp_xline(struct Client *); |
68 |
< |
static void introduce_client(struct Client *, struct Client *); |
72 |
< |
static void *uid_get(va_list); |
67 |
> |
static void introduce_client(struct Client *); |
68 |
> |
static const char *uid_get(void); |
69 |
|
|
70 |
|
/* Used for building up the isupport string, |
71 |
|
* used with init_isupport, add_isupport, delete_isupport |
92 |
|
0, /* @ */ |
93 |
|
0, /* A */ |
94 |
|
0, /* B */ |
95 |
< |
0, /* C */ |
95 |
> |
UMODE_CCONN_FULL, /* C */ |
96 |
|
UMODE_DEAF, /* D */ |
97 |
|
0, /* E */ |
98 |
|
0, /* F */ |
162 |
|
unsigned int idx = 0; |
163 |
|
char *umode_buffer_ptr = umode_buffer; |
164 |
|
|
165 |
< |
for (; idx < (sizeof(user_modes) / sizeof(int)); ++idx) |
165 |
> |
for (; idx < (sizeof(user_modes) / sizeof(user_modes[0])); ++idx) |
166 |
|
if (user_modes[idx]) |
167 |
|
*umode_buffer_ptr++ = idx; |
168 |
|
|
279 |
|
** nick from local user or kill him/her... |
280 |
|
*/ |
281 |
|
void |
282 |
< |
register_local_user(struct Client *client_p, struct Client *source_p, |
287 |
< |
const char *nick, const char *username) |
282 |
> |
register_local_user(struct Client *source_p) |
283 |
|
{ |
284 |
|
const struct AccessItem *aconf = NULL; |
290 |
– |
char ipaddr[HOSTIPLEN]; |
285 |
|
dlink_node *ptr = NULL; |
286 |
|
dlink_node *m = NULL; |
287 |
|
|
288 |
|
assert(source_p != NULL); |
289 |
+ |
assert(source_p == source_p->from); |
290 |
|
assert(MyConnect(source_p)); |
296 |
– |
assert(source_p->username != username); |
291 |
|
assert(!source_p->localClient->registration); |
292 |
|
|
293 |
+ |
ClearCap(source_p, CAP_TS6); |
294 |
+ |
|
295 |
|
if (ConfigFileEntry.ping_cookie) |
296 |
|
{ |
297 |
< |
if (!IsPingSent(source_p) && |
302 |
< |
source_p->localClient->random_ping == 0) |
297 |
> |
if (!IsPingSent(source_p) && source_p->localClient->random_ping == 0) |
298 |
|
{ |
299 |
< |
source_p->localClient->random_ping = (unsigned long)rand(); |
300 |
< |
sendto_one(source_p, "PING :%lu", |
299 |
> |
do |
300 |
> |
source_p->localClient->random_ping = genrand_int32(); |
301 |
> |
while (!source_p->localClient->random_ping); |
302 |
> |
|
303 |
> |
sendto_one(source_p, "PING :%u", |
304 |
|
source_p->localClient->random_ping); |
305 |
|
SetPingSent(source_p); |
306 |
|
return; |
314 |
|
/* Straight up the maximum rate of flooding... */ |
315 |
|
source_p->localClient->allow_read = MAX_FLOOD_BURST; |
316 |
|
|
317 |
< |
if (!execute_callback(client_check_cb, source_p, username)) |
317 |
> |
if (!execute_callback(client_check_cb, source_p, source_p->username)) |
318 |
|
return; |
319 |
|
|
320 |
|
if (valid_hostname(source_p->host) == 0) |
330 |
|
|
331 |
|
if (!IsGotId(source_p)) |
332 |
|
{ |
333 |
< |
const char *p = NULL; |
333 |
> |
char username[USERLEN + 1]; |
334 |
> |
const char *p = username; |
335 |
|
unsigned int i = 0; |
336 |
|
|
337 |
|
if (IsNeedIdentd(aconf)) |
338 |
|
{ |
339 |
< |
ServerStats->is_ref++; |
339 |
> |
++ServerStats.is_ref; |
340 |
|
sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install " |
341 |
|
"identd to use this server", me.name, source_p->name); |
342 |
|
exit_client(source_p, &me, "Install identd"); |
343 |
|
return; |
344 |
|
} |
345 |
|
|
346 |
< |
p = username; |
346 |
> |
strlcpy(username, source_p->username, sizeof(username)); |
347 |
|
|
348 |
|
if (!IsNoTilde(aconf)) |
349 |
|
source_p->username[i++] = '~'; |
350 |
|
|
351 |
< |
while (*p && i < USERLEN) |
353 |
< |
{ |
351 |
> |
for (; *p && i < USERLEN; ++p) |
352 |
|
if (*p != '[') |
353 |
|
source_p->username[i++] = *p; |
356 |
– |
p++; |
357 |
– |
} |
354 |
|
|
355 |
|
source_p->username[i] = '\0'; |
356 |
|
} |
362 |
|
|
363 |
|
if (!match_conf_password(pass, aconf)) |
364 |
|
{ |
365 |
< |
ServerStats->is_ref++; |
365 |
> |
++ServerStats.is_ref; |
366 |
|
sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), |
367 |
|
me.name, source_p->name); |
368 |
|
exit_client(source_p, &me, "Bad Password"); |
378 |
|
/* report if user has &^>= etc. and set flags as needed in source_p */ |
379 |
|
report_and_set_user_flags(source_p, aconf); |
380 |
|
|
381 |
+ |
if (IsDead(source_p)) |
382 |
+ |
return; |
383 |
+ |
|
384 |
|
/* Limit clients - |
385 |
|
* We want to be able to have servers and F-line clients |
386 |
|
* connect, so save room for "buffer" connections. |
394 |
|
{ |
395 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, |
396 |
|
"Too many clients, rejecting %s[%s].", |
397 |
< |
nick, source_p->host); |
398 |
< |
ServerStats->is_ref++; |
397 |
> |
source_p->name, source_p->host); |
398 |
> |
++ServerStats.is_ref; |
399 |
|
exit_client(source_p, &me, "Sorry, server is full - try later"); |
400 |
|
return; |
401 |
|
} |
406 |
|
char tmpstr2[IRCD_BUFSIZE]; |
407 |
|
|
408 |
|
sendto_realops_flags(UMODE_REJ, L_ALL, "Invalid username: %s (%s@%s)", |
409 |
< |
nick, source_p->username, source_p->host); |
410 |
< |
ServerStats->is_ref++; |
409 |
> |
source_p->name, source_p->username, source_p->host); |
410 |
> |
++ServerStats.is_ref; |
411 |
|
ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username); |
412 |
|
exit_client(source_p, &me, tmpstr2); |
413 |
|
return; |
414 |
|
} |
415 |
|
|
416 |
< |
assert(source_p == client_p); |
418 |
< |
|
419 |
< |
/* end of valid user name check */ |
420 |
< |
if (check_xline(source_p) || check_regexp_xline(source_p)) |
421 |
< |
return; |
422 |
< |
|
423 |
< |
if (IsDead(client_p)) |
416 |
> |
if (check_xline(source_p)) |
417 |
|
return; |
418 |
|
|
419 |
< |
if (source_p->id[0] == '\0' && me.id[0]) |
419 |
> |
if (me.id[0]) |
420 |
|
{ |
421 |
< |
char *id = (char *)execute_callback(uid_get_cb, source_p); |
422 |
< |
while (hash_find_id(id) != NULL) |
423 |
< |
id = uid_get(NULL); |
421 |
> |
const char *id = NULL; |
422 |
> |
|
423 |
> |
while (hash_find_id((id = uid_get())) != NULL) |
424 |
> |
; |
425 |
|
|
426 |
|
strlcpy(source_p->id, id, sizeof(source_p->id)); |
427 |
|
hash_add_id(source_p); |
428 |
|
} |
429 |
|
|
436 |
– |
irc_getnameinfo((struct sockaddr *)&source_p->localClient->ip, |
437 |
– |
source_p->localClient->ip.ss_len, ipaddr, |
438 |
– |
HOSTIPLEN, NULL, 0, NI_NUMERICHOST); |
439 |
– |
|
430 |
|
sendto_realops_flags(UMODE_CCONN, L_ALL, |
431 |
|
"Client connecting: %s (%s@%s) [%s] {%s} [%s]", |
432 |
< |
nick, source_p->username, source_p->host, |
432 |
> |
source_p->name, source_p->username, source_p->host, |
433 |
|
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
434 |
< |
"255.255.255.255" : ipaddr, get_client_class(source_p), |
434 |
> |
"255.255.255.255" : source_p->sockhost, |
435 |
> |
get_client_class(source_p), |
436 |
> |
source_p->info); |
437 |
> |
|
438 |
> |
sendto_realops_flags(UMODE_CCONN_FULL, L_ALL, |
439 |
> |
"CLICONN %s %s %s %s %s %s %s 0 %s", |
440 |
> |
source_p->name, source_p->username, source_p->host, |
441 |
> |
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
442 |
> |
"255.255.255.255" : source_p->sockhost, |
443 |
> |
get_client_class(source_p), |
444 |
> |
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
445 |
> |
"<hidden>" : source_p->client_host, |
446 |
> |
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
447 |
> |
"<hidden>" : source_p->client_server, |
448 |
|
source_p->info); |
449 |
|
|
447 |
– |
/* If they have died in send_* don't do anything. */ |
448 |
– |
if (IsDead(source_p)) |
449 |
– |
return; |
450 |
|
|
451 |
|
if (ConfigFileEntry.invisible_on_connect) |
452 |
|
{ |
453 |
|
source_p->umodes |= UMODE_INVISIBLE; |
454 |
< |
Count.invisi++; |
454 |
> |
++Count.invisi; |
455 |
|
} |
456 |
|
|
457 |
|
if ((++Count.local) > Count.max_loc) |
463 |
|
Count.max_loc); |
464 |
|
} |
465 |
|
|
466 |
– |
SetClient(source_p); |
467 |
– |
|
468 |
– |
source_p->servptr = &me; |
469 |
– |
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users); |
470 |
– |
|
466 |
|
/* Increment our total user count here */ |
467 |
|
if (++Count.total > Count.max_tot) |
468 |
|
Count.max_tot = Count.total; |
469 |
< |
Count.totalrestartcount++; |
469 |
> |
++Count.totalrestartcount; |
470 |
> |
|
471 |
> |
assert(source_p->servptr == &me); |
472 |
> |
SetClient(source_p); |
473 |
> |
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list); |
474 |
|
|
475 |
|
source_p->localClient->allow_read = MAX_FLOOD_BURST; |
476 |
|
|
477 |
+ |
assert(dlinkFindDelete(&unknown_list, source_p)); |
478 |
+ |
|
479 |
|
if ((m = dlinkFindDelete(&unknown_list, source_p)) != NULL) |
480 |
|
{ |
481 |
|
free_dlink_node(m); |
482 |
|
dlinkAdd(source_p, &source_p->localClient->lclient_node, &local_client_list); |
483 |
|
} |
483 |
– |
else assert(0); |
484 |
|
|
485 |
|
user_welcome(source_p); |
486 |
|
add_user_host(source_p->username, source_p->host, 0); |
487 |
|
SetUserHost(source_p); |
488 |
|
|
489 |
< |
introduce_client(client_p, source_p); |
489 |
> |
introduce_client(source_p); |
490 |
|
} |
491 |
|
|
492 |
|
/* register_remote_user() |
493 |
|
* |
494 |
< |
* inputs - client_p directly connected client |
495 |
< |
* - source_p remote or directly connected client |
494 |
> |
* inputs - source_p remote or directly connected client |
495 |
|
* - username to register as |
496 |
|
* - host name to register as |
497 |
|
* - server name |
501 |
|
* is introduced by a server. |
502 |
|
*/ |
503 |
|
void |
504 |
< |
register_remote_user(struct Client *client_p, struct Client *source_p, |
504 |
> |
register_remote_user(struct Client *source_p, |
505 |
|
const char *username, const char *host, const char *server, |
506 |
|
const char *realname) |
507 |
|
{ |
511 |
|
assert(source_p->username != username); |
512 |
|
|
513 |
|
strlcpy(source_p->host, host, sizeof(source_p->host)); |
515 |
– |
strlcpy(source_p->info, realname, sizeof(source_p->info)); |
514 |
|
strlcpy(source_p->username, username, sizeof(source_p->username)); |
515 |
|
|
516 |
|
/* |
528 |
|
"No server %s for user %s[%s@%s] from %s", |
529 |
|
server, source_p->name, source_p->username, |
530 |
|
source_p->host, source_p->from->name); |
531 |
< |
kill_client(client_p, source_p, "%s (Server doesn't exist)", me.name); |
531 |
> |
kill_client(source_p->from, source_p, "%s (Server doesn't exist)", me.name); |
532 |
|
|
533 |
|
SetKilled(source_p); |
534 |
|
exit_client(source_p, &me, "Ghosted Client"); |
539 |
|
{ |
540 |
|
sendto_realops_flags(UMODE_DEBUG, L_ALL, |
541 |
|
"Bad User [%s] :%s USER %s@%s %s, != %s[%s]", |
542 |
< |
client_p->name, source_p->name, source_p->username, |
542 |
> |
source_p->from->name, source_p->name, source_p->username, |
543 |
|
source_p->host, source_p->servptr->name, |
544 |
|
target_p->name, target_p->from->name); |
545 |
< |
kill_client(client_p, source_p, |
545 |
> |
kill_client(source_p->from, source_p, |
546 |
|
"%s (NICK from wrong direction (%s != %s))", |
547 |
|
me.name, source_p->servptr->name, target_p->from->name); |
548 |
|
SetKilled(source_p); |
554 |
|
if (++Count.total > Count.max_tot) |
555 |
|
Count.max_tot = Count.total; |
556 |
|
|
559 |
– |
++source_p->from->serv->dep_users; |
560 |
– |
|
557 |
|
SetClient(source_p); |
558 |
< |
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users); |
558 |
> |
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list); |
559 |
|
add_user_host(source_p->username, source_p->host, 1); |
560 |
|
SetUserHost(source_p); |
561 |
|
|
562 |
< |
introduce_client(client_p, source_p); |
562 |
> |
introduce_client(source_p); |
563 |
|
} |
564 |
|
|
565 |
|
/* introduce_client() |
566 |
|
* |
567 |
< |
* inputs - client_p |
572 |
< |
* - source_p |
567 |
> |
* inputs - source_p |
568 |
|
* output - NONE |
569 |
|
* side effects - This common function introduces a client to the rest |
570 |
|
* of the net, either from a local client connect or |
571 |
|
* from a remote connect. |
572 |
|
*/ |
573 |
|
static void |
574 |
< |
introduce_client(struct Client *client_p, struct Client *source_p) |
574 |
> |
introduce_client(struct Client *source_p) |
575 |
|
{ |
576 |
|
dlink_node *server_node = NULL; |
577 |
|
static char ubuf[12]; |
581 |
|
else |
582 |
|
send_umode(NULL, source_p, 0, SEND_UMODES, ubuf); |
583 |
|
|
584 |
+ |
watch_check_hash(source_p, RPL_LOGON); |
585 |
+ |
|
586 |
|
if (*ubuf == '\0') |
587 |
|
{ |
588 |
|
ubuf[0] = '+'; |
589 |
|
ubuf[1] = '\0'; |
590 |
|
} |
591 |
|
|
592 |
< |
/* arghhh one could try not introducing new nicks to ll leafs |
596 |
< |
* but then you have to introduce them "on the fly" in SJOIN |
597 |
< |
* not fun. |
598 |
< |
* Its not going to cost much more bandwidth to simply let new |
599 |
< |
* nicks just ride on through. |
600 |
< |
*/ |
601 |
< |
|
602 |
< |
/* We now introduce nicks "on the fly" in SJOIN anyway -- |
603 |
< |
* you _need_ to if you aren't going to burst everyone initially. |
604 |
< |
* |
605 |
< |
* Only send to non CAP_LL servers, unless we're a lazylink leaf, |
606 |
< |
* in that case just send it to the uplink. |
607 |
< |
* -davidt |
608 |
< |
* rewritten to cope with SIDs .. eww eww eww --is |
609 |
< |
*/ |
610 |
< |
if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL) && |
611 |
< |
client_p != uplink) |
592 |
> |
DLINK_FOREACH(server_node, serv_list.head) |
593 |
|
{ |
594 |
< |
if (IsCapable(uplink, CAP_TS6) && HasID(source_p)) |
595 |
< |
{ |
596 |
< |
sendto_one(uplink, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
594 |
> |
struct Client *server = server_node->data; |
595 |
> |
|
596 |
> |
if (server == source_p->from) |
597 |
> |
continue; |
598 |
> |
|
599 |
> |
if (IsCapable(server, CAP_TS6) && HasID(source_p)) |
600 |
> |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
601 |
|
source_p->servptr->id, |
602 |
|
source_p->name, source_p->hopcount+1, |
603 |
|
(unsigned long)source_p->tsinfo, |
604 |
|
ubuf, source_p->username, source_p->host, |
605 |
|
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
606 |
|
"0" : source_p->sockhost, source_p->id, source_p->info); |
622 |
– |
} |
607 |
|
else |
608 |
< |
{ |
625 |
< |
sendto_one(uplink, "NICK %s %d %lu %s %s %s %s :%s", |
608 |
> |
sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s", |
609 |
|
source_p->name, source_p->hopcount+1, |
610 |
|
(unsigned long)source_p->tsinfo, |
611 |
|
ubuf, source_p->username, source_p->host, |
612 |
|
source_p->servptr->name, source_p->info); |
630 |
– |
} |
631 |
– |
} |
632 |
– |
else |
633 |
– |
{ |
634 |
– |
DLINK_FOREACH(server_node, serv_list.head) |
635 |
– |
{ |
636 |
– |
struct Client *server = server_node->data; |
637 |
– |
|
638 |
– |
if (IsCapable(server, CAP_LL) || server == client_p) |
639 |
– |
continue; |
640 |
– |
|
641 |
– |
if (IsCapable(server, CAP_TS6) && HasID(source_p)) |
642 |
– |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
643 |
– |
source_p->servptr->id, |
644 |
– |
source_p->name, source_p->hopcount+1, |
645 |
– |
(unsigned long)source_p->tsinfo, |
646 |
– |
ubuf, source_p->username, source_p->host, |
647 |
– |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
648 |
– |
"0" : source_p->sockhost, source_p->id, source_p->info); |
649 |
– |
else |
650 |
– |
sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s", |
651 |
– |
source_p->name, source_p->hopcount+1, |
652 |
– |
(unsigned long)source_p->tsinfo, |
653 |
– |
ubuf, source_p->username, source_p->host, |
654 |
– |
source_p->servptr->name, source_p->info); |
655 |
– |
} |
613 |
|
} |
614 |
|
} |
615 |
|
|
629 |
|
|
630 |
|
assert(p != NULL); |
631 |
|
|
632 |
< |
if ('.' == *p || ':' == *p) |
632 |
> |
if (*p == '.' || *p == ':') |
633 |
|
return 0; |
634 |
|
|
635 |
< |
while (*p) |
679 |
< |
{ |
635 |
> |
for (; *p; ++p) |
636 |
|
if (!IsHostChar(*p)) |
637 |
|
return 0; |
682 |
– |
p++; |
683 |
– |
} |
638 |
|
|
639 |
|
return 1; |
640 |
|
} |
658 |
|
|
659 |
|
assert(p != NULL); |
660 |
|
|
661 |
< |
if ('~' == *p) |
661 |
> |
if (*p == '~') |
662 |
|
++p; |
663 |
|
|
664 |
|
/* reject usernames that don't start with an alphanum |
672 |
|
{ |
673 |
|
if ((*p == '.') && ConfigFileEntry.dots_in_ident) |
674 |
|
{ |
675 |
< |
dots++; |
722 |
< |
|
723 |
< |
if (dots > ConfigFileEntry.dots_in_ident) |
675 |
> |
if (++dots > ConfigFileEntry.dots_in_ident) |
676 |
|
return 0; |
677 |
< |
if (!IsUserChar(p[1])) |
677 |
> |
if (!IsUserChar(*(p + 1))) |
678 |
|
return 0; |
679 |
|
} |
680 |
|
else if (!IsUserChar(*p)) |
763 |
|
* side effects - |
764 |
|
*/ |
765 |
|
void |
766 |
< |
do_local_user(const char *nick, struct Client *client_p, struct Client *source_p, |
766 |
> |
do_local_user(struct Client *source_p, |
767 |
|
const char *username, const char *host, const char *server, |
768 |
|
const char *realname) |
769 |
|
{ |
770 |
|
assert(source_p != NULL); |
771 |
|
assert(source_p->username != username); |
772 |
< |
|
821 |
< |
if (source_p == NULL) |
822 |
< |
return; |
823 |
< |
|
824 |
< |
if (!IsUnknown(source_p)) |
825 |
< |
{ |
826 |
< |
sendto_one(source_p, form_str(ERR_ALREADYREGISTRED), |
827 |
< |
me.name, nick); |
828 |
< |
return; |
829 |
< |
} |
772 |
> |
assert(IsUnknown(source_p)); |
773 |
|
|
774 |
|
source_p->localClient->registration &= ~REG_NEED_USER; |
775 |
|
|
780 |
|
|
781 |
|
strlcpy(source_p->info, realname, sizeof(source_p->info)); |
782 |
|
|
783 |
+ |
/* stash for later */ |
784 |
+ |
strlcpy(source_p->client_host, host, sizeof(source_p->client_host)); |
785 |
+ |
strlcpy(source_p->client_server, server, sizeof(source_p->client_server)); |
786 |
+ |
|
787 |
|
if (!IsGotId(source_p)) |
841 |
– |
{ |
842 |
– |
/* save the username in the client |
843 |
– |
* If you move this you'll break ping cookies..you've been warned |
844 |
– |
*/ |
788 |
|
strlcpy(source_p->username, username, sizeof(source_p->username)); |
846 |
– |
} |
789 |
|
|
790 |
|
if (!source_p->localClient->registration) |
791 |
< |
/* NICK already received, now I have USER... */ |
850 |
< |
register_local_user(client_p, source_p, source_p->name, username); |
791 |
> |
register_local_user(source_p); |
792 |
|
} |
793 |
|
|
794 |
|
/* change_simple_umode() |
799 |
|
static void * |
800 |
|
change_simple_umode(va_list args) |
801 |
|
{ |
802 |
+ |
struct Client *client_p; |
803 |
|
struct Client *source_p; |
804 |
|
int what; |
805 |
|
unsigned int flag; |
806 |
|
|
807 |
< |
va_arg(args, struct Client *); |
807 |
> |
client_p = va_arg(args, struct Client *); |
808 |
|
source_p = va_arg(args, struct Client *); |
809 |
|
what = va_arg(args, int); |
810 |
|
flag = va_arg(args, unsigned int); |
990 |
|
/* send_umode() |
991 |
|
* send the MODE string for user (user) to connection client_p |
992 |
|
* -avalon |
993 |
+ |
* |
994 |
+ |
* inputs - client_p |
995 |
+ |
* - source_p |
996 |
+ |
* - int old |
997 |
+ |
* - sendmask mask of modes to send |
998 |
+ |
* - suplied umode_buf |
999 |
+ |
* output - NONE |
1000 |
|
*/ |
1001 |
|
void |
1002 |
|
send_umode(struct Client *client_p, struct Client *source_p, |
1003 |
|
unsigned int old, unsigned int sendmask, char *umode_buf) |
1004 |
|
{ |
1005 |
+ |
char *m = umode_buf; |
1006 |
|
int what = 0; |
1007 |
|
unsigned int i; |
1008 |
|
unsigned int flag; |
1059 |
– |
char *m = umode_buf; |
1009 |
|
|
1010 |
|
/* |
1011 |
|
* build a string in umode_buf to represent the change in the user's |
1062 |
|
send_umode_out(struct Client *client_p, struct Client *source_p, |
1063 |
|
unsigned int old) |
1064 |
|
{ |
1065 |
< |
char buf[IRCD_BUFSIZE]; |
1065 |
> |
char buf[IRCD_BUFSIZE] = { '\0' }; |
1066 |
|
dlink_node *ptr = NULL; |
1067 |
|
|
1068 |
|
send_umode(NULL, source_p, old, IsOperHiddenAdmin(source_p) ? |
1069 |
|
SEND_UMODES & ~UMODE_ADMIN : SEND_UMODES, buf); |
1070 |
|
|
1071 |
< |
if (*buf) |
1071 |
> |
if (buf[0]) |
1072 |
|
{ |
1073 |
|
DLINK_FOREACH(ptr, serv_list.head) |
1074 |
|
{ |
1075 |
|
struct Client *target_p = ptr->data; |
1076 |
|
|
1077 |
|
if ((target_p != client_p) && (target_p != source_p)) |
1078 |
< |
{ |
1079 |
< |
if ((!(ServerInfo.hub && IsCapable(target_p, CAP_LL))) || |
1080 |
< |
(target_p->localClient->serverMask & |
1132 |
< |
source_p->lazyLinkClientExists)) |
1133 |
< |
sendto_one(target_p, ":%s MODE %s :%s", |
1134 |
< |
ID_or_name(source_p, target_p), |
1135 |
< |
ID_or_name(source_p, target_p), buf); |
1136 |
< |
} |
1078 |
> |
sendto_one(target_p, ":%s MODE %s :%s", |
1079 |
> |
ID_or_name(source_p, target_p), |
1080 |
> |
ID_or_name(source_p, target_p), buf); |
1081 |
|
} |
1082 |
|
} |
1083 |
|
|
1151 |
|
static int |
1152 |
|
check_xline(struct Client *source_p) |
1153 |
|
{ |
1154 |
< |
struct ConfItem *conf; |
1155 |
< |
struct MatchItem *xconf; |
1212 |
< |
const char *reason; |
1154 |
> |
struct ConfItem *conf = NULL; |
1155 |
> |
const char *reason = NULL; |
1156 |
|
|
1157 |
< |
if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info, |
1158 |
< |
NULL, NULL, 0)) != NULL) |
1157 |
> |
if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info, NULL, NULL, 0)) || |
1158 |
> |
(conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0))) |
1159 |
|
{ |
1160 |
< |
xconf = map_to_conf(conf); |
1161 |
< |
xconf->count++; |
1160 |
> |
struct MatchItem *reg = map_to_conf(conf); |
1161 |
> |
|
1162 |
> |
++reg->count; |
1163 |
|
|
1164 |
< |
if (xconf->reason != NULL) |
1165 |
< |
reason = xconf->reason; |
1164 |
> |
if (reg->reason != NULL) |
1165 |
> |
reason = reg->reason; |
1166 |
|
else |
1167 |
|
reason = "No Reason"; |
1168 |
|
|
1172 |
|
get_client_name(source_p, HIDE_IP), |
1173 |
|
source_p->sockhost); |
1174 |
|
|
1175 |
< |
ServerStats->is_ref++; |
1175 |
> |
++ServerStats.is_ref; |
1176 |
|
if (REJECT_HOLD_TIME > 0) |
1177 |
|
{ |
1178 |
|
sendto_one(source_p, ":%s NOTICE %s :Bad user info", |
1188 |
|
return 0; |
1189 |
|
} |
1190 |
|
|
1247 |
– |
static int |
1248 |
– |
check_regexp_xline(struct Client *source_p) |
1249 |
– |
{ |
1250 |
– |
struct ConfItem *conf = NULL; |
1251 |
– |
const char *reason = NULL; |
1252 |
– |
|
1253 |
– |
if ((conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0))) |
1254 |
– |
{ |
1255 |
– |
struct MatchItem *reg = map_to_conf(conf); |
1256 |
– |
|
1257 |
– |
++reg->count; |
1258 |
– |
|
1259 |
– |
if (reg->reason != NULL) |
1260 |
– |
reason = reg->reason; |
1261 |
– |
else |
1262 |
– |
reason = "No Reason"; |
1263 |
– |
|
1264 |
– |
sendto_realops_flags(UMODE_REJ, L_ALL, |
1265 |
– |
"X-line (REGEX) Rejecting [%s] [%s], user %s [%s]", |
1266 |
– |
source_p->info, reason, |
1267 |
– |
get_client_name(source_p, HIDE_IP), |
1268 |
– |
source_p->sockhost); |
1269 |
– |
|
1270 |
– |
ServerStats->is_ref++; |
1271 |
– |
exit_client(source_p, &me, "Bad user info"); |
1272 |
– |
return 1; |
1273 |
– |
} |
1274 |
– |
|
1275 |
– |
return 0; |
1276 |
– |
} |
1277 |
– |
|
1191 |
|
/* oper_up() |
1192 |
|
* |
1193 |
|
* inputs - pointer to given client to oper |
1217 |
|
source_p->umodes |= (UMODE_SERVNOTICE|UMODE_OPERWALL| |
1218 |
|
UMODE_WALLOP|UMODE_LOCOPS); |
1219 |
|
|
1220 |
+ |
if (!(old & UMODE_INVISIBLE) && IsInvisible(source_p)) |
1221 |
+ |
++Count.invisi; |
1222 |
+ |
if ((old & UMODE_INVISIBLE) && !IsInvisible(source_p)) |
1223 |
+ |
--Count.invisi; |
1224 |
+ |
|
1225 |
|
assert(dlinkFind(&oper_list, source_p) == NULL); |
1226 |
|
dlinkAdd(source_p, make_dlink_node(), &oper_list); |
1227 |
|
|
1243 |
|
send_message_file(source_p, &ConfigFileEntry.opermotd); |
1244 |
|
} |
1245 |
|
|
1246 |
< |
/* |
1247 |
< |
* Quick and dirty UID code for new proposed SID on EFnet |
1248 |
< |
* |
1249 |
< |
*/ |
1246 |
> |
static char new_uid[TOTALSIDUID + 1]; /* allow for \0 */ |
1247 |
> |
|
1248 |
> |
int |
1249 |
> |
valid_sid(const char *sid) |
1250 |
> |
{ |
1251 |
|
|
1252 |
< |
static char new_uid[TOTALSIDUID+1]; /* allow for \0 */ |
1253 |
< |
static void add_one_to_uid(int i); |
1252 |
> |
if (strlen(sid) == IRC_MAXSID) |
1253 |
> |
if (IsDigit(*sid)) |
1254 |
> |
if (IsAlNum(*(sid + 1)) && IsAlNum(*(sid + 2))) |
1255 |
> |
return 1; |
1256 |
> |
|
1257 |
> |
return 0; |
1258 |
> |
} |
1259 |
|
|
1260 |
|
/* |
1261 |
|
* init_uid() |
1275 |
|
|
1276 |
|
if (ServerInfo.sid != NULL) |
1277 |
|
{ |
1278 |
< |
memcpy(new_uid, ServerInfo.sid, IRCD_MIN(strlen(ServerInfo.sid), |
1279 |
< |
IRC_MAXSID)); |
1280 |
< |
memcpy(&me.id, ServerInfo.sid, IRCD_MIN(strlen(ServerInfo.sid), |
1357 |
< |
IRC_MAXSID)); |
1278 |
> |
strlcpy(new_uid, ServerInfo.sid, sizeof(new_uid)); |
1279 |
> |
strlcpy(me.id, ServerInfo.sid, sizeof(me.id)); |
1280 |
> |
|
1281 |
|
hash_add_id(&me); |
1282 |
|
} |
1283 |
|
|
1285 |
|
if (new_uid[i] == '\0') |
1286 |
|
new_uid[i] = 'A'; |
1287 |
|
|
1288 |
< |
/* XXX if IRC_MAXUID != 6, this will have to be rewritten */ |
1288 |
> |
/* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */ |
1289 |
|
/* Yes nenolod, I have known it was off by one ever since I wrote it |
1290 |
|
* But *JUST* for you, though, it really doesn't look as *pretty* |
1291 |
|
* -Dianora |
1292 |
|
*/ |
1293 |
< |
memcpy(new_uid+IRC_MAXSID, "AAAAA@", IRC_MAXUID); |
1293 |
> |
memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID); |
1294 |
|
|
1295 |
|
entering_umode_cb = register_callback("entering_umode", NULL); |
1296 |
|
umode_cb = register_callback("changing_umode", change_simple_umode); |
1374 |
– |
uid_get_cb = register_callback("uid_get", uid_get); |
1375 |
– |
} |
1376 |
– |
|
1377 |
– |
/* |
1378 |
– |
* uid_get |
1379 |
– |
* |
1380 |
– |
* inputs - struct Client * |
1381 |
– |
* output - new UID is returned to caller |
1382 |
– |
* side effects - new_uid is incremented by one. |
1383 |
– |
*/ |
1384 |
– |
static void * |
1385 |
– |
uid_get(va_list args) |
1386 |
– |
{ |
1387 |
– |
add_one_to_uid(TOTALSIDUID-1); /* index from 0 */ |
1388 |
– |
return ((void *) new_uid); |
1297 |
|
} |
1298 |
|
|
1299 |
|
/* |
1316 |
|
new_uid[i] = 'A'; |
1317 |
|
add_one_to_uid(i-1); |
1318 |
|
} |
1319 |
< |
else new_uid[i] = new_uid[i] + 1; |
1319 |
> |
else |
1320 |
> |
++new_uid[i]; |
1321 |
|
} |
1322 |
|
else |
1323 |
|
{ |
1324 |
< |
/* XXX if IRC_MAXUID != 6, this will have to be rewritten */ |
1324 |
> |
/* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */ |
1325 |
|
if (new_uid[i] == 'Z') |
1326 |
< |
memcpy(new_uid+IRC_MAXSID, "AAAAAA", IRC_MAXUID); |
1326 |
> |
memcpy(new_uid + IRC_MAXSID, "AAAAAA", IRC_MAXUID); |
1327 |
|
else |
1328 |
< |
new_uid[i] = new_uid[i] + 1; |
1328 |
> |
++new_uid[i]; |
1329 |
|
} |
1330 |
|
} |
1331 |
|
|
1332 |
|
/* |
1333 |
+ |
* uid_get |
1334 |
+ |
* |
1335 |
+ |
* inputs - struct Client * |
1336 |
+ |
* output - new UID is returned to caller |
1337 |
+ |
* side effects - new_uid is incremented by one. |
1338 |
+ |
*/ |
1339 |
+ |
static const char * |
1340 |
+ |
uid_get(void) |
1341 |
+ |
{ |
1342 |
+ |
add_one_to_uid(TOTALSIDUID - 1); /* index from 0 */ |
1343 |
+ |
return new_uid; |
1344 |
+ |
} |
1345 |
+ |
|
1346 |
+ |
/* |
1347 |
|
* init_isupport() |
1348 |
|
* |
1349 |
|
* input - NONE |
1357 |
|
|
1358 |
|
add_isupport("CALLERID", NULL, -1); |
1359 |
|
add_isupport("CASEMAPPING", CASEMAP, -1); |
1360 |
+ |
add_isupport("DEAF", "D", -1); |
1361 |
|
add_isupport("KICKLEN", NULL, KICKLEN); |
1362 |
|
add_isupport("MODES", NULL, MAXMODEPARAMS); |
1363 |
|
add_isupport("NICKLEN", NULL, NICKLEN-1); |