diff options
author | /dev/humancontroller <devhc@example.com> | 2015-02-04 11:42:43 +0100 |
---|---|---|
committer | /dev/humancontroller <devhc@example.com> | 2017-03-09 13:51:06 +0100 |
commit | eabaabaaafe9daa690432059261143b0e4fecfe5 (patch) | |
tree | cba36c19c383b729a5fe63434a6dc9687abc9603 /src/sys | |
parent | 6aec9f7560daa005c513cde384f063f0b9b55dbc (diff) |
remove the (generally unsecure) use of PIDs and PID files
this includes the removal of the "safe mode" question feature
Diffstat (limited to 'src/sys')
-rw-r--r-- | src/sys/sys_local.h | 3 | ||||
-rw-r--r-- | src/sys/sys_main.c | 76 | ||||
-rw-r--r-- | src/sys/sys_unix.c | 20 | ||||
-rw-r--r-- | src/sys/sys_win32.c | 36 |
4 files changed, 0 insertions, 135 deletions
diff --git a/src/sys/sys_local.h b/src/sys/sys_local.h index 3c16876d..525c7990 100644 --- a/src/sys/sys_local.h +++ b/src/sys/sys_local.h @@ -56,6 +56,3 @@ void Sys_PlatformExit( void ); void Sys_SigHandler( int signal ) __attribute__ ((noreturn)); void Sys_ErrorDialog( const char *error ); void Sys_AnsiColorPrint( const char *msg ); - -int Sys_PID( void ); -qboolean Sys_PIDIsRunning( int pid ); diff --git a/src/sys/sys_main.c b/src/sys/sys_main.c index 45b2f6ba..24d501f1 100644 --- a/src/sys/sys_main.c +++ b/src/sys/sys_main.c @@ -149,73 +149,6 @@ char *Sys_GetClipboardData(void) #endif } -#ifdef DEDICATED -# define PID_FILENAME PRODUCT_NAME "_server.pid" -#else -# define PID_FILENAME PRODUCT_NAME ".pid" -#endif - -/* -================= -Sys_PIDFileName -================= -*/ -static char *Sys_PIDFileName( void ) -{ - const char *homePath = Cvar_VariableString( "fs_homepath" ); - - if( *homePath != '\0' ) - return va( "%s/%s", homePath, PID_FILENAME ); - - return NULL; -} - -/* -================= -Sys_WritePIDFile - -Return qtrue if there is an existing stale PID file -================= -*/ -qboolean Sys_WritePIDFile( void ) -{ - char *pidFile = Sys_PIDFileName( ); - FILE *f; - qboolean stale = qfalse; - - if( pidFile == NULL ) - return qfalse; - - // First, check if the pid file is already there - if( ( f = fopen( pidFile, "r" ) ) != NULL ) - { - char pidBuffer[ 64 ] = { 0 }; - int pid; - - pid = fread( pidBuffer, sizeof( char ), sizeof( pidBuffer ) - 1, f ); - fclose( f ); - - if(pid > 0) - { - pid = atoi( pidBuffer ); - if( !Sys_PIDIsRunning( pid ) ) - stale = qtrue; - } - else - stale = qtrue; - } - - if( ( f = fopen( pidFile, "w" ) ) != NULL ) - { - fprintf( f, "%d", Sys_PID( ) ); - fclose( f ); - } - else - Com_Printf( S_COLOR_YELLOW "Couldn't write %s.\n", pidFile ); - - return stale; -} - /* ================= Sys_Exit @@ -231,15 +164,6 @@ static __attribute__ ((noreturn)) void Sys_Exit( int exitCode ) SDL_Quit( ); #endif - if( exitCode < 2 ) - { - // Normal exit - char *pidFile = Sys_PIDFileName( ); - - if( pidFile != NULL ) - remove( pidFile ); - } - NET_Shutdown( ); Sys_PlatformExit( ); diff --git a/src/sys/sys_unix.c b/src/sys/sys_unix.c index f3dd0406..bc3cacf5 100644 --- a/src/sys/sys_unix.c +++ b/src/sys/sys_unix.c @@ -809,23 +809,3 @@ Unix specific deinitialisation void Sys_PlatformExit( void ) { } - -/* -============== -Sys_PID -============== -*/ -int Sys_PID( void ) -{ - return getpid( ); -} - -/* -============== -Sys_PIDIsRunning -============== -*/ -qboolean Sys_PIDIsRunning( int pid ) -{ - return kill( pid, 0 ) == 0; -} diff --git a/src/sys/sys_win32.c b/src/sys/sys_win32.c index 635b157f..6f251299 100644 --- a/src/sys/sys_win32.c +++ b/src/sys/sys_win32.c @@ -683,39 +683,3 @@ void Sys_PlatformExit( void ) timeEndPeriod(timerResolution); #endif } - -/* -============== -Sys_PID -============== -*/ -int Sys_PID( void ) -{ - return GetCurrentProcessId( ); -} - -/* -============== -Sys_PIDIsRunning -============== -*/ -qboolean Sys_PIDIsRunning( int pid ) -{ - DWORD processes[ 1024 ]; - DWORD numBytes, numProcesses; - int i; - - if( !EnumProcesses( processes, sizeof( processes ), &numBytes ) ) - return qfalse; // Assume it's not running - - numProcesses = numBytes / sizeof( DWORD ); - - // Search for the pid - for( i = 0; i < numProcesses; i++ ) - { - if( processes[ i ] == pid ) - return qtrue; - } - - return qfalse; -} |