1
0
Fork 0

(svn r14711) -Codechange: don't misuse the _network_company_info password field for changing the password on clients.

release/0.7
rubidium 2008-12-22 18:20:28 +00:00
parent 887869c771
commit e6e32bad4d
3 changed files with 11 additions and 15 deletions

View File

@ -1210,14 +1210,14 @@ DEF_CONSOLE_CMD(ConSayClient)
return true; return true;
} }
extern void HashCurrentCompanyPassword(); extern void HashCurrentCompanyPassword(const char *password);
/* Also use from within company_gui to change the password graphically */ /* Also use from within company_gui to change the password graphically */
bool NetworkChangeCompanyPassword(byte argc, char *argv[]) bool NetworkChangeCompanyPassword(byte argc, char *argv[])
{ {
if (argc == 0) { if (argc == 0) {
if (!IsValidCompanyID(_local_company)) return true; // dedicated server IConsoleHelp("Change the password of your company. Usage: 'company_pw \"<password>\"'");
IConsolePrintF(CC_WARNING, "Current value for 'company_pw': %s", _network_company_info[_local_company].password); IConsoleHelp("Use \"*\" to disable the password.");
return true; return true;
} }
@ -1230,15 +1230,13 @@ bool NetworkChangeCompanyPassword(byte argc, char *argv[])
if (strcmp(argv[0], "*") == 0) argv[0][0] = '\0'; if (strcmp(argv[0], "*") == 0) argv[0][0] = '\0';
strecpy(_network_company_info[_local_company].password, argv[0], lastof(_network_company_info[_local_company].password));
if (!_network_server) { if (!_network_server) {
NetworkClientSetPassword(); NetworkClientSetPassword(argv[0]);
} else { } else {
HashCurrentCompanyPassword(); HashCurrentCompanyPassword(argv[0]);
} }
IConsolePrintF(CC_WARNING, "'company_pw' changed to: %s", _network_company_info[_local_company].password); IConsolePrintF(CC_WARNING, "'company_pw' changed to: %s", argv[0]);
return true; return true;
} }

View File

@ -79,14 +79,12 @@ static const char *GenerateCompanyPasswordHash(const char *password)
/** /**
* Hash the current company password; used when the server 'company' sets his/her password. * Hash the current company password; used when the server 'company' sets his/her password.
*/ */
void HashCurrentCompanyPassword() void HashCurrentCompanyPassword(const char *password)
{ {
if (StrEmpty(_network_company_info[_local_company].password)) return;
_password_game_seed = _settings_game.game_creation.generation_seed; _password_game_seed = _settings_game.game_creation.generation_seed;
strecpy(_password_server_unique_id, _settings_client.network.network_id, lastof(_password_server_unique_id)); strecpy(_password_server_unique_id, _settings_client.network.network_id, lastof(_password_server_unique_id));
const char *new_pw = GenerateCompanyPasswordHash(_network_company_info[_local_company].password); const char *new_pw = GenerateCompanyPasswordHash(password);
strecpy(_network_company_info[_local_company].password, new_pw, lastof(_network_company_info[_local_company].password)); strecpy(_network_company_info[_local_company].password, new_pw, lastof(_network_company_info[_local_company].password));
} }
@ -950,9 +948,9 @@ void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const
SEND_COMMAND(PACKET_CLIENT_CHAT)(action, type, dest, msg); SEND_COMMAND(PACKET_CLIENT_CHAT)(action, type, dest, msg);
} }
void NetworkClientSetPassword() void NetworkClientSetPassword(const char *password)
{ {
SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_company_info[_local_company].password); SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(password);
} }
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */

View File

@ -40,7 +40,7 @@ void NetworkUpdateClientInfo(ClientID client_id);
bool NetworkClientConnectGame(const char *host, uint16 port); bool NetworkClientConnectGame(const char *host, uint16 port);
void NetworkClientSendRcon(const char *password, const char *command); void NetworkClientSendRcon(const char *password, const char *command);
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg); void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg);
void NetworkClientSetPassword(); void NetworkClientSetPassword(const char *password);
/*** Commands ran by the server ***/ /*** Commands ran by the server ***/
void NetworkServerMonthlyLoop(); void NetworkServerMonthlyLoop();