1 |
|
/* |
2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
< |
* s_user.c: User related functions. |
2 |
> |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
4 |
> |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
|
* USA |
20 |
< |
* |
21 |
< |
* $Id$ |
20 |
> |
*/ |
21 |
> |
|
22 |
> |
/*! \file s_user.c |
23 |
> |
* \brief User related functions. |
24 |
> |
* \version $Id$ |
25 |
|
*/ |
26 |
|
|
27 |
|
#include "stdinc.h" |
31 |
|
#include "channel.h" |
32 |
|
#include "channel_mode.h" |
33 |
|
#include "client.h" |
32 |
– |
#include "fdlist.h" |
34 |
|
#include "hash.h" |
35 |
|
#include "irc_string.h" |
35 |
– |
#include "s_bsd.h" |
36 |
|
#include "ircd.h" |
37 |
|
#include "listener.h" |
38 |
|
#include "motd.h" |
42 |
|
#include "s_serv.h" |
43 |
|
#include "send.h" |
44 |
|
#include "supported.h" |
45 |
– |
#include "whowas.h" |
45 |
|
#include "memory.h" |
46 |
|
#include "packet.h" |
47 |
|
#include "rng_mt.h" |
48 |
|
#include "userhost.h" |
50 |
– |
#include "hook.h" |
49 |
|
#include "s_misc.h" |
50 |
|
#include "parse.h" |
51 |
|
#include "watch.h" |
169 |
|
void |
170 |
|
show_lusers(struct Client *source_p) |
171 |
|
{ |
174 |
– |
const char *from, *to; |
175 |
– |
|
176 |
– |
if (!MyConnect(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p)) |
177 |
– |
{ |
178 |
– |
from = me.id; |
179 |
– |
to = source_p->id; |
180 |
– |
} |
181 |
– |
else |
182 |
– |
{ |
183 |
– |
from = me.name; |
184 |
– |
to = source_p->name; |
185 |
– |
} |
186 |
– |
|
172 |
|
if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) |
173 |
< |
sendto_one(source_p, form_str(RPL_LUSERCLIENT), |
174 |
< |
from, to, (Count.total-Count.invisi), |
190 |
< |
Count.invisi, dlink_list_length(&global_serv_list)); |
173 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT, (Count.total-Count.invisi), |
174 |
> |
Count.invisi, dlink_list_length(&global_serv_list)); |
175 |
|
else |
176 |
< |
sendto_one(source_p, form_str(RPL_LUSERCLIENT), from, to, |
177 |
< |
(Count.total-Count.invisi), Count.invisi, 1); |
176 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT, |
177 |
> |
(Count.total-Count.invisi), Count.invisi, 1); |
178 |
|
|
179 |
|
if (Count.oper > 0) |
180 |
< |
sendto_one(source_p, form_str(RPL_LUSEROP), |
197 |
< |
from, to, Count.oper); |
180 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSEROP, Count.oper); |
181 |
|
|
182 |
|
if (dlink_list_length(&unknown_list) > 0) |
183 |
< |
sendto_one(source_p, form_str(RPL_LUSERUNKNOWN), |
201 |
< |
from, to, dlink_list_length(&unknown_list)); |
183 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSERUNKNOWN, dlink_list_length(&unknown_list)); |
184 |
|
|
185 |
|
if (dlink_list_length(&global_channel_list) > 0) |
186 |
< |
sendto_one(source_p, form_str(RPL_LUSERCHANNELS), |
205 |
< |
from, to, dlink_list_length(&global_channel_list)); |
186 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSERCHANNELS, dlink_list_length(&global_channel_list)); |
187 |
|
|
188 |
|
if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) |
189 |
|
{ |
190 |
< |
sendto_one(source_p, form_str(RPL_LUSERME), |
191 |
< |
from, to, Count.local, Count.myserver); |
211 |
< |
sendto_one(source_p, form_str(RPL_LOCALUSERS), |
212 |
< |
from, to, Count.local, Count.max_loc); |
190 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSERME, Count.local, Count.myserver); |
191 |
> |
sendto_one_numeric(source_p, &me, RPL_LOCALUSERS, Count.local, Count.max_loc); |
192 |
|
} |
193 |
|
else |
194 |
|
{ |
195 |
< |
sendto_one(source_p, form_str(RPL_LUSERME), |
196 |
< |
from, to, Count.total, 0); |
218 |
< |
sendto_one(source_p, form_str(RPL_LOCALUSERS), |
219 |
< |
from, to, Count.total, Count.max_tot); |
195 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSERME, Count.total, 0); |
196 |
> |
sendto_one_numeric(source_p, &me, RPL_LOCALUSERS, Count.total, Count.max_tot); |
197 |
|
} |
198 |
|
|
199 |
< |
sendto_one(source_p, form_str(RPL_GLOBALUSERS), |
223 |
< |
from, to, Count.total, Count.max_tot); |
199 |
> |
sendto_one_numeric(source_p, &me, RPL_GLOBALUSERS, Count.total, Count.max_tot); |
200 |
|
|
201 |
|
if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) |
202 |
< |
sendto_one(source_p, form_str(RPL_STATSCONN), from, to, |
203 |
< |
Count.max_loc_con, Count.max_loc_cli, Count.totalrestartcount); |
202 |
> |
sendto_one_numeric(source_p, &me, RPL_STATSCONN, Count.max_loc_con, |
203 |
> |
Count.max_loc_cli, Count.totalrestartcount); |
204 |
|
|
205 |
|
if (Count.local > Count.max_loc_cli) |
206 |
|
Count.max_loc_cli = Count.local; |
221 |
|
const dlink_node *ptr = NULL; |
222 |
|
|
223 |
|
DLINK_FOREACH(ptr, support_list_lines.head) |
224 |
< |
sendto_one(source_p, form_str(RPL_ISUPPORT), me.name, |
249 |
< |
source_p->name, ptr->data); |
224 |
> |
sendto_one_numeric(source_p, &me, RPL_ISUPPORT, ptr->data); |
225 |
|
} |
226 |
|
|
227 |
|
/* |
287 |
|
|
288 |
|
if (!valid_hostname(source_p->host)) |
289 |
|
{ |
290 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You have an illegal " |
291 |
< |
"character in your hostname", me.name, source_p->name); |
290 |
> |
sendto_one_notice(source_p, &me, ":*** Notice -- You have an illegal " |
291 |
> |
"character in your hostname"); |
292 |
|
strlcpy(source_p->host, source_p->sockhost, |
293 |
|
sizeof(source_p->host)); |
294 |
|
} |
304 |
|
if (IsNeedIdentd(conf)) |
305 |
|
{ |
306 |
|
++ServerStats.is_ref; |
307 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install " |
308 |
< |
"identd to use this server", me.name, source_p->name); |
307 |
> |
sendto_one_notice(source_p, &me, ":*** Notice -- You need to install " |
308 |
> |
"identd to use this server"); |
309 |
|
exit_client(source_p, &me, "Install identd"); |
310 |
|
return; |
311 |
|
} |
330 |
|
if (!match_conf_password(pass, conf)) |
331 |
|
{ |
332 |
|
++ServerStats.is_ref; |
333 |
< |
sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), |
334 |
< |
me.name, source_p->name); |
333 |
> |
|
334 |
> |
sendto_one_numeric(source_p, &me, ERR_PASSWDMISMATCH); |
335 |
|
exit_client(source_p, &me, "Bad Password"); |
336 |
|
return; |
337 |
|
} |
444 |
|
* - username to register as |
445 |
|
* - host name to register as |
446 |
|
* - server name |
472 |
– |
* - realname (gecos) |
447 |
|
* output - NONE |
448 |
|
* side effects - This function is called when a remote client |
449 |
|
* is introduced by a server. |
450 |
|
*/ |
451 |
|
void |
452 |
< |
register_remote_user(struct Client *source_p, |
453 |
< |
const char *username, const char *host, const char *server, |
480 |
< |
const char *realname) |
452 |
> |
register_remote_user(struct Client *source_p, const char *username, |
453 |
> |
const char *host, const char *server) |
454 |
|
{ |
455 |
|
struct Client *target_p = NULL; |
456 |
|
|
536 |
|
introduce_client(struct Client *source_p) |
537 |
|
{ |
538 |
|
dlink_node *server_node = NULL; |
539 |
< |
char ubuf[66]; |
539 |
> |
char ubuf[IRCD_BUFSIZE]; |
540 |
|
|
541 |
|
if (MyClient(source_p)) |
542 |
|
send_umode(source_p, source_p, 0, SEND_UMODES, ubuf); |
559 |
|
continue; |
560 |
|
|
561 |
|
if (IsCapable(server, CAP_SVS)) |
562 |
< |
{ |
563 |
< |
if (IsCapable(server, CAP_TS6) && HasID(source_p)) |
564 |
< |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s %s :%s", |
565 |
< |
source_p->servptr->id, |
566 |
< |
source_p->name, source_p->hopcount+1, |
567 |
< |
(unsigned long)source_p->tsinfo, |
568 |
< |
ubuf, source_p->username, source_p->host, |
569 |
< |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
570 |
< |
"0" : source_p->sockhost, source_p->id, |
598 |
< |
source_p->svid, |
599 |
< |
source_p->info); |
600 |
< |
else |
601 |
< |
sendto_one(server, "NICK %s %d %lu %s %s %s %s %s :%s", |
602 |
< |
source_p->name, source_p->hopcount+1, |
603 |
< |
(unsigned long)source_p->tsinfo, |
604 |
< |
ubuf, source_p->username, source_p->host, |
605 |
< |
source_p->servptr->name, source_p->svid, |
606 |
< |
source_p->info); |
607 |
< |
|
608 |
< |
} |
562 |
> |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s %s :%s", |
563 |
> |
source_p->servptr->id, |
564 |
> |
source_p->name, source_p->hopcount+1, |
565 |
> |
(unsigned long)source_p->tsinfo, |
566 |
> |
ubuf, source_p->username, source_p->host, |
567 |
> |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
568 |
> |
"0" : source_p->sockhost, source_p->id, |
569 |
> |
source_p->svid, |
570 |
> |
source_p->info); |
571 |
|
else |
572 |
< |
{ |
573 |
< |
if (IsCapable(server, CAP_TS6) && HasID(source_p)) |
574 |
< |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
575 |
< |
source_p->servptr->id, |
576 |
< |
source_p->name, source_p->hopcount+1, |
577 |
< |
(unsigned long)source_p->tsinfo, |
578 |
< |
ubuf, source_p->username, source_p->host, |
617 |
< |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
618 |
< |
"0" : source_p->sockhost, source_p->id, source_p->info); |
619 |
< |
else |
620 |
< |
sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s", |
621 |
< |
source_p->name, source_p->hopcount+1, |
622 |
< |
(unsigned long)source_p->tsinfo, |
623 |
< |
ubuf, source_p->username, source_p->host, |
624 |
< |
source_p->servptr->name, source_p->info); |
625 |
< |
} |
572 |
> |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
573 |
> |
source_p->servptr->id, |
574 |
> |
source_p->name, source_p->hopcount+1, |
575 |
> |
(unsigned long)source_p->tsinfo, |
576 |
> |
ubuf, source_p->username, source_p->host, |
577 |
> |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
578 |
> |
"0" : source_p->sockhost, source_p->id, source_p->info); |
579 |
|
|
580 |
|
if (!EmptyString(source_p->certfp)) |
581 |
|
sendto_one(server, ":%s CERTFP %s", ID(source_p), source_p->certfp); |
701 |
|
{ |
702 |
|
/* If this user is being spoofed, tell them so */ |
703 |
|
if (IsConfDoSpoofIp(conf)) |
704 |
< |
sendto_one(source_p, |
752 |
< |
":%s NOTICE %s :*** Spoofing your IP. Congrats.", |
753 |
< |
me.name, source_p->name); |
704 |
> |
sendto_one_notice(source_p, &me, ":*** Spoofing your IP. Congrats."); |
705 |
|
|
706 |
|
/* If this user is in the exception class, Set it "E lined" */ |
707 |
|
if (IsConfExemptKline(conf)) |
708 |
|
{ |
709 |
|
SetExemptKline(source_p); |
710 |
< |
sendto_one(source_p, |
760 |
< |
":%s NOTICE %s :*** You are exempt from K/D/G lines. Congrats.", |
761 |
< |
me.name, source_p->name); |
710 |
> |
sendto_one_notice(source_p, &me, ":*** You are exempt from K/D/G lines. Congrats."); |
711 |
|
} |
712 |
|
|
713 |
|
/* |
717 |
|
else if (IsConfExemptGline(conf)) |
718 |
|
{ |
719 |
|
SetExemptGline(source_p); |
720 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from G lines. Congrats.", |
772 |
< |
me.name, source_p->name); |
720 |
> |
sendto_one_notice(source_p, &me, ":*** You are exempt from G lines. Congrats."); |
721 |
|
} |
722 |
|
|
723 |
|
if (IsConfExemptResv(conf)) |
724 |
|
{ |
725 |
|
SetExemptResv(source_p); |
726 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from resvs. Congrats.", |
779 |
< |
me.name, source_p->name); |
726 |
> |
sendto_one_notice(source_p, &me, ":*** You are exempt from resvs. Congrats."); |
727 |
|
} |
728 |
|
|
729 |
|
/* If this user is exempt from user limits set it "F lined" */ |
730 |
|
if (IsConfExemptLimits(conf)) |
731 |
|
{ |
732 |
|
SetExemptLimits(source_p); |
733 |
< |
sendto_one(source_p, |
787 |
< |
":%s NOTICE %s :*** You are exempt from user limits. Congrats.", |
788 |
< |
me.name,source_p->name); |
733 |
> |
sendto_one_notice(source_p, &me, ":*** You are exempt from user limits. Congrats."); |
734 |
|
} |
735 |
|
|
736 |
|
if (IsConfCanFlood(conf)) |
737 |
|
{ |
738 |
|
SetCanFlood(source_p); |
739 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from flood " |
740 |
< |
"protection, aren't you fearsome.", |
796 |
< |
me.name, source_p->name); |
739 |
> |
sendto_one_notice(source_p, &me, ":*** You are exempt from flood " |
740 |
> |
"protection, aren't you fearsome."); |
741 |
|
} |
742 |
|
} |
743 |
|
|
762 |
|
if ((target_p = find_person(client_p, parv[1])) == NULL) |
763 |
|
{ |
764 |
|
if (MyConnect(source_p)) |
765 |
< |
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), |
822 |
< |
me.name, source_p->name, parv[1]); |
765 |
> |
sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, parv[1]); |
766 |
|
return; |
767 |
|
} |
768 |
|
|
769 |
|
if (source_p != target_p) |
770 |
|
{ |
771 |
< |
sendto_one(source_p, form_str(ERR_USERSDONTMATCH), |
829 |
< |
me.name, source_p->name); |
771 |
> |
sendto_one_numeric(source_p, &me, ERR_USERSDONTMATCH); |
772 |
|
return; |
773 |
|
} |
774 |
|
|
782 |
|
*m++ = (char)i; |
783 |
|
*m = '\0'; |
784 |
|
|
785 |
< |
sendto_one(source_p, form_str(RPL_UMODEIS), |
844 |
< |
me.name, source_p->name, buf); |
785 |
> |
sendto_one_numeric(source_p, &me, RPL_UMODEIS, buf); |
786 |
|
return; |
787 |
|
} |
788 |
|
|
863 |
|
} |
864 |
|
|
865 |
|
if (badflag) |
866 |
< |
sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG), |
926 |
< |
me.name, source_p->name); |
866 |
> |
sendto_one_numeric(source_p, &me, ERR_UMODEUNKNOWNFLAG); |
867 |
|
|
868 |
|
if (MyConnect(source_p) && HasUMode(source_p, UMODE_ADMIN) && |
869 |
|
!HasOFlag(source_p, OPER_FLAG_ADMIN)) |
870 |
|
{ |
871 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;", |
932 |
< |
me.name, source_p->name); |
871 |
> |
sendto_one_notice(source_p, &me, ":*** You have no admin flag;"); |
872 |
|
DelUMode(source_p, UMODE_ADMIN); |
873 |
|
} |
874 |
|
|
1018 |
|
|
1019 |
|
if (MyClient(target_p)) |
1020 |
|
{ |
1021 |
< |
sendto_one(target_p, form_str(RPL_NEWHOSTIS), me.name, |
1083 |
< |
target_p->name, target_p->host); |
1021 |
> |
sendto_one_numeric(target_p, &me, RPL_NEWHOSTIS, target_p->host); |
1022 |
|
clear_ban_cache_client(target_p); |
1023 |
|
} |
1024 |
|
|
1088 |
|
if (HasFlag(source_p, FLAGS_SSL)) |
1089 |
|
{ |
1090 |
|
AddUMode(source_p, UMODE_SSL); |
1091 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** Connected securely via %s", |
1092 |
< |
me.name, source_p->name, |
1155 |
< |
ssl_get_cipher(source_p->localClient->fd.ssl)); |
1091 |
> |
sendto_one_notice(source_p, &me, ":*** Connected securely via %s", |
1092 |
> |
ssl_get_cipher(source_p->localClient->fd.ssl)); |
1093 |
|
} |
1094 |
|
#endif |
1095 |
|
|
1096 |
< |
sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name, |
1097 |
< |
ServerInfo.network_name, source_p->name); |
1098 |
< |
sendto_one(source_p, form_str(RPL_YOURHOST), me.name, source_p->name, |
1099 |
< |
get_listener_name(source_p->localClient->listener), ircd_version); |
1100 |
< |
sendto_one(source_p, form_str(RPL_CREATED), |
1101 |
< |
me.name, source_p->name, built_date); |
1165 |
< |
sendto_one(source_p, form_str(RPL_MYINFO), |
1166 |
< |
me.name, source_p->name, me.name, ircd_version, umode_buffer); |
1096 |
> |
sendto_one_numeric(source_p, &me, RPL_WELCOME, ServerInfo.network_name, |
1097 |
> |
source_p->name); |
1098 |
> |
sendto_one_numeric(source_p, &me, RPL_YOURHOST, |
1099 |
> |
get_listener_name(source_p->localClient->listener), ircd_version); |
1100 |
> |
sendto_one_numeric(source_p, &me, RPL_CREATED, built_date); |
1101 |
> |
sendto_one_numeric(source_p, &me, RPL_MYINFO, me.name, ircd_version, umode_buffer); |
1102 |
|
show_isupport(source_p); |
1103 |
|
|
1104 |
|
if (source_p->id[0] != '\0') |
1105 |
< |
sendto_one(source_p, form_str(RPL_YOURID), me.name, |
1171 |
< |
source_p->name, source_p->id); |
1105 |
> |
sendto_one_numeric(source_p, &me, RPL_YOURID, source_p->id); |
1106 |
|
|
1107 |
|
show_lusers(source_p); |
1108 |
|
motd_signon(source_p); |
1183 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s is now an operator", |
1184 |
|
get_oper_name(source_p)); |
1185 |
|
send_umode_out(source_p, source_p, old); |
1186 |
< |
sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name); |
1186 |
> |
sendto_one_numeric(source_p, &me, RPL_YOUREOPER); |
1187 |
|
} |
1188 |
|
|
1189 |
|
static char new_uid[TOTALSIDUID + 1]; /* allow for \0 */ |
1384 |
|
int n = 0; |
1385 |
|
int tokens = 0; |
1386 |
|
size_t len = 0; |
1387 |
< |
size_t reserve = strlen(me.name) + HOSTLEN + strlen(form_str(RPL_ISUPPORT)); |
1387 |
> |
size_t reserve = strlen(me.name) + HOSTLEN + strlen(numeric_form(RPL_ISUPPORT)); |
1388 |
|
|
1389 |
|
DLINK_FOREACH_SAFE(ptr, ptr_next, support_list_lines.head) |
1390 |
|
{ |