mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Allow sending an empty password to drop settings_access
This commit is contained in:
parent
38ebad6123
commit
2cad094725
@ -730,6 +730,7 @@ DEF_CONSOLE_CMD(ConSettingsAccess)
|
||||
{
|
||||
if (argc == 0) {
|
||||
IConsoleHelp("Enable changing game settings from this client. Usage: 'settings_access <password>'");
|
||||
IConsoleHelp("Send an empty password \"\" to drop access");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,11 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendCompanyPassword(const char
|
||||
NetworkRecvStatus ClientNetworkGameSocketHandler::SendSettingsPassword(const char *password)
|
||||
{
|
||||
Packet *p = new Packet(PACKET_CLIENT_SETTINGS_PASSWORD);
|
||||
p->Send_string(GenerateCompanyPasswordHash(password, _password_server_id, _settings_password_game_seed));
|
||||
if (StrEmpty(password)) {
|
||||
p->Send_string("");
|
||||
} else {
|
||||
p->Send_string(GenerateCompanyPasswordHash(password, _password_server_id, _settings_password_game_seed));
|
||||
}
|
||||
my_client->SendPacket(p);
|
||||
return NETWORK_RECV_STATUS_OKAY;
|
||||
}
|
||||
|
@ -1055,7 +1055,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_SETTINGS_PASSWO
|
||||
p->Recv_string(password, sizeof(password));
|
||||
|
||||
/* Check settings password. Deny if no password is set */
|
||||
if (StrEmpty(_settings_client.network.settings_password) ||
|
||||
if (StrEmpty(password)) {
|
||||
if (this->settings_authed) DEBUG(net, 0, "[settings-ctrl] client-id %d deauthed", this->client_id);
|
||||
this->settings_authed = false;
|
||||
} else if (StrEmpty(_settings_client.network.settings_password) ||
|
||||
strcmp(password, GenerateCompanyPasswordHash(_settings_client.network.settings_password, _settings_client.network.network_id, _settings_game.game_creation.generation_seed ^ this->settings_hash_bits)) != 0) {
|
||||
DEBUG(net, 0, "[settings-ctrl] wrong password from client-id %d", this->client_id);
|
||||
this->settings_authed = false;
|
||||
|
Loading…
Reference in New Issue
Block a user