Allow sending an empty password to drop settings_access
This commit is contained in:
@@ -730,6 +730,7 @@ DEF_CONSOLE_CMD(ConSettingsAccess)
|
|||||||
{
|
{
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
IConsoleHelp("Enable changing game settings from this client. Usage: 'settings_access <password>'");
|
IConsoleHelp("Enable changing game settings from this client. Usage: 'settings_access <password>'");
|
||||||
|
IConsoleHelp("Send an empty password \"\" to drop access");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -459,7 +459,11 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendCompanyPassword(const char
|
|||||||
NetworkRecvStatus ClientNetworkGameSocketHandler::SendSettingsPassword(const char *password)
|
NetworkRecvStatus ClientNetworkGameSocketHandler::SendSettingsPassword(const char *password)
|
||||||
{
|
{
|
||||||
Packet *p = new Packet(PACKET_CLIENT_SETTINGS_PASSWORD);
|
Packet *p = new Packet(PACKET_CLIENT_SETTINGS_PASSWORD);
|
||||||
|
if (StrEmpty(password)) {
|
||||||
|
p->Send_string("");
|
||||||
|
} else {
|
||||||
p->Send_string(GenerateCompanyPasswordHash(password, _password_server_id, _settings_password_game_seed));
|
p->Send_string(GenerateCompanyPasswordHash(password, _password_server_id, _settings_password_game_seed));
|
||||||
|
}
|
||||||
my_client->SendPacket(p);
|
my_client->SendPacket(p);
|
||||||
return NETWORK_RECV_STATUS_OKAY;
|
return NETWORK_RECV_STATUS_OKAY;
|
||||||
}
|
}
|
||||||
|
@@ -1055,7 +1055,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_SETTINGS_PASSWO
|
|||||||
p->Recv_string(password, sizeof(password));
|
p->Recv_string(password, sizeof(password));
|
||||||
|
|
||||||
/* Check settings password. Deny if no password is set */
|
/* 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) {
|
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);
|
DEBUG(net, 0, "[settings-ctrl] wrong password from client-id %d", this->client_id);
|
||||||
this->settings_authed = false;
|
this->settings_authed = false;
|
||||||
|
Reference in New Issue
Block a user