26 |
|
|
27 |
|
#include "stdinc.h" |
28 |
|
#include "list.h" |
29 |
< |
#include "s_user.h" |
30 |
< |
#include "s_misc.h" |
29 |
> |
#include "user.h" |
30 |
|
#include "channel.h" |
31 |
|
#include "channel_mode.h" |
32 |
|
#include "client.h" |
38 |
|
#include "numeric.h" |
39 |
|
#include "conf.h" |
40 |
|
#include "log.h" |
41 |
< |
#include "s_serv.h" |
41 |
> |
#include "server.h" |
42 |
|
#include "send.h" |
43 |
|
#include "supported.h" |
44 |
|
#include "memory.h" |
45 |
|
#include "packet.h" |
46 |
|
#include "rng_mt.h" |
47 |
|
#include "userhost.h" |
48 |
< |
#include "s_misc.h" |
48 |
> |
#include "misc.h" |
49 |
|
#include "parse.h" |
50 |
|
#include "watch.h" |
51 |
|
|
117 |
|
0, /* m */ |
118 |
|
UMODE_NCHANGE, /* n */ |
119 |
|
UMODE_OPER, /* o */ |
120 |
< |
0, /* p */ |
121 |
< |
0, /* q */ |
120 |
> |
UMODE_HIDECHANS, /* p */ |
121 |
> |
UMODE_HIDEIDLE, /* q */ |
122 |
|
UMODE_REGISTERED, /* r */ |
123 |
|
UMODE_SERVNOTICE, /* s */ |
124 |
|
0, /* t */ |
167 |
|
Count.invisi, dlink_list_length(&global_serv_list)); |
168 |
|
else |
169 |
|
sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT, |
170 |
< |
(Count.total-Count.invisi), Count.invisi, 1); |
170 |
> |
(Count.total - Count.invisi), Count.invisi, 1); |
171 |
|
|
172 |
< |
if (Count.oper > 0) |
172 |
> |
if (Count.oper) |
173 |
|
sendto_one_numeric(source_p, &me, RPL_LUSEROP, Count.oper); |
174 |
|
|
175 |
< |
if (dlink_list_length(&unknown_list) > 0) |
175 |
> |
if (dlink_list_length(&unknown_list)) |
176 |
|
sendto_one_numeric(source_p, &me, RPL_LUSERUNKNOWN, dlink_list_length(&unknown_list)); |
177 |
|
|
178 |
< |
if (dlink_list_length(&global_channel_list) > 0) |
178 |
> |
if (dlink_list_length(&global_channel_list)) |
179 |
|
sendto_one_numeric(source_p, &me, RPL_LUSERCHANNELS, dlink_list_length(&global_channel_list)); |
180 |
|
|
181 |
|
if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) |
403 |
|
return 0; |
404 |
|
} |
405 |
|
|
406 |
< |
/* |
408 |
< |
* register_local_user |
409 |
< |
* This function is called when both NICK and USER messages |
406 |
> |
/*! \brief This function is called when both NICK and USER messages |
407 |
|
* have been accepted for the client, in whatever order. Only |
408 |
|
* after this, is the UID message propagated. |
409 |
< |
* |
413 |
< |
* 1) user telnets in and gives only "NICK foobar" and waits |
414 |
< |
* 2) another user far away logs in normally with the nick |
415 |
< |
* "foobar" (quite legal, as this server didn't propagate |
416 |
< |
* it). |
417 |
< |
* 3) now this server gets nick "foobar" from outside, but |
418 |
< |
* has alread the same defined locally. Current server |
419 |
< |
* would just issue "KILL foobar" to clean out dups. But, |
420 |
< |
* this is not fair. It should actually request another |
421 |
< |
* nick from local user or kill him/her... |
409 |
> |
* \param source_p Pointer to given client to introduce |
410 |
|
*/ |
411 |
|
void |
412 |
|
register_local_user(struct Client *source_p) |
482 |
|
source_p->username[i] = '\0'; |
483 |
|
} |
484 |
|
|
485 |
< |
/* password check */ |
485 |
> |
/* Password check */ |
486 |
|
if (!EmptyString(conf->passwd)) |
487 |
|
{ |
488 |
< |
const char *pass = source_p->localClient->passwd; |
501 |
< |
|
502 |
< |
if (!match_conf_password(pass, conf)) |
488 |
> |
if (!match_conf_password(source_p->localClient->passwd, conf)) |
489 |
|
{ |
490 |
|
++ServerStats.is_ref; |
491 |
|
|
495 |
|
} |
496 |
|
} |
497 |
|
|
498 |
< |
/* don't free source_p->localClient->passwd here - it can be required |
498 |
> |
/* |
499 |
> |
* Don't free source_p->localClient->passwd here - it can be required |
500 |
|
* by masked /stats I if there are auth{} blocks with need_password = no; |
501 |
|
* --adx |
502 |
|
*/ |
503 |
|
|
504 |
< |
/* report if user has &^>= etc. and set flags as needed in source_p */ |
504 |
> |
/* |
505 |
> |
* Report if user has &^>= etc. and set flags as needed in source_p |
506 |
> |
*/ |
507 |
|
report_and_set_user_flags(source_p, conf); |
508 |
|
|
509 |
|
if (IsDead(source_p)) |
510 |
|
return; |
511 |
|
|
512 |
< |
/* Limit clients - |
512 |
> |
/* |
513 |
> |
* Limit clients - |
514 |
|
* We want to be able to have servers and F-line clients |
515 |
|
* connect, so save room for "buffer" connections. |
516 |
|
* Smaller servers may want to decrease this, and it should |
517 |
|
* probably be just a percentage of the MAXCLIENTS... |
518 |
|
* -Taner |
519 |
|
*/ |
530 |
– |
/* Except "F:" clients */ |
520 |
|
if ((Count.local >= ServerInfo.max_clients + MAX_BUFFER) || |
521 |
|
(Count.local >= ServerInfo.max_clients && !IsExemptLimits(source_p))) |
522 |
|
{ |
528 |
|
return; |
529 |
|
} |
530 |
|
|
542 |
– |
/* valid user name check */ |
531 |
|
if (!valid_username(source_p->username, 1)) |
532 |
|
{ |
533 |
< |
char tmpstr2[IRCD_BUFSIZE] = ""; |
533 |
> |
char buf[IRCD_BUFSIZE] = ""; |
534 |
|
|
535 |
|
sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE, |
536 |
|
"Invalid username: %s (%s@%s)", |
537 |
|
source_p->name, source_p->username, source_p->host); |
538 |
|
++ServerStats.is_ref; |
539 |
< |
snprintf(tmpstr2, sizeof(tmpstr2), "Invalid username [%s]", |
540 |
< |
source_p->username); |
553 |
< |
exit_client(source_p, tmpstr2); |
539 |
> |
snprintf(buf, sizeof(buf), "Invalid username [%s]", source_p->username); |
540 |
> |
exit_client(source_p, buf); |
541 |
|
return; |
542 |
|
} |
543 |
|
|
574 |
|
Count.max_loc); |
575 |
|
} |
576 |
|
|
590 |
– |
/* Increment our total user count here */ |
577 |
|
if (++Count.total > Count.max_tot) |
578 |
|
Count.max_tot = Count.total; |
579 |
|
++Count.totalrestartcount; |
582 |
|
SetClient(source_p); |
583 |
|
dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list); |
584 |
|
|
599 |
– |
source_p->localClient->allow_read = MAX_FLOOD_BURST; |
600 |
– |
|
585 |
|
assert(dlinkFind(&unknown_list, source_p)); |
586 |
|
|
587 |
|
dlink_move_node(&source_p->localClient->lclient_node, |
616 |
|
strlcpy(source_p->username, username, sizeof(source_p->username)); |
617 |
|
|
618 |
|
/* |
619 |
< |
* coming from another server, take the servers word for it |
619 |
> |
* Coming from another server, take the servers word for it |
620 |
|
*/ |
621 |
|
source_p->servptr = hash_find_server(server); |
622 |
|
|
664 |
|
if (HasFlag(source_p->servptr, FLAGS_SERVICE)) |
665 |
|
AddFlag(source_p, FLAGS_SERVICE); |
666 |
|
|
683 |
– |
/* Increment our total user count here */ |
667 |
|
if (++Count.total > Count.max_tot) |
668 |
|
Count.max_tot = Count.total; |
669 |
|
|
742 |
|
{ |
743 |
|
while (*++p) |
744 |
|
{ |
745 |
< |
if ((*p == '.') && ConfigFileEntry.dots_in_ident) |
745 |
> |
if (*p == '.' && ConfigFileEntry.dots_in_ident) |
746 |
|
{ |
747 |
|
if (++dots > ConfigFileEntry.dots_in_ident) |
748 |
|
return 0; |
774 |
|
valid_nickname(const char *nickname, const int local) |
775 |
|
{ |
776 |
|
const char *p = nickname; |
794 |
– |
assert(nickname && *nickname); |
777 |
|
|
778 |
< |
assert(p); |
778 |
> |
assert(nickname && *nickname); |
779 |
|
|
780 |
< |
/* nicks can't start with a digit or - or be 0 length */ |
781 |
< |
/* This closer duplicates behaviour of hybrid-6 */ |
780 |
> |
/* |
781 |
> |
* Nicks can't start with a digit or - or be 0 length. |
782 |
> |
*/ |
783 |
|
if (*p == '-' || (IsDigit(*p) && local) || *p == '\0') |
784 |
|
return 0; |
785 |
|
|
807 |
|
{ |
808 |
|
char *m = umode_buf; |
809 |
|
int what = 0; |
827 |
– |
unsigned int i; |
828 |
– |
unsigned int flag; |
810 |
|
|
811 |
|
/* |
812 |
< |
* build a string in umode_buf to represent the change in the user's |
812 |
> |
* Build a string in umode_buf to represent the change in the user's |
813 |
|
* mode between the new (source_p->umodes) and 'old'. |
814 |
|
*/ |
815 |
< |
for (i = 0; i < 128; ++i) |
815 |
> |
for (unsigned int i = 0; i < 128; ++i) |
816 |
|
{ |
817 |
< |
flag = user_modes[i]; |
817 |
> |
unsigned int flag = user_modes[i]; |
818 |
> |
|
819 |
|
if (!flag) |
820 |
|
continue; |
821 |
|
|
964 |
|
target_p->host, target_p->away); |
965 |
|
} |
966 |
|
|
967 |
< |
/* oper_up() |
968 |
< |
* |
969 |
< |
* inputs - pointer to given client to oper |
988 |
< |
* output - NONE |
989 |
< |
* side effects - Blindly opers up given source_p, using conf info |
990 |
< |
* all checks on passwords have already been done. |
991 |
< |
* This could also be used by rsa oper routines. |
967 |
> |
/*! \brief Blindly opers up given source_p, using conf info. |
968 |
> |
* All checks on passwords have already been done. |
969 |
> |
* \param source_p Pointer to given client to oper |
970 |
|
*/ |
971 |
|
void |
972 |
|
oper_up(struct Client *source_p) |
1003 |
|
sendto_one_numeric(source_p, &me, RPL_YOUREOPER); |
1004 |
|
} |
1005 |
|
|
1006 |
< |
static char new_uid[TOTALSIDUID + 1]; /* allow for \0 */ |
1006 |
> |
static char new_uid[TOTALSIDUID + 1]; /* Allow for \0 */ |
1007 |
|
|
1008 |
|
int |
1009 |
|
valid_sid(const char *sid) |
1050 |
|
* note this is a recursive function |
1051 |
|
*/ |
1052 |
|
static void |
1053 |
< |
add_one_to_uid(int i) |
1053 |
> |
add_one_to_uid(unsigned int i) |
1054 |
|
{ |
1055 |
< |
if (i != IRC_MAXSID) /* Not reached server SID portion yet? */ |
1055 |
> |
if (i != IRC_MAXSID) /* Not reached server SID portion yet? */ |
1056 |
|
{ |
1057 |
|
if (new_uid[i] == 'Z') |
1058 |
|
new_uid[i] = '0'; |
1059 |
|
else if (new_uid[i] == '9') |
1060 |
|
{ |
1061 |
|
new_uid[i] = 'A'; |
1062 |
< |
add_one_to_uid(i-1); |
1062 |
> |
add_one_to_uid(i - 1); |
1063 |
|
} |
1064 |
|
else |
1065 |
|
++new_uid[i]; |
1084 |
|
static const char * |
1085 |
|
uid_get(void) |
1086 |
|
{ |
1087 |
< |
add_one_to_uid(TOTALSIDUID - 1); /* index from 0 */ |
1087 |
> |
add_one_to_uid(TOTALSIDUID - 1); /* Index from 0 */ |
1088 |
|
return new_uid; |
1089 |
|
} |
1090 |
|
|
1142 |
|
|
1143 |
|
if (ptr == NULL) |
1144 |
|
{ |
1145 |
< |
support = MyMalloc(sizeof(*support)); |
1145 |
> |
support = MyCalloc(sizeof(*support)); |
1146 |
|
dlinkAddTail(support, &support->node, &support_list); |
1147 |
|
} |
1148 |
|
|
1149 |
|
support->name = xstrdup(name); |
1150 |
< |
if (options != NULL) |
1150 |
> |
if (options) |
1151 |
|
support->options = xstrdup(options); |
1152 |
|
support->number = n; |
1153 |
|
|
1215 |
|
p += (n = sprintf(p, "%s", support->name)); |
1216 |
|
len += n; |
1217 |
|
|
1218 |
< |
if (support->options != NULL) |
1218 |
> |
if (support->options) |
1219 |
|
{ |
1220 |
|
p += (n = sprintf(p, "=%s", support->options)); |
1221 |
|
len += n; |
1243 |
|
} |
1244 |
|
} |
1245 |
|
|
1246 |
< |
if (len != 0) |
1246 |
> |
if (len) |
1247 |
|
{ |
1248 |
|
if (*--p == ' ') |
1249 |
|
*p = '\0'; |