19 |
|
* USA |
20 |
|
*/ |
21 |
|
|
22 |
< |
/*! \file s_user.c |
22 |
> |
/*! \file user.c |
23 |
|
* \brief User related functions. |
24 |
|
* \version $Id$ |
25 |
|
*/ |
31 |
|
#include "channel_mode.h" |
32 |
|
#include "client.h" |
33 |
|
#include "hash.h" |
34 |
+ |
#include "id.h" |
35 |
|
#include "irc_string.h" |
36 |
|
#include "ircd.h" |
37 |
|
#include "listener.h" |
50 |
|
#include "watch.h" |
51 |
|
|
52 |
|
static char umode_buffer[IRCD_BUFSIZE]; |
52 |
– |
static const char *uid_get(void); |
53 |
|
|
54 |
|
/* Used for building up the isupport string, |
55 |
|
* used with init_isupport, add_isupport, delete_isupport |
197 |
|
if (IsConfExemptKline(conf)) |
198 |
|
{ |
199 |
|
SetExemptKline(source_p); |
200 |
< |
sendto_one_notice(source_p, &me, ":*** You are exempt from K/D/G lines. Congrats."); |
200 |
> |
sendto_one_notice(source_p, &me, ":*** You are exempt from K/D lines. Congrats."); |
201 |
|
} |
202 |
|
|
203 |
< |
/* |
204 |
< |
* The else here is to make sure that G line exempt users |
205 |
< |
* do not get noticed twice. |
206 |
< |
*/ |
207 |
< |
else if (IsConfExemptGline(conf)) |
203 |
> |
if (IsConfExemptXline(conf)) |
204 |
|
{ |
205 |
< |
SetExemptGline(source_p); |
206 |
< |
sendto_one_notice(source_p, &me, ":*** You are exempt from G lines. Congrats."); |
205 |
> |
SetExemptXline(source_p); |
206 |
> |
sendto_one_notice(source_p, &me, ":*** You are exempt from X lines. Congrats."); |
207 |
|
} |
208 |
|
|
209 |
|
if (IsConfExemptResv(conf)) |
262 |
|
continue; |
263 |
|
|
264 |
|
if (IsCapable(server, CAP_SVS)) |
265 |
< |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s %s :%s", |
265 |
> |
sendto_one(server, ":%s UID %s %u %lu %s %s %s %s %s %s :%s", |
266 |
|
source_p->servptr->id, |
267 |
|
source_p->name, source_p->hopcount+1, |
268 |
|
(unsigned long)source_p->tsinfo, |
271 |
|
source_p->account, |
272 |
|
source_p->info); |
273 |
|
else |
274 |
< |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
274 |
> |
sendto_one(server, ":%s UID %s %u %lu %s %s %s %s %s :%s", |
275 |
|
source_p->servptr->id, |
276 |
|
source_p->name, source_p->hopcount+1, |
277 |
|
(unsigned long)source_p->tsinfo, |
331 |
|
{ |
332 |
|
struct MaskItem *conf = NULL; |
333 |
|
|
334 |
+ |
if (IsExemptXline(source_p)) |
335 |
+ |
return 0; |
336 |
+ |
|
337 |
|
if ((conf = find_matching_name_conf(CONF_XLINE, source_p->info, NULL, NULL, 0))) |
338 |
|
{ |
339 |
|
++conf->count; |
364 |
|
|
365 |
|
assert(source_p == source_p->from); |
366 |
|
assert(MyConnect(source_p)); |
367 |
+ |
assert(IsUnknown(source_p)); |
368 |
|
assert(!source_p->connection->registration); |
369 |
|
|
370 |
– |
ClearCap(source_p, CAP_TS6); |
371 |
– |
|
370 |
|
if (ConfigGeneral.ping_cookie) |
371 |
|
{ |
372 |
|
if (!IsPingSent(source_p) && !source_p->connection->random_ping) |
461 |
|
* probably be just a percentage of the MAXCLIENTS... |
462 |
|
* -Taner |
463 |
|
*/ |
464 |
< |
if ((Count.local >= ConfigServerInfo.max_clients + MAX_BUFFER) || |
465 |
< |
(Count.local >= ConfigServerInfo.max_clients && !IsExemptLimits(source_p))) |
464 |
> |
if ((Count.local >= GlobalSetOptions.maxclients + MAX_BUFFER) || |
465 |
> |
(Count.local >= GlobalSetOptions.maxclients && !IsExemptLimits(source_p))) |
466 |
|
{ |
467 |
|
sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE, |
468 |
|
"Too many clients, rejecting %s[%s].", |
587 |
|
SetUserHost(source_p); |
588 |
|
|
589 |
|
if (HasFlag(source_p->servptr, FLAGS_EOB)) |
590 |
< |
if (strcmp(source_p->sockhost, "0")) /* XXX: TBR */ |
591 |
< |
sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE, |
592 |
< |
"Client connecting at %s: %s (%s@%s) [%s] [%s] <%s>", |
593 |
< |
source_p->servptr->name, |
594 |
< |
source_p->name, source_p->username, source_p->host, |
597 |
< |
source_p->sockhost, source_p->info, source_p->id); |
598 |
< |
else |
599 |
< |
sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE, |
600 |
< |
"Client connecting at %s: %s (%s@%s) [%s] <%s>", |
601 |
< |
source_p->servptr->name, |
602 |
< |
source_p->name, source_p->username, source_p->host, |
603 |
< |
source_p->info, source_p->id); |
590 |
> |
sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE, |
591 |
> |
"Client connecting at %s: %s (%s@%s) [%s] [%s] <%s>", |
592 |
> |
source_p->servptr->name, |
593 |
> |
source_p->name, source_p->username, source_p->host, |
594 |
> |
source_p->sockhost, source_p->info, source_p->id); |
595 |
|
|
596 |
|
introduce_client(source_p); |
597 |
|
} |
902 |
|
if (HasOFlag(source_p, OPER_FLAG_ADMIN)) |
903 |
|
AddUMode(source_p, UMODE_ADMIN); |
904 |
|
|
905 |
+ |
if (!EmptyString(conf->whois)) |
906 |
+ |
{ |
907 |
+ |
client_attach_svstag(source_p, RPL_WHOISOPERATOR, "+", conf->whois); |
908 |
+ |
sendto_server(source_p, 0, 0, ":%s SVSTAG %s %lu %u + :%s", |
909 |
+ |
me.id, source_p->id, (unsigned long)source_p->tsinfo, |
910 |
+ |
RPL_WHOISOPERATOR, conf->whois); |
911 |
+ |
} |
912 |
+ |
|
913 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s is now an operator", |
914 |
|
get_oper_name(source_p)); |
915 |
|
sendto_server(NULL, 0, 0, ":%s GLOBOPS :%s is now an operator", |
918 |
|
sendto_one_numeric(source_p, &me, RPL_YOUREOPER); |
919 |
|
} |
920 |
|
|
922 |
– |
static char new_uid[TOTALSIDUID + 1]; /* Allow for \0 */ |
923 |
– |
|
924 |
– |
int |
925 |
– |
valid_sid(const char *sid) |
926 |
– |
{ |
927 |
– |
if (strlen(sid) == IRC_MAXSID) |
928 |
– |
if (IsDigit(*sid)) |
929 |
– |
if (IsAlNum(*(sid + 1)) && IsAlNum(*(sid + 2))) |
930 |
– |
return 1; |
931 |
– |
|
932 |
– |
return 0; |
933 |
– |
} |
934 |
– |
|
935 |
– |
/* |
936 |
– |
* init_uid() |
937 |
– |
* |
938 |
– |
* inputs - NONE |
939 |
– |
* output - NONE |
940 |
– |
* side effects - new_uid is filled in with server id portion (sid) |
941 |
– |
* (first 3 bytes) or defaulted to 'A'. |
942 |
– |
* Rest is filled in with 'A' |
943 |
– |
*/ |
944 |
– |
void |
945 |
– |
init_uid(void) |
946 |
– |
{ |
947 |
– |
memset(new_uid, 0, sizeof(new_uid)); |
948 |
– |
|
949 |
– |
if (!EmptyString(ConfigServerInfo.sid)) |
950 |
– |
strlcpy(new_uid, ConfigServerInfo.sid, sizeof(new_uid)); |
951 |
– |
|
952 |
– |
for (unsigned int i = 0; i < IRC_MAXSID; ++i) |
953 |
– |
if (new_uid[i] == '\0') |
954 |
– |
new_uid[i] = 'A'; |
955 |
– |
|
956 |
– |
/* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */ |
957 |
– |
memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID); |
958 |
– |
} |
959 |
– |
|
960 |
– |
/* |
961 |
– |
* add_one_to_uid |
962 |
– |
* |
963 |
– |
* inputs - index number into new_uid |
964 |
– |
* output - NONE |
965 |
– |
* side effects - new_uid is incremented by one |
966 |
– |
* note this is a recursive function |
967 |
– |
*/ |
968 |
– |
static void |
969 |
– |
add_one_to_uid(unsigned int i) |
970 |
– |
{ |
971 |
– |
if (i != IRC_MAXSID) /* Not reached server SID portion yet? */ |
972 |
– |
{ |
973 |
– |
if (new_uid[i] == 'Z') |
974 |
– |
new_uid[i] = '0'; |
975 |
– |
else if (new_uid[i] == '9') |
976 |
– |
{ |
977 |
– |
new_uid[i] = 'A'; |
978 |
– |
add_one_to_uid(i - 1); |
979 |
– |
} |
980 |
– |
else |
981 |
– |
++new_uid[i]; |
982 |
– |
} |
983 |
– |
else |
984 |
– |
{ |
985 |
– |
/* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */ |
986 |
– |
if (new_uid[i] == 'Z') |
987 |
– |
memcpy(new_uid + IRC_MAXSID, "AAAAAA", IRC_MAXUID); |
988 |
– |
else |
989 |
– |
++new_uid[i]; |
990 |
– |
} |
991 |
– |
} |
992 |
– |
|
993 |
– |
/* |
994 |
– |
* uid_get |
995 |
– |
* |
996 |
– |
* inputs - struct Client * |
997 |
– |
* output - new UID is returned to caller |
998 |
– |
* side effects - new_uid is incremented by one. |
999 |
– |
*/ |
1000 |
– |
static const char * |
1001 |
– |
uid_get(void) |
1002 |
– |
{ |
1003 |
– |
add_one_to_uid(TOTALSIDUID - 1); /* Index from 0 */ |
1004 |
– |
return new_uid; |
1005 |
– |
} |
1006 |
– |
|
921 |
|
/* |
922 |
|
* init_isupport() |
923 |
|
* |