1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-05 08:33:14 +02:00

Multiple fixes related to ban actions:

1) Fix issue if HOOKTYPE_IS_HANDSHAKE_FINISHED rejects the user
2) Fix authprompt issue. We now allow adding the TKL in
   place_ban_host() for soft-kline/etc. Previously all the
   soft-kline/gline/zline/gzline acted like soft-kill.
3) The blacklist module did not allow clients in with action 'warn',
   reported by westor in https://bugs.unrealircd.org/view.php?id=5501
This commit is contained in:
Bram Matthys
2020-01-02 14:25:28 +01:00
parent 7278c9c8f4
commit d7d673faf2
4 changed files with 33 additions and 27 deletions
+4 -2
View File
@@ -396,7 +396,8 @@ int authprompt_place_host_ban(Client *client, int action, char *reason, long dur
/* And tag the user */
authprompt_tag_as_auth_required(client);
return 0; /* pretend user is exempt */
authprompt_send_auth_required_message(client);
return 1; /* pretend user is killed */
}
return 99; /* no action taken, proceed normally */
}
@@ -418,7 +419,8 @@ int authprompt_find_tkline_match(Client *client, TKL *tkl)
/* And tag the user */
authprompt_tag_as_auth_required(client);
return 0; /* pretend user is exempt */
authprompt_send_auth_required_message(client);
return 1; /* pretend user is killed */
}
return 99; /* no action taken, proceed normally */
}
+7 -4
View File
@@ -719,11 +719,13 @@ int blacklist_parse_reply(struct hostent *he, int entry)
* from blacklist_preconnect() for softbans that need to be delayed
* as to give the user the opportunity to do SASL Authentication.
*/
void blacklist_action(Client *client, char *opernotice, BanAction ban_action, char *ban_reason, long ban_time)
int blacklist_action(Client *client, char *opernotice, BanAction ban_action, char *ban_reason, long ban_time)
{
sendto_snomask(SNO_BLACKLIST, "%s", opernotice);
ircd_log(LOG_KILL, "%s", opernotice);
place_host_ban(client, ban_action, ban_reason, ban_time);
if (ban_action == BAN_ACT_WARN)
return 0;
return place_host_ban(client, ban_action, ban_reason, ban_time);
}
void blacklist_hit(Client *client, Blacklist *bl, int reply)
@@ -833,6 +835,7 @@ int blacklist_preconnect(Client *client)
if (IsLoggedIn(client))
return HOOK_CONTINUE; /* yup, so the softban does not apply. */
blacklist_action(client, blu->save_opernotice, blu->save_action, blu->save_reason, blu->save_tkltime);
return HOOK_DENY;
if (blacklist_action(client, blu->save_opernotice, blu->save_action, blu->save_reason, blu->save_tkltime))
return HOOK_DENY;
return HOOK_CONTINUE; /* exempt */
}
+18 -17
View File
@@ -254,7 +254,6 @@ CMD_FUNC(cmd_nick_local)
Membership *mp;
long lastnick = 0l;
int differ = 1, update_watch = 1;
unsigned char newusr = 0;
unsigned char removemoder = (client->umodes & UMODE_REGNICK) ? 1 : 0;
Hook *h;
int i = 0;
@@ -395,10 +394,17 @@ CMD_FUNC(cmd_nick_local)
client->lastnick = TStime();
if (!register_user(client, nick, client->user->username, NULL, NULL, NULL))
return;
strlcpy(nick, client->name, sizeof(nick)); /* don't ask, but I need this. do not remove! -- Syzop */
update_watch = 0;
newusr = 1;
{
if (IsDead(client))
return;
/* ..otherwise.. fallthrough so we run the same code
* as in case of !is_handshake_finished()
*/
} else {
/* New user! */
update_watch = 0; /* already done in register_user() */
strlcpy(nick, client->name, sizeof(nick)); /* don't ask, but I need this. do not remove! -- Syzop */
}
}
} else
if (MyUser(client))
@@ -469,23 +475,18 @@ CMD_FUNC(cmd_nick_local)
/* Someone changing nicks in the pre-registered phase */
}
if (update_watch && client->name[0])
{
del_from_client_hash_table(client->name, client);
if (IsUser(client))
hash_check_watch(client, RPL_LOGOFF);
}
del_from_client_hash_table(client->name, client);
if (update_watch && IsUser(client))
hash_check_watch(client, RPL_LOGOFF);
strlcpy(client->name, nick, sizeof(client->name));
add_to_client_hash_table(nick, client);
/* update fdlist --nenolod */
if (MyConnect(client))
{
snprintf(descbuf, sizeof(descbuf), "Client: %s", nick);
fd_desc(client->local->fd, descbuf);
}
snprintf(descbuf, sizeof(descbuf), "Client: %s", nick);
fd_desc(client->local->fd, descbuf);
if (IsUser(client) && update_watch)
if (update_watch && IsUser(client))
hash_check_watch(client, RPL_LOGON);
if (removemoder && MyUser(client))
+4 -4
View File
@@ -4088,8 +4088,6 @@ int _place_host_ban(Client *client, BanAction action, char *reason, long duratio
if (IsSoftBanAction(action) && IsLoggedIn(client))
return 0;
RunHookReturnInt4(HOOKTYPE_PLACE_HOST_BAN, client, action, reason, duration, !=99);
switch(action)
{
case BAN_ACT_TEMPSHUN:
@@ -4164,16 +4162,18 @@ int _place_host_ban(Client *client, BanAction action, char *reason, long duratio
tkllayer[7] = mo2;
tkllayer[8] = reason;
cmd_tkl(&me, NULL, 9, tkllayer);
RunHookReturnInt4(HOOKTYPE_PLACE_HOST_BAN, client, action, reason, duration, !=99);
if ((action == BAN_ACT_SHUN) || (action == BAN_ACT_SOFT_SHUN))
{
find_shun(client);
return 1;
} else
return find_tkline_match(client, 0);
} /* else.. */
return find_tkline_match(client, 0);
}
case BAN_ACT_SOFT_KILL:
case BAN_ACT_KILL:
default:
RunHookReturnInt4(HOOKTYPE_PLACE_HOST_BAN, client, action, reason, duration, !=99);
exit_client(client, NULL, reason);
return 1;
}