1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2025-12-10 06:52:05 +01:00

Fix #14777: authorized_key: Correctly target key type for add/remove

The logic in ConNetworkAuthorizedKey for the `authorized_key` command was inverted.
The check `if (StrEqualsIgnoreCase(type, name)) continue;` caused the action (add/remove) to be incorrectly executed on the first key type encountered that *did not* match the requested type, rather than the intended one. This resulted in keys specified for 'admin' being added to 'rcon', for example.

This commit inverts the condition to ensure the action is performed only when the requested type matches the iterated key name.
This commit is contained in:
Muxy Du Goulp
2025-11-15 21:01:52 +01:00
committed by rubidium42
parent d61a21cc0b
commit 05c40a6e55

View File

@@ -2167,7 +2167,7 @@ static bool ConNetworkAuthorizedKey(std::span<std::string_view> argv)
}
for (auto [name, authorized_keys] : _console_cmd_authorized_keys) {
if (StrEqualsIgnoreCase(type, name)) continue;
if (!StrEqualsIgnoreCase(type, name)) continue;
PerformNetworkAuthorizedKeyAction(name, authorized_keys, action, authorized_key);
return true;