Allow sending an empty password to drop settings_access

This commit is contained in:
Jonathan G Rennison 2020-09-29 18:21:06 +01:00
parent 38ebad6123
commit 2cad094725
3 changed files with 10 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;