53 |
|
#include "watch.h" |
54 |
|
|
55 |
|
|
56 |
– |
struct Callback *entering_umode_cb = NULL; |
57 |
– |
struct Callback *umode_cb = NULL; |
58 |
– |
|
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 */ |
135 |
|
UMODE_UNAUTH, /* u */ |
136 |
|
0, /* v */ |
137 |
|
UMODE_WALLOP, /* w */ |
138 |
< |
0, /* x */ |
138 |
> |
UMODE_HIDDENHOST, /* x */ |
139 |
|
UMODE_SPY, /* y */ |
140 |
|
UMODE_OPERWALL, /* z 0x7A */ |
141 |
|
0,0,0,0,0, /* 0x7B - 0x7F */ |
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 |
|
|
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)) |
744 |
– |
{ |
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); |
748 |
– |
} |
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 |
|
|
794 |
– |
/* change_simple_umode() |
795 |
– |
* |
796 |
– |
* this callback can be hooked to allow special handling of |
797 |
– |
* certain usermodes |
798 |
– |
*/ |
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 |
– |
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); |
811 |
– |
|
812 |
– |
if (what == MODE_ADD) |
813 |
– |
AddUMode(source_p, flag); |
814 |
– |
else |
815 |
– |
DelUMode(source_p, flag); |
816 |
– |
|
817 |
– |
return NULL; |
818 |
– |
} |
819 |
– |
|
806 |
|
/* set_user_mode() |
807 |
|
* |
808 |
|
* added 15/10/91 By Darren Reed. |
851 |
|
return; |
852 |
|
} |
853 |
|
|
868 |
– |
execute_callback(entering_umode_cb, client_p, source_p); |
869 |
– |
|
854 |
|
/* find flags already set for user */ |
855 |
|
setflags = source_p->umodes; |
856 |
|
|
902 |
|
|
903 |
|
break; |
904 |
|
|
905 |
< |
/* we may not get these, |
906 |
< |
* but they shouldnt be in default |
923 |
< |
*/ |
924 |
< |
case 'r': |
925 |
< |
case ' ' : |
926 |
< |
case '\n': |
927 |
< |
case '\r': |
928 |
< |
case '\t': |
905 |
> |
case 'r': /* Only services may set +r */ |
906 |
> |
case 'x': /* Only services may set +x */ |
907 |
|
break; |
908 |
|
|
909 |
|
default: |
911 |
|
{ |
912 |
|
if (MyConnect(source_p) && !HasUMode(source_p, UMODE_OPER) && |
913 |
|
(ConfigFileEntry.oper_only_umodes & flag)) |
936 |
– |
{ |
914 |
|
badflag = 1; |
938 |
– |
} |
915 |
|
else |
916 |
< |
execute_callback(umode_cb, client_p, source_p, what, flag); |
916 |
> |
{ |
917 |
> |
if (what == MODE_ADD) |
918 |
> |
AddUMode(source_p, flag); |
919 |
> |
else |
920 |
> |
DelUMode(source_p, flag); |
921 |
> |
} |
922 |
|
} |
923 |
|
else |
924 |
|
{ |
1053 |
|
} |
1054 |
|
|
1055 |
|
void |
1056 |
< |
user_set_hostmask(struct Client *target_p, const char *hostname) |
1056 |
> |
user_set_hostmask(struct Client *target_p, const char *hostname, const int what) |
1057 |
|
{ |
1058 |
< |
if (!valid_hostname(hostname)) |
1059 |
< |
return; |
1058 |
> |
dlink_node *ptr = NULL; |
1059 |
> |
|
1060 |
> |
sendto_common_channels_local(target_p, 0, 0, ":%s!%s@%s QUIT :Changing hostname", |
1061 |
> |
target_p->name, target_p->username, target_p->host); |
1062 |
|
|
1063 |
|
if (IsUserHostIp(target_p)) |
1064 |
|
delete_user_host(target_p->username, target_p->host, !MyConnect(target_p)); |
1065 |
|
|
1066 |
|
strlcpy(target_p->host, hostname, sizeof(target_p->host)); |
1084 |
– |
SetIPSpoof(target_p); |
1067 |
|
|
1068 |
|
add_user_host(target_p->username, target_p->host, !MyConnect(target_p)); |
1069 |
|
SetUserHost(target_p); |
1070 |
|
|
1071 |
+ |
switch (what) |
1072 |
+ |
{ |
1073 |
+ |
case MODE_ADD: |
1074 |
+ |
AddUMode(target_p, UMODE_HIDDENHOST); |
1075 |
+ |
AddFlag(target_p, FLAGS_IP_SPOOFING); |
1076 |
+ |
break; |
1077 |
+ |
case MODE_DEL: |
1078 |
+ |
DelUMode(target_p, UMODE_HIDDENHOST); |
1079 |
+ |
|
1080 |
+ |
if (!HasFlag(target_p, FLAGS_AUTH_SPOOF)) |
1081 |
+ |
DelFlag(target_p, FLAGS_IP_SPOOFING); |
1082 |
+ |
break; |
1083 |
+ |
default: break; |
1084 |
+ |
} |
1085 |
+ |
|
1086 |
|
if (MyClient(target_p)) |
1087 |
+ |
{ |
1088 |
+ |
sendto_one(target_p, form_str(RPL_NEWHOSTIS), me.name, |
1089 |
+ |
target_p->name, target_p->username, |
1090 |
+ |
target_p->host); |
1091 |
|
clear_ban_cache_client(target_p); |
1092 |
+ |
} |
1093 |
+ |
|
1094 |
+ |
DLINK_FOREACH(ptr, target_p->channel.head) |
1095 |
+ |
{ |
1096 |
+ |
char modebuf[4], nickbuf[NICKLEN * 3 + 3] = { '\0' }; |
1097 |
+ |
char *p = modebuf; |
1098 |
+ |
int len = 0; |
1099 |
+ |
const struct Membership *ms = ptr->data; |
1100 |
+ |
|
1101 |
+ |
if (has_member_flags(ms, CHFL_CHANOP)) { |
1102 |
+ |
*p++ = 'o'; |
1103 |
+ |
len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name); |
1104 |
+ |
} |
1105 |
+ |
|
1106 |
+ |
if (has_member_flags(ms, CHFL_HALFOP)) { |
1107 |
+ |
*p++ = 'h'; |
1108 |
+ |
len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name); |
1109 |
+ |
} |
1110 |
+ |
|
1111 |
+ |
if (has_member_flags(ms, CHFL_VOICE)) { |
1112 |
+ |
*p++ = 'v'; |
1113 |
+ |
len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name); |
1114 |
+ |
} |
1115 |
+ |
|
1116 |
+ |
*p = '\0'; |
1117 |
+ |
|
1118 |
+ |
sendto_channel_local_butone(target_p, 0, 0, ms->chptr, ":%s!%s@%s JOIN :%s", |
1119 |
+ |
target_p->name, target_p->username, target_p->host, |
1120 |
+ |
ms->chptr->chname); |
1121 |
+ |
if (nickbuf[0]) |
1122 |
+ |
sendto_channel_local_butone(target_p, 0, 0, ms->chptr, ":%s MODE %s +%s %s", |
1123 |
+ |
target_p->servptr->name, ms->chptr->chname, |
1124 |
+ |
modebuf, nickbuf); |
1125 |
+ |
|
1126 |
+ |
} |
1127 |
+ |
|
1128 |
+ |
if (target_p->away[0]) |
1129 |
+ |
sendto_common_channels_local(target_p, 0, CAP_AWAY_NOTIFY, |
1130 |
+ |
":%s!%s@%s AWAY :%s", |
1131 |
+ |
target_p->name, target_p->username, |
1132 |
+ |
target_p->host, target_p->away); |
1133 |
|
} |
1134 |
|
|
1135 |
|
/* user_welcome() |
1155 |
|
#endif |
1156 |
|
|
1157 |
|
sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name, |
1158 |
< |
ServerInfo.network_name, source_p->name, |
1117 |
< |
source_p->username, source_p->host); |
1158 |
> |
ServerInfo.network_name, source_p->name); |
1159 |
|
sendto_one(source_p, form_str(RPL_YOURHOST), me.name, source_p->name, |
1160 |
|
get_listener_name(source_p->localClient->listener), ircd_version); |
1161 |
|
sendto_one(source_p, form_str(RPL_CREATED), |
1201 |
|
struct MaskItem *conf = NULL; |
1202 |
|
const char *reason = NULL; |
1203 |
|
|
1204 |
< |
if ((conf = find_matching_name_conf(CONF_XLINE, source_p->info, NULL, NULL, 0)) || |
1164 |
< |
(conf = find_matching_name_conf(CONF_RXLINE, source_p->info, NULL, NULL, 0))) |
1204 |
> |
if ((conf = find_matching_name_conf(CONF_XLINE, source_p->info, NULL, NULL, 0))) |
1205 |
|
{ |
1206 |
|
++conf->count; |
1207 |
|
|
1309 |
|
* -Dianora |
1310 |
|
*/ |
1311 |
|
memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID); |
1272 |
– |
|
1273 |
– |
entering_umode_cb = register_callback("entering_umode", NULL); |
1274 |
– |
umode_cb = register_callback("changing_umode", change_simple_umode); |
1312 |
|
} |
1313 |
|
|
1314 |
|
/* |