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 dP
parent ca744dd7f9
commit e8a9b867dd

View File

@@ -2170,7 +2170,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;