23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
< |
#include "tools.h" |
26 |
> |
#include "list.h" |
27 |
|
#include "client.h" |
28 |
|
#include "channel_mode.h" |
29 |
|
#include "common.h" |
33 |
|
#include "irc_string.h" |
34 |
|
#include "sprintf_irc.h" |
35 |
|
#include "ircd.h" |
36 |
– |
#include "list.h" |
36 |
|
#include "s_gline.h" |
37 |
|
#include "numeric.h" |
38 |
|
#include "packet.h" |
263 |
|
struct AccessItem *aconf; |
264 |
|
|
265 |
|
conf = make_conf_item(KLINE_TYPE); |
266 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
266 |
> |
aconf = map_to_conf(conf); |
267 |
|
|
268 |
|
DupString(aconf->host, client_p->host); |
269 |
|
DupString(aconf->reason, "idle exceeder"); |
556 |
|
{ |
557 |
|
if (IsServer(client_p)) |
558 |
|
{ |
559 |
< |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, |
560 |
< |
"Server %s split from %s", |
562 |
< |
client_p->name, client_p->servptr->name); |
559 |
> |
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, "Server %s split from %s", |
560 |
> |
client_p->name, client_p->servptr->name); |
561 |
|
} |
562 |
|
else if (IsClient(client_p)) |
563 |
|
{ |
564 |
+ |
assert(Count.total > 0); |
565 |
|
--Count.total; |
566 |
|
if (IsOper(client_p)) |
567 |
|
--Count.oper; |
696 |
|
void |
697 |
|
free_exited_clients(void) |
698 |
|
{ |
699 |
< |
dlink_node *ptr, *next; |
701 |
< |
struct Client *target_p; |
699 |
> |
dlink_node *ptr = NULL, *next = NULL; |
700 |
|
|
701 |
|
DLINK_FOREACH_SAFE(ptr, next, dead_list.head) |
702 |
|
{ |
703 |
< |
target_p = ptr->data; |
706 |
< |
|
707 |
< |
if (ptr->data == NULL) |
708 |
< |
{ |
709 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
710 |
< |
"Warning: null client on dead_list!"); |
711 |
< |
dlinkDelete(ptr, &dead_list); |
712 |
< |
free_dlink_node(ptr); |
713 |
< |
continue; |
714 |
< |
} |
715 |
< |
|
716 |
< |
free_client(target_p); |
703 |
> |
free_client(ptr->data); |
704 |
|
dlinkDelete(ptr, &dead_list); |
705 |
|
free_dlink_node(ptr); |
706 |
|
} |
721 |
|
|
722 |
|
if (IsServer(source_p)) |
723 |
|
{ |
724 |
< |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->servers); |
724 |
> |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list); |
725 |
|
|
726 |
|
if ((lp = dlinkFindDelete(&global_serv_list, source_p)) != NULL) |
727 |
|
free_dlink_node(lp); |
741 |
– |
|
742 |
– |
if (!MyConnect(source_p)) |
743 |
– |
{ |
744 |
– |
source_p->from->serv->dep_servers--; |
745 |
– |
assert(source_p->from->serv->dep_servers > 0); |
746 |
– |
} |
728 |
|
} |
729 |
|
else if (IsClient(source_p)) |
730 |
|
{ |
731 |
|
if (source_p->servptr->serv != NULL) |
732 |
< |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->users); |
732 |
> |
dlinkDelete(&source_p->lnode, &source_p->servptr->serv->client_list); |
733 |
|
|
734 |
|
/* If a person is on a channel, send a QUIT notice |
735 |
|
** to every client (person) on the same channel (so |
742 |
|
DLINK_FOREACH_SAFE(lp, next_lp, source_p->channel.head) |
743 |
|
remove_user_from_channel(lp->data); |
744 |
|
|
764 |
– |
/* Clean up allow lists */ |
765 |
– |
del_all_accepts(source_p); |
745 |
|
add_history(source_p, 0); |
746 |
|
off_history(source_p); |
747 |
|
|
748 |
|
watch_check_hash(source_p, RPL_LOGOFF); |
749 |
|
|
750 |
< |
if (!MyConnect(source_p)) |
772 |
< |
{ |
773 |
< |
source_p->from->serv->dep_users--; |
774 |
< |
assert(source_p->from->serv->dep_users >= 0); |
775 |
< |
} |
776 |
< |
else |
750 |
> |
if (MyConnect(source_p)) |
751 |
|
{ |
752 |
|
/* Clean up invitefield */ |
753 |
|
DLINK_FOREACH_SAFE(lp, next_lp, source_p->localClient->invited.head) |
754 |
|
del_invite(lp->data, source_p); |
755 |
+ |
|
756 |
+ |
del_all_accepts(source_p); |
757 |
|
} |
758 |
|
} |
759 |
|
|
810 |
|
* hidden behind fakename. If so, send out the QUITs -adx |
811 |
|
*/ |
812 |
|
if (hidden || !IsCapable(to, CAP_QS)) |
813 |
< |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->users.head) |
813 |
> |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->client_list.head) |
814 |
|
{ |
815 |
|
target_p = ptr->data; |
816 |
|
sendto_one(to, ":%s QUIT :%s", target_p->name, splitstr); |
817 |
|
} |
818 |
|
|
819 |
< |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->servers.head) |
819 |
> |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->server_list.head) |
820 |
|
recurse_send_quits(original_source_p, ptr->data, from, to, |
821 |
|
comment, splitstr, myname); |
822 |
|
|
840 |
|
{ |
841 |
|
dlink_node *ptr, *next; |
842 |
|
|
843 |
< |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->users.head) |
843 |
> |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->client_list.head) |
844 |
|
exit_one_client(ptr->data, quitmsg); |
845 |
|
|
846 |
< |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->servers.head) |
846 |
> |
DLINK_FOREACH_SAFE(ptr, next, source_p->serv->server_list.head) |
847 |
|
{ |
848 |
|
recurse_remove_clients(ptr->data, quitmsg); |
849 |
|
exit_one_client(ptr->data, quitmsg); |
850 |
|
} |
875 |
– |
|
876 |
– |
assert(source_p->serv->dep_servers == 1); |
877 |
– |
assert(source_p->serv->dep_users == 0); |
851 |
|
} |
852 |
|
|
853 |
|
/* |
915 |
|
if (IsIpHash(source_p)) |
916 |
|
remove_one_ip(&source_p->localClient->ip); |
917 |
|
|
918 |
< |
delete_auth(source_p); |
918 |
> |
if (source_p->localClient->auth) |
919 |
> |
{ |
920 |
> |
delete_auth(source_p->localClient->auth); |
921 |
> |
source_p->localClient->auth = NULL; |
922 |
> |
} |
923 |
|
|
924 |
|
/* This source_p could have status of one of STAT_UNKNOWN, STAT_CONNECTING |
925 |
|
* STAT_HANDSHAKE or STAT_UNKNOWN |
934 |
|
} |
935 |
|
else if (IsClient(source_p)) |
936 |
|
{ |
937 |
+ |
assert(Count.local > 0); |
938 |
|
Count.local--; |
939 |
|
|
940 |
|
if (IsOper(source_p)) |
1016 |
|
assert(source_p->serv != NULL && source_p->servptr != NULL); |
1017 |
|
|
1018 |
|
if (ConfigServerHide.hide_servers) |
1019 |
< |
/* set netsplit message to "*.net *.split" to still show |
1019 |
> |
/* |
1020 |
> |
* Set netsplit message to "*.net *.split" to still show |
1021 |
|
* that its a split, but hide the servers splitting |
1022 |
|
*/ |
1023 |
|
strcpy(splitstr, "*.net *.split"); |
1181 |
|
|
1182 |
|
/* |
1183 |
|
* accept processing, this adds a form of "caller ID" to ircd |
1184 |
< |
* |
1184 |
> |
* |
1185 |
|
* If a client puts themselves into "caller ID only" mode, |
1186 |
< |
* only clients that match a client pointer they have put on |
1186 |
> |
* only clients that match a client pointer they have put on |
1187 |
|
* the accept list will be allowed to message them. |
1188 |
|
* |
1189 |
< |
* [ source.on_allow_list ] -> [ target1 ] -> [ target2 ] |
1211 |
< |
* |
1212 |
< |
* [target.allow_list] -> [ source1 ] -> [source2 ] |
1213 |
< |
* |
1214 |
< |
* i.e. a target will have a link list of source pointers it will allow |
1215 |
< |
* each source client then has a back pointer pointing back |
1216 |
< |
* to the client that has it on its accept list. |
1217 |
< |
* This allows for exit_one_client to remove these now bogus entries |
1218 |
< |
* from any client having an accept on them. |
1189 |
> |
* Diane Bruce, "Dianora" db@db.net |
1190 |
|
*/ |
1191 |
|
|
1192 |
< |
/* accept_message() |
1193 |
< |
* |
1223 |
< |
* inputs - pointer to source client |
1224 |
< |
* - pointer to target client |
1225 |
< |
* output - 1 if accept this message 0 if not |
1226 |
< |
* side effects - See if source is on target's allow list |
1227 |
< |
*/ |
1228 |
< |
int |
1229 |
< |
accept_message(struct Client *source, struct Client *target) |
1192 |
> |
void |
1193 |
> |
del_accept(struct split_nuh_item *accept_p, struct Client *client_p) |
1194 |
|
{ |
1195 |
< |
dlink_node *ptr; |
1232 |
< |
|
1233 |
< |
DLINK_FOREACH(ptr, target->allow_list.head) |
1234 |
< |
{ |
1235 |
< |
struct Client *target_p = ptr->data; |
1236 |
< |
|
1237 |
< |
if (source == target_p) |
1238 |
< |
return (1); |
1239 |
< |
} |
1195 |
> |
dlinkDelete(&accept_p->node, &client_p->localClient->acceptlist); |
1196 |
|
|
1197 |
< |
if (IsSoftCallerId(target)) |
1198 |
< |
{ |
1199 |
< |
DLINK_FOREACH(ptr, target->channel.head) |
1200 |
< |
if (IsMember(source, ((struct Membership *)ptr->data)->chptr)) |
1245 |
< |
return (1); |
1246 |
< |
} |
1247 |
< |
|
1248 |
< |
return (0); |
1197 |
> |
MyFree(accept_p->nickptr); |
1198 |
> |
MyFree(accept_p->userptr); |
1199 |
> |
MyFree(accept_p->hostptr); |
1200 |
> |
MyFree(accept_p); |
1201 |
|
} |
1202 |
|
|
1203 |
< |
/* del_from_accept() |
1204 |
< |
* |
1205 |
< |
* inputs - pointer to source client |
1254 |
< |
* - pointer to target client |
1255 |
< |
* output - NONE |
1256 |
< |
* side effects - Delete's source pointer to targets allow list |
1257 |
< |
* |
1258 |
< |
* Walk through the target's accept list, remove if source is found, |
1259 |
< |
* Then walk through the source's on_accept_list remove target if found. |
1260 |
< |
*/ |
1261 |
< |
void |
1262 |
< |
del_from_accept(struct Client *source, struct Client *target) |
1203 |
> |
struct split_nuh_item * |
1204 |
> |
find_accept(const char *nick, const char *user, |
1205 |
> |
const char *host, struct Client *client_p, int do_match) |
1206 |
|
{ |
1207 |
< |
dlink_node *ptr; |
1208 |
< |
dlink_node *ptr2; |
1209 |
< |
dlink_node *next_ptr; |
1267 |
< |
dlink_node *next_ptr2; |
1268 |
< |
struct Client *target_p; |
1207 |
> |
dlink_node *ptr = NULL; |
1208 |
> |
/* XXX We wouldn't need that if match() would return 0 on match */ |
1209 |
> |
int (*cmpfunc)(const char *, const char *) = do_match ? match : irccmp; |
1210 |
|
|
1211 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, target->allow_list.head) |
1211 |
> |
DLINK_FOREACH(ptr, client_p->localClient->acceptlist.head) |
1212 |
|
{ |
1213 |
< |
target_p = ptr->data; |
1273 |
< |
|
1274 |
< |
if (source == target_p) |
1275 |
< |
{ |
1276 |
< |
dlinkDelete(ptr, &target->allow_list); |
1277 |
< |
free_dlink_node(ptr); |
1278 |
< |
|
1279 |
< |
DLINK_FOREACH_SAFE(ptr2, next_ptr2, source->on_allow_list.head) |
1280 |
< |
{ |
1281 |
< |
target_p = ptr2->data; |
1213 |
> |
struct split_nuh_item *accept_p = ptr->data; |
1214 |
|
|
1215 |
< |
if (target == target_p) |
1216 |
< |
{ |
1217 |
< |
dlinkDelete(ptr2, &source->on_allow_list); |
1218 |
< |
free_dlink_node(ptr2); |
1287 |
< |
} |
1288 |
< |
} |
1289 |
< |
} |
1215 |
> |
if (cmpfunc(accept_p->nickptr, nick) == do_match && |
1216 |
> |
cmpfunc(accept_p->userptr, user) == do_match && |
1217 |
> |
cmpfunc(accept_p->hostptr, host) == do_match) |
1218 |
> |
return accept_p; |
1219 |
|
} |
1220 |
+ |
|
1221 |
+ |
return NULL; |
1222 |
|
} |
1223 |
|
|
1224 |
< |
/* del_all_accepts() |
1224 |
> |
/* accept_message() |
1225 |
|
* |
1226 |
< |
* inputs - pointer to exiting client |
1227 |
< |
* output - NONE |
1228 |
< |
* side effects - Walk through given clients allow_list and on_allow_list |
1229 |
< |
* remove all references to this client |
1226 |
> |
* inputs - pointer to source client |
1227 |
> |
* - pointer to target client |
1228 |
> |
* output - 1 if accept this message 0 if not |
1229 |
> |
* side effects - See if source is on target's allow list |
1230 |
|
*/ |
1231 |
< |
void |
1232 |
< |
del_all_accepts(struct Client *client_p) |
1231 |
> |
int |
1232 |
> |
accept_message(struct Client *source, |
1233 |
> |
struct Client *target) |
1234 |
|
{ |
1235 |
< |
dlink_node *ptr, *next_ptr; |
1304 |
< |
|
1305 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->allow_list.head) |
1306 |
< |
del_from_accept(ptr->data, client_p); |
1235 |
> |
dlink_node *ptr = NULL; |
1236 |
|
|
1237 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head) |
1238 |
< |
del_from_accept(client_p, ptr->data); |
1239 |
< |
} |
1237 |
> |
if (source == target || find_accept(source->name, source->username, |
1238 |
> |
source->host, target, 1)) |
1239 |
> |
return 1; |
1240 |
|
|
1241 |
< |
/* del_all_their_accepts() |
1242 |
< |
* |
1243 |
< |
* inputs - pointer to exiting client |
1244 |
< |
* output - NONE |
1316 |
< |
* side effects - Walk through given clients on_allow_list |
1317 |
< |
* remove all references to this client, |
1318 |
< |
* allow this client to keep their own allow_list |
1319 |
< |
*/ |
1320 |
< |
void |
1321 |
< |
del_all_their_accepts(struct Client *client_p) |
1322 |
< |
{ |
1323 |
< |
dlink_node *ptr, *next_ptr; |
1241 |
> |
if (IsSoftCallerId(target)) |
1242 |
> |
DLINK_FOREACH(ptr, target->channel.head) |
1243 |
> |
if (IsMember(source, ((struct Membership *)ptr->data)->chptr)) |
1244 |
> |
return 1; |
1245 |
|
|
1246 |
< |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head) |
1326 |
< |
del_from_accept(client_p, ptr->data); |
1246 |
> |
return 0; |
1247 |
|
} |
1248 |
|
|
1249 |
< |
/* set_initial_nick() |
1330 |
< |
* |
1331 |
< |
* inputs |
1332 |
< |
* output |
1333 |
< |
* side effects - |
1249 |
> |
/* del_all_accepts() |
1250 |
|
* |
1251 |
< |
* This function is only called to set up an initially registering |
1252 |
< |
* client. |
1251 |
> |
* inputs - pointer to exiting client |
1252 |
> |
* output - NONE |
1253 |
> |
* side effects - Walk through given clients acceptlist and remove all entries |
1254 |
|
*/ |
1255 |
|
void |
1256 |
< |
set_initial_nick(struct Client *client_p, struct Client *source_p, |
1340 |
< |
const char *nick) |
1256 |
> |
del_all_accepts(struct Client *client_p) |
1257 |
|
{ |
1258 |
< |
char buf[USERLEN + 1]; |
1343 |
< |
|
1344 |
< |
/* Client setting NICK the first time */ |
1345 |
< |
|
1346 |
< |
/* This had to be copied here to avoid problems.. */ |
1347 |
< |
source_p->tsinfo = CurrentTime; |
1348 |
< |
source_p->localClient->registration &= ~REG_NEED_NICK; |
1258 |
> |
dlink_node *ptr = NULL, *next_ptr = NULL; |
1259 |
|
|
1260 |
< |
if (source_p->name[0]) |
1261 |
< |
hash_del_client(source_p); |
1352 |
< |
|
1353 |
< |
strlcpy(source_p->name, nick, sizeof(source_p->name)); |
1354 |
< |
hash_add_client(source_p); |
1355 |
< |
|
1356 |
< |
/* fd_desc is long enough */ |
1357 |
< |
fd_note(&client_p->localClient->fd, "Nick: %s", nick); |
1358 |
< |
|
1359 |
< |
if (!source_p->localClient->registration) |
1360 |
< |
{ |
1361 |
< |
strlcpy(buf, source_p->username, sizeof(buf)); |
1362 |
< |
|
1363 |
< |
/* |
1364 |
< |
* USER already received, now we have NICK. |
1365 |
< |
* *NOTE* For servers "NICK" *must* precede the |
1366 |
< |
* user message (giving USER before NICK is possible |
1367 |
< |
* only for local client connection!). register_user |
1368 |
< |
* may reject the client and call exit_client for it |
1369 |
< |
* --must test this and exit m_nick too!!! |
1370 |
< |
*/ |
1371 |
< |
register_local_user(client_p, source_p, nick, buf); |
1372 |
< |
} |
1260 |
> |
DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->acceptlist.head) |
1261 |
> |
del_accept(ptr->data, client_p); |
1262 |
|
} |
1263 |
|
|
1264 |
|
/* change_local_nick() |
1297 |
|
|
1298 |
|
if (!samenick) |
1299 |
|
{ |
1411 |
– |
/* |
1412 |
– |
* Make sure everyone that has this client on its accept list |
1413 |
– |
* loses that reference. |
1414 |
– |
*/ |
1415 |
– |
del_all_their_accepts(source_p); |
1300 |
|
source_p->tsinfo = CurrentTime; |
1301 |
|
clear_ban_cache_client(source_p); |
1302 |
|
watch_check_hash(source_p, RPL_LOGOFF); |