32 |
|
#include "fdlist.h" |
33 |
|
#include "hash.h" |
34 |
|
#include "irc_string.h" |
35 |
– |
#include "sprintf_irc.h" |
35 |
|
#include "s_bsd.h" |
36 |
|
#include "ircd.h" |
37 |
|
#include "listener.h" |
53 |
|
#include "watch.h" |
54 |
|
|
55 |
|
|
57 |
– |
struct Callback *entering_umode_cb = NULL; |
58 |
– |
struct Callback *umode_cb = NULL; |
59 |
– |
|
56 |
|
static char umode_buffer[IRCD_BUFSIZE]; |
57 |
|
|
58 |
|
static void user_welcome(struct Client *); |
77 |
|
MessageFile *isupportFile; |
78 |
|
|
79 |
|
/* memory is cheap. map 0-255 to equivalent mode */ |
80 |
< |
unsigned int user_modes[256] = |
80 |
> |
const unsigned int user_modes[256] = |
81 |
|
{ |
82 |
|
/* 0x00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x0F */ |
83 |
|
/* 0x10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x1F */ |
89 |
|
UMODE_CCONN_FULL, /* C */ |
90 |
|
UMODE_DEAF, /* D */ |
91 |
|
0, /* E */ |
92 |
< |
0, /* F */ |
92 |
> |
UMODE_FARCONNECT, /* F */ |
93 |
|
UMODE_SOFTCALLERID, /* G */ |
94 |
|
UMODE_HIDDEN, /* H */ |
95 |
|
0, /* I */ |
116 |
|
UMODE_BOTS, /* b */ |
117 |
|
UMODE_CCONN, /* c */ |
118 |
|
UMODE_DEBUG, /* d */ |
119 |
< |
0, /* e */ |
119 |
> |
UMODE_EXTERNAL, /* e */ |
120 |
|
UMODE_FULL, /* f */ |
121 |
|
UMODE_CALLERID, /* g */ |
122 |
|
0, /* h */ |
135 |
|
UMODE_UNAUTH, /* u */ |
136 |
|
0, /* v */ |
137 |
|
UMODE_WALLOP, /* w */ |
138 |
< |
UMODE_EXTERNAL, /* x */ |
138 |
> |
0, /* x */ |
139 |
|
UMODE_SPY, /* y */ |
140 |
|
UMODE_OPERWALL, /* z 0x7A */ |
141 |
|
0,0,0,0,0, /* 0x7B - 0x7F */ |
210 |
|
sendto_one(source_p, form_str(RPL_LUSERME), |
211 |
|
from, to, Count.local, Count.myserver); |
212 |
|
sendto_one(source_p, form_str(RPL_LOCALUSERS), |
213 |
< |
from, to, Count.local, Count.max_loc, |
218 |
< |
Count.local, Count.max_loc); |
213 |
> |
from, to, Count.local, Count.max_loc); |
214 |
|
} |
215 |
|
else |
216 |
|
{ |
217 |
|
sendto_one(source_p, form_str(RPL_LUSERME), |
218 |
|
from, to, Count.total, 0); |
219 |
|
sendto_one(source_p, form_str(RPL_LOCALUSERS), |
220 |
< |
from, to, Count.total, Count.max_tot, |
226 |
< |
Count.total, Count.max_tot); |
220 |
> |
from, to, Count.total, Count.max_tot); |
221 |
|
} |
222 |
|
|
223 |
|
sendto_one(source_p, form_str(RPL_GLOBALUSERS), |
224 |
< |
from, to, Count.total, Count.max_tot, |
231 |
< |
Count.total, Count.max_tot); |
224 |
> |
from, to, Count.total, Count.max_tot); |
225 |
|
|
226 |
|
if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) |
227 |
|
sendto_one(source_p, form_str(RPL_STATSCONN), from, to, |
304 |
|
/* Straight up the maximum rate of flooding... */ |
305 |
|
source_p->localClient->allow_read = MAX_FLOOD_BURST; |
306 |
|
|
307 |
< |
if (!execute_callback(client_check_cb, source_p, source_p->username)) |
307 |
> |
if (!check_client(source_p)) |
308 |
|
return; |
309 |
|
|
310 |
|
if (valid_hostname(source_p->host) == 0) |
390 |
|
} |
391 |
|
|
392 |
|
/* valid user name check */ |
393 |
< |
if (valid_username(source_p->username) == 0) |
393 |
> |
if (valid_username(source_p->username, 1) == 0) |
394 |
|
{ |
395 |
|
char tmpstr2[IRCD_BUFSIZE]; |
396 |
|
|
551 |
|
add_user_host(source_p->username, source_p->host, 1); |
552 |
|
SetUserHost(source_p); |
553 |
|
|
554 |
+ |
if (HasFlag(source_p->servptr, FLAGS_EOB)) |
555 |
+ |
sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE, |
556 |
+ |
"Client connecting at %s: %s (%s@%s) [%s] <%s>", |
557 |
+ |
source_p->servptr->name, |
558 |
+ |
source_p->name, source_p->username, source_p->host, |
559 |
+ |
source_p->info, source_p->id); |
560 |
+ |
|
561 |
|
introduce_client(source_p); |
562 |
|
} |
563 |
|
|
659 |
|
if (!IsHostChar(*p)) |
660 |
|
return 0; |
661 |
|
|
662 |
< |
return 1; |
662 |
> |
return p - hostname <= HOSTLEN; |
663 |
|
} |
664 |
|
|
665 |
|
/* valid_username() |
674 |
|
* style of username |
675 |
|
*/ |
676 |
|
int |
677 |
< |
valid_username(const char *username) |
677 |
> |
valid_username(const char *username, const int local) |
678 |
|
{ |
679 |
|
int dots = 0; |
680 |
|
const char *p = username; |
684 |
|
if (*p == '~') |
685 |
|
++p; |
686 |
|
|
687 |
< |
/* reject usernames that don't start with an alphanum |
687 |
> |
/* |
688 |
> |
* Reject usernames that don't start with an alphanum |
689 |
|
* i.e. reject jokers who have '-@somehost' or '.@somehost' |
690 |
|
* or "-hi-@somehost", "h-----@somehost" would still be accepted. |
691 |
|
*/ |
692 |
|
if (!IsAlNum(*p)) |
693 |
|
return 0; |
694 |
|
|
695 |
< |
while (*++p) |
695 |
> |
if (local) |
696 |
|
{ |
697 |
< |
if ((*p == '.') && ConfigFileEntry.dots_in_ident) |
697 |
> |
while (*++p) |
698 |
|
{ |
699 |
< |
if (++dots > ConfigFileEntry.dots_in_ident) |
700 |
< |
return 0; |
701 |
< |
if (!IsUserChar(*(p + 1))) |
699 |
> |
if ((*p == '.') && ConfigFileEntry.dots_in_ident) |
700 |
> |
{ |
701 |
> |
if (++dots > ConfigFileEntry.dots_in_ident) |
702 |
> |
return 0; |
703 |
> |
if (!IsUserChar(*(p + 1))) |
704 |
> |
return 0; |
705 |
> |
} |
706 |
> |
else if (!IsUserChar(*p)) |
707 |
|
return 0; |
708 |
|
} |
709 |
< |
else if (!IsUserChar(*p)) |
710 |
< |
return 0; |
709 |
> |
} |
710 |
> |
else |
711 |
> |
{ |
712 |
> |
while (*++p) |
713 |
> |
if (!IsUserChar(*p)) |
714 |
> |
return 0; |
715 |
|
} |
716 |
|
|
717 |
< |
return 1; |
717 |
> |
return p - username <= USERLEN;; |
718 |
|
} |
719 |
|
|
720 |
|
/* clean_nick_name() |
755 |
|
{ |
756 |
|
/* If this user is being spoofed, tell them so */ |
757 |
|
if (IsConfDoSpoofIp(conf)) |
748 |
– |
{ |
758 |
|
sendto_one(source_p, |
759 |
< |
":%s NOTICE %s :*** Spoofing your IP. congrats.", |
759 |
> |
":%s NOTICE %s :*** Spoofing your IP. Congrats.", |
760 |
|
me.name, source_p->name); |
752 |
– |
} |
761 |
|
|
762 |
|
/* If this user is in the exception class, Set it "E lined" */ |
763 |
|
if (IsConfExemptKline(conf)) |
764 |
|
{ |
765 |
|
SetExemptKline(source_p); |
766 |
|
sendto_one(source_p, |
767 |
< |
":%s NOTICE %s :*** You are exempt from K/D/G lines. congrats.", |
767 |
> |
":%s NOTICE %s :*** You are exempt from K/D/G lines. Congrats.", |
768 |
|
me.name, source_p->name); |
769 |
|
} |
770 |
|
|
774 |
|
else if (IsConfExemptGline(conf)) |
775 |
|
{ |
776 |
|
SetExemptGline(source_p); |
777 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from G lines.", |
777 |
> |
sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from G lines. Congrats.", |
778 |
|
me.name, source_p->name); |
779 |
|
} |
780 |
|
|
781 |
|
if (IsConfExemptResv(conf)) |
782 |
|
{ |
783 |
|
SetExemptResv(source_p); |
784 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from resvs.", |
784 |
> |
sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from resvs. Congrats.", |
785 |
|
me.name, source_p->name); |
786 |
|
} |
787 |
|
|
790 |
|
{ |
791 |
|
SetExemptLimits(source_p); |
792 |
|
sendto_one(source_p, |
793 |
< |
":%s NOTICE %s :*** You are exempt from user limits. congrats.", |
793 |
> |
":%s NOTICE %s :*** You are exempt from user limits. Congrats.", |
794 |
|
me.name,source_p->name); |
795 |
|
} |
796 |
|
|
803 |
|
} |
804 |
|
} |
805 |
|
|
798 |
– |
/* change_simple_umode() |
799 |
– |
* |
800 |
– |
* this callback can be hooked to allow special handling of |
801 |
– |
* certain usermodes |
802 |
– |
*/ |
803 |
– |
static void * |
804 |
– |
change_simple_umode(va_list args) |
805 |
– |
{ |
806 |
– |
struct Client *client_p; |
807 |
– |
struct Client *source_p; |
808 |
– |
int what; |
809 |
– |
unsigned int flag; |
810 |
– |
|
811 |
– |
client_p = va_arg(args, struct Client *); |
812 |
– |
source_p = va_arg(args, struct Client *); |
813 |
– |
what = va_arg(args, int); |
814 |
– |
flag = va_arg(args, unsigned int); |
815 |
– |
|
816 |
– |
if (what == MODE_ADD) |
817 |
– |
AddUMode(source_p, flag); |
818 |
– |
else |
819 |
– |
DelUMode(source_p, flag); |
820 |
– |
|
821 |
– |
return NULL; |
822 |
– |
} |
823 |
– |
|
806 |
|
/* set_user_mode() |
807 |
|
* |
808 |
|
* added 15/10/91 By Darren Reed. |
812 |
|
*/ |
813 |
|
void |
814 |
|
set_user_mode(struct Client *client_p, struct Client *source_p, |
815 |
< |
int parc, char *parv[]) |
815 |
> |
const int parc, char *parv[]) |
816 |
|
{ |
817 |
|
unsigned int flag, setflags; |
818 |
|
char **p, *m, buf[IRCD_BUFSIZE]; |
829 |
|
return; |
830 |
|
} |
831 |
|
|
850 |
– |
if (IsServer(source_p)) |
851 |
– |
{ |
852 |
– |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
853 |
– |
"*** Mode for User %s from %s", |
854 |
– |
parv[1], source_p->name); |
855 |
– |
return; |
856 |
– |
} |
857 |
– |
|
832 |
|
if (source_p != target_p) |
833 |
|
{ |
834 |
|
sendto_one(source_p, form_str(ERR_USERSDONTMATCH), |
851 |
|
return; |
852 |
|
} |
853 |
|
|
880 |
– |
execute_callback(entering_umode_cb, client_p, source_p); |
881 |
– |
|
854 |
|
/* find flags already set for user */ |
855 |
|
setflags = source_p->umodes; |
856 |
|
|
902 |
|
|
903 |
|
break; |
904 |
|
|
905 |
< |
/* we may not get these, |
934 |
< |
* but they shouldnt be in default |
935 |
< |
*/ |
936 |
< |
case 'r': |
937 |
< |
case ' ' : |
938 |
< |
case '\n': |
939 |
< |
case '\r': |
940 |
< |
case '\t': |
905 |
> |
case 'r': /* Only services may set +r */ |
906 |
|
break; |
907 |
|
|
908 |
|
default: |
910 |
|
{ |
911 |
|
if (MyConnect(source_p) && !HasUMode(source_p, UMODE_OPER) && |
912 |
|
(ConfigFileEntry.oper_only_umodes & flag)) |
948 |
– |
{ |
913 |
|
badflag = 1; |
950 |
– |
} |
914 |
|
else |
915 |
< |
execute_callback(umode_cb, client_p, source_p, what, flag); |
915 |
> |
{ |
916 |
> |
if (what == MODE_ADD) |
917 |
> |
AddUMode(source_p, flag); |
918 |
> |
else |
919 |
> |
DelUMode(source_p, flag); |
920 |
> |
} |
921 |
|
} |
922 |
|
else |
923 |
|
{ |
934 |
|
sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG), |
935 |
|
me.name, source_p->name); |
936 |
|
|
969 |
– |
if (HasUMode(source_p, UMODE_NCHANGE) && !HasOFlag(source_p, OPER_FLAG_N)) |
970 |
– |
{ |
971 |
– |
sendto_one(source_p, ":%s NOTICE %s :*** You have no nchange flag;", |
972 |
– |
me.name, source_p->name); |
973 |
– |
DelUMode(source_p, UMODE_NCHANGE); |
974 |
– |
} |
975 |
– |
|
937 |
|
if (MyConnect(source_p) && HasUMode(source_p, UMODE_ADMIN) && |
938 |
|
!HasOFlag(source_p, OPER_FLAG_ADMIN)) |
939 |
|
{ |
1051 |
|
send_umode(client_p, source_p, old, 0xffffffff, buf); |
1052 |
|
} |
1053 |
|
|
1054 |
+ |
void |
1055 |
+ |
user_set_hostmask(struct Client *target_p, const char *hostname) |
1056 |
+ |
{ |
1057 |
+ |
if (!valid_hostname(hostname)) |
1058 |
+ |
return; |
1059 |
+ |
|
1060 |
+ |
if (IsUserHostIp(target_p)) |
1061 |
+ |
delete_user_host(target_p->username, target_p->host, !MyConnect(target_p)); |
1062 |
+ |
|
1063 |
+ |
strlcpy(target_p->host, hostname, sizeof(target_p->host)); |
1064 |
+ |
SetIPSpoof(target_p); |
1065 |
+ |
|
1066 |
+ |
add_user_host(target_p->username, target_p->host, !MyConnect(target_p)); |
1067 |
+ |
SetUserHost(target_p); |
1068 |
+ |
|
1069 |
+ |
if (MyClient(target_p)) |
1070 |
+ |
clear_ban_cache_client(target_p); |
1071 |
+ |
} |
1072 |
+ |
|
1073 |
|
/* user_welcome() |
1074 |
|
* |
1075 |
|
* inputs - client pointer to client to welcome |
1139 |
|
struct MaskItem *conf = NULL; |
1140 |
|
const char *reason = NULL; |
1141 |
|
|
1142 |
< |
if ((conf = find_matching_name_conf(CONF_XLINE, source_p->info, NULL, NULL, 0)) || |
1163 |
< |
(conf = find_matching_name_conf(CONF_RXLINE, source_p->info, NULL, NULL, 0))) |
1142 |
> |
if ((conf = find_matching_name_conf(CONF_XLINE, source_p->info, NULL, NULL, 0))) |
1143 |
|
{ |
1144 |
|
++conf->count; |
1145 |
|
|
1174 |
|
oper_up(struct Client *source_p) |
1175 |
|
{ |
1176 |
|
const unsigned int old = source_p->umodes; |
1177 |
< |
const struct MaskItem *conf = NULL; |
1177 |
> |
const struct MaskItem *conf = source_p->localClient->confs.head->data; |
1178 |
|
|
1179 |
|
assert(source_p->localClient->confs.head); |
1201 |
– |
conf = source_p->localClient->confs.head->data; |
1180 |
|
|
1181 |
|
++Count.oper; |
1182 |
|
SetOper(source_p); |
1198 |
|
|
1199 |
|
if (HasOFlag(source_p, OPER_FLAG_ADMIN)) |
1200 |
|
AddUMode(source_p, UMODE_ADMIN); |
1223 |
– |
if (!HasOFlag(source_p, OPER_FLAG_N)) |
1224 |
– |
DelUMode(source_p, UMODE_NCHANGE); |
1201 |
|
|
1202 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s is now an operator", |
1203 |
|
get_oper_name(source_p)); |
1230 |
|
void |
1231 |
|
init_uid(void) |
1232 |
|
{ |
1233 |
< |
int i; |
1233 |
> |
unsigned int i; |
1234 |
|
|
1235 |
|
memset(new_uid, 0, sizeof(new_uid)); |
1236 |
|
|
1247 |
|
* -Dianora |
1248 |
|
*/ |
1249 |
|
memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID); |
1274 |
– |
|
1275 |
– |
entering_umode_cb = register_callback("entering_umode", NULL); |
1276 |
– |
umode_cb = register_callback("changing_umode", change_simple_umode); |
1250 |
|
} |
1251 |
|
|
1252 |
|
/* |
1313 |
|
add_isupport("DEAF", "D", -1); |
1314 |
|
add_isupport("KICKLEN", NULL, KICKLEN); |
1315 |
|
add_isupport("MODES", NULL, MAXMODEPARAMS); |
1343 |
– |
add_isupport("NICKLEN", NULL, NICKLEN); |
1316 |
|
#ifdef HALFOPS |
1317 |
|
add_isupport("PREFIX", "(ohv)@%+", -1); |
1318 |
|
add_isupport("STATUSMSG", "@%+", -1); |
1320 |
|
add_isupport("PREFIX", "(ov)@+", -1); |
1321 |
|
add_isupport("STATUSMSG", "@+", -1); |
1322 |
|
#endif |
1351 |
– |
add_isupport("TOPICLEN", NULL, TOPICLEN); |
1323 |
|
} |
1324 |
|
|
1325 |
|
/* |
1354 |
|
dlinkAddTail(support, &support->node, &support_list); |
1355 |
|
} |
1356 |
|
|
1357 |
< |
DupString(support->name, name); |
1357 |
> |
support->name = xstrdup(name); |
1358 |
|
if (options != NULL) |
1359 |
< |
DupString(support->options, options); |
1359 |
> |
support->options = xstrdup(options); |
1360 |
|
support->number = n; |
1361 |
|
|
1362 |
|
rebuild_isupport_message_line(); |
1415 |
|
{ |
1416 |
|
struct Isupport *support = ptr->data; |
1417 |
|
|
1418 |
< |
p += (n = ircsprintf(p, "%s", support->name)); |
1418 |
> |
p += (n = sprintf(p, "%s", support->name)); |
1419 |
|
len += n; |
1420 |
|
|
1421 |
|
if (support->options != NULL) |
1422 |
|
{ |
1423 |
< |
p += (n = ircsprintf(p, "=%s", support->options)); |
1423 |
> |
p += (n = sprintf(p, "=%s", support->options)); |
1424 |
|
len += n; |
1425 |
|
} |
1426 |
|
|
1427 |
|
if (support->number > 0) |
1428 |
|
{ |
1429 |
< |
p += (n = ircsprintf(p, "=%d", support->number)); |
1429 |
> |
p += (n = sprintf(p, "=%d", support->number)); |
1430 |
|
len += n; |
1431 |
|
} |
1432 |
|
|