• R/O
  • SSH

zandronum-sandbox-stable: Commit


Commit MetaInfo

Revision144001a99a3bda2dadabaebc66d396f343936458 (tree)
Time2022-09-16 23:44:02
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Added the CCMD "rcon_logout" so that clients with RCON access may logout if they want to. This also changes the old behaviour where a client who already had RCON access could lose it if they resent the wrong password to the server.

Change Summary

Incremental Difference

diff -r c73c3e63f676 -r 144001a99a3b docs/zandronum-history.txt
--- a/docs/zandronum-history.txt Fri Sep 16 10:16:18 2022 -0400
+++ b/docs/zandronum-history.txt Fri Sep 16 10:44:02 2022 -0400
@@ -32,6 +32,7 @@
3232 + - Added the dmflag "sv_dontoverrideplayercolors", which prevents player colors from being overriden. [Kaminsky]
3333 + - Added the EVENT script types for domination: GAMEEVENT_DOMINATION_CONTROL for when a team takes control of a point sector, and GAMEEVENT_DOMINATION_POINT for when a team gets a point for owning a sector. [Kaminsky]
3434 + - Added the CVar "cl_identifymonsters" which allows monsters to be identified with cl_identifytarget. [Kaminsky]
35++ - Added the CCMD "rcon_logout" so that clients with RCON access may logout if they want to. This also changes the old behaviour where a client who already had RCON access could lose it if they resent the wrong password to the server. [Kaminsky]
3536 - - Fixed: clients didn't initialize a sector's friction properly in some cases due to a superfluous check that wasn't removed earlier. [Kaminsky]
3637 - - Fixed: the server wouldn't initialize compatflags and compatflags2 properly if entered as command line parameters. [Kaminsky]
3738 - - Fixed: serverinfo CVars entered on the command line were restored in reverse order. [Kaminsky]
diff -r c73c3e63f676 -r 144001a99a3b src/cl_commands.cpp
--- a/src/cl_commands.cpp Fri Sep 16 10:16:18 2022 -0400
+++ b/src/cl_commands.cpp Fri Sep 16 10:44:02 2022 -0400
@@ -577,10 +577,14 @@
577577
578578 //*****************************************************************************
579579 //
580-void CLIENTCOMMANDS_RequestRCON( const char *pszRCONPassword )
580+void CLIENTCOMMANDS_ChangeRCONStatus( const bool bIsLoggingIn, const char *pszRCONPassword )
581581 {
582- CLIENT_GetLocalBuffer( )->ByteStream.WriteByte( CLC_REQUESTRCON );
583- CLIENT_GetLocalBuffer( )->ByteStream.WriteString( pszRCONPassword );
582+ CLIENT_GetLocalBuffer( )->ByteStream.WriteByte( CLC_CHANGERCONSTATUS );
583+ CLIENT_GetLocalBuffer( )->ByteStream.WriteByte( bIsLoggingIn );
584+
585+ // [AK] It's only necessary to send the RCON password if we're trying to log in.
586+ if ( bIsLoggingIn )
587+ CLIENT_GetLocalBuffer( )->ByteStream.WriteString( pszRCONPassword );
584588 }
585589
586590 //*****************************************************************************
diff -r c73c3e63f676 -r 144001a99a3b src/cl_commands.h
--- a/src/cl_commands.h Fri Sep 16 10:16:18 2022 -0400
+++ b/src/cl_commands.h Fri Sep 16 10:44:02 2022 -0400
@@ -88,7 +88,7 @@
8888 void CLIENTCOMMANDS_Taunt( void );
8989 void CLIENTCOMMANDS_Spectate( void );
9090 void CLIENTCOMMANDS_RequestJoin( const char *pszJoinPassword );
91-void CLIENTCOMMANDS_RequestRCON( const char *pszRCONPassword );
91+void CLIENTCOMMANDS_ChangeRCONStatus( bool bIsLoggingIn, const char *pszRCONPassword );
9292 void CLIENTCOMMANDS_RCONCommand( const char *pszCommand );
9393 void CLIENTCOMMANDS_Suicide( void );
9494 void CLIENTCOMMANDS_ChangeTeam( const char *pszJoinPassword, LONG lDesiredTeam );
diff -r c73c3e63f676 -r 144001a99a3b src/cl_main.cpp
--- a/src/cl_main.cpp Fri Sep 16 10:16:18 2022 -0400
+++ b/src/cl_main.cpp Fri Sep 16 10:44:02 2022 -0400
@@ -2272,6 +2272,10 @@
22722272 }
22732273 else
22742274 {
2275+ // [AK] Close the server setup menu if we're still in it.
2276+ if ( M_InServerSetupMenu( ))
2277+ M_ClearMenus( );
2278+
22752279 g_HasRCONAccess = false;
22762280 }
22772281 break;
@@ -9496,7 +9500,15 @@
94969500 }
94979501
94989502 if ( g_ConnectionState == CTS_ACTIVE )
9499- CLIENTCOMMANDS_RequestRCON( argv[1] );
9503+ CLIENTCOMMANDS_ChangeRCONStatus( true, argv[1] );
9504+}
9505+
9506+//*****************************************************************************
9507+//
9508+CCMD( rcon_logout )
9509+{
9510+ if ( g_ConnectionState == CTS_ACTIVE )
9511+ CLIENTCOMMANDS_ChangeRCONStatus( false, NULL );
95009512 }
95019513
95029514 //*****************************************************************************
diff -r c73c3e63f676 -r 144001a99a3b src/network_enums.h
--- a/src/network_enums.h Fri Sep 16 10:16:18 2022 -0400
+++ b/src/network_enums.h Fri Sep 16 10:44:02 2022 -0400
@@ -413,7 +413,7 @@
413413 ENUM_ELEMENT( CLC_TAUNT ),
414414 ENUM_ELEMENT( CLC_SPECTATE ),
415415 ENUM_ELEMENT( CLC_REQUESTJOIN ),
416- ENUM_ELEMENT( CLC_REQUESTRCON ),
416+ ENUM_ELEMENT( CLC_CHANGERCONSTATUS ),
417417 ENUM_ELEMENT( CLC_RCONCOMMAND ),
418418 ENUM_ELEMENT( CLC_SUICIDE ),
419419 ENUM_ELEMENT( CLC_CHANGETEAM ),
diff -r c73c3e63f676 -r 144001a99a3b src/sv_main.cpp
--- a/src/sv_main.cpp Fri Sep 16 10:16:18 2022 -0400
+++ b/src/sv_main.cpp Fri Sep 16 10:44:02 2022 -0400
@@ -4826,7 +4826,7 @@
48264826
48274827 // Client wishes to join the game after spectating.
48284828 return ( server_RequestJoin( pByteStream ));
4829- case CLC_REQUESTRCON:
4829+ case CLC_CHANGERCONSTATUS:
48304830
48314831 // Client is attempting to gain remote control access to the server.
48324832 return ( server_RequestRCON( pByteStream ));
@@ -6372,29 +6372,54 @@
63726372 static bool server_RequestRCON( BYTESTREAM_s *pByteStream )
63736373 {
63746374 const char *pszUserPassword;
6375-
6376- // If the user password matches our PW, and we have a PW set, give him RCON access.
6377- pszUserPassword = pByteStream->ReadString();
6375+ const bool bIsLoggingIn = !!pByteStream->ReadByte(); // [AK]
63786376
63796377 // [BB] If the client is flooding the server with commands, the client is
63806378 // kicked and we don't need to handle the command.
63816379 if ( server_CheckForClientCommandFlood ( g_lCurrentClient ) == true )
63826380 return ( true );
63836381
6384- if (( strlen( sv_rconpassword ) > 0 ) && ( strcmp( sv_rconpassword, pszUserPassword ) == 0 ))
6385- {
6386- g_aClients[g_lCurrentClient].bRCONAccess = true;
6387- SERVER_PrintfPlayer( g_lCurrentClient, "RCON access granted.\n" );
6388- Printf( "RCON access for %s is granted!\n", players[g_lCurrentClient].userinfo.GetName() );
6382+ if ( bIsLoggingIn )
6383+ {
6384+ // If the user password matches our PW, and we have a PW set, give him RCON access.
6385+ pszUserPassword = pByteStream->ReadString();
6386+
6387+ if ( g_aClients[g_lCurrentClient].bRCONAccess )
6388+ {
6389+ SERVER_PrintfPlayer( g_lCurrentClient, "You already have RCON access.\n" );
6390+ return ( false );
6391+ }
6392+
6393+ if (( strlen( sv_rconpassword ) > 0 ) && ( strcmp( sv_rconpassword, pszUserPassword ) == 0 ))
6394+ {
6395+ g_aClients[g_lCurrentClient].bRCONAccess = true;
6396+ SERVER_PrintfPlayer( g_lCurrentClient, "RCON access granted.\n" );
6397+ Printf( "RCON access for %s is granted!\n", players[g_lCurrentClient].userinfo.GetName() );
6398+
6399+ SERVERCOMMANDS_RCONAccess( g_lCurrentClient );
6400+ }
6401+ else
6402+ {
6403+ g_aClients[g_lCurrentClient].bRCONAccess = false;
6404+ SERVER_PrintfPlayer( g_lCurrentClient, "Incorrect RCON password.\n" );
6405+ Printf( "Incorrect RCON password attempt from %s.\n", players[g_lCurrentClient].userinfo.GetName() );
6406+ }
63896407 }
63906408 else
63916409 {
6410+ if ( g_aClients[g_lCurrentClient].bRCONAccess == false )
6411+ {
6412+ SERVER_PrintfPlayer( g_lCurrentClient, "You don't have RCON access.\n" );
6413+ return ( false );
6414+ }
6415+
63926416 g_aClients[g_lCurrentClient].bRCONAccess = false;
6393- SERVER_PrintfPlayer( g_lCurrentClient, "Incorrect RCON password.\n" );
6394- Printf( "Incorrect RCON password attempt from %s.\n", players[g_lCurrentClient].userinfo.GetName() );
6395- }
6396-
6397- SERVERCOMMANDS_RCONAccess( g_lCurrentClient );
6417+ SERVER_PrintfPlayer( g_lCurrentClient, "You have logged out of RCON.\n" );
6418+ Printf( "%s has logged out of RCON.\n", players[g_lCurrentClient].userinfo.GetName() );
6419+
6420+ SERVERCOMMANDS_RCONAccess( g_lCurrentClient );
6421+ }
6422+
63986423 return ( false );
63996424 }
64006425
diff -r c73c3e63f676 -r 144001a99a3b wadsrc/static/menudef.za
--- a/wadsrc/static/menudef.za Fri Sep 16 10:16:18 2022 -0400
+++ b/wadsrc/static/menudef.za Fri Sep 16 10:44:02 2022 -0400
@@ -619,6 +619,7 @@
619619 Submenu "Voting setup", "ZA_VotingSetupMenu"
620620 Submenu "Gameplay Options", "GameplayOptions"
621621 Submenu "Compatibility Options", "CompatibilityOptions"
622+ Command "Log out of RCON", "rcon_logout"
622623 StaticText " "
623624 TextField "Server name", "sv_hostname"
624625 TextField "Website", "sv_website"
Show on old repository browser