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 | |
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')
-rw-r--r-- | src/qcommon/common.c | 12 | ||||
-rw-r--r-- | src/qcommon/qcommon.h | 2 | ||||
-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 |
6 files changed, 0 insertions, 149 deletions
diff --git a/src/qcommon/common.c b/src/qcommon/common.c index 59659ef0..275ea4ea 100644 --- a/src/qcommon/common.c +++ b/src/qcommon/common.c @@ -2599,18 +2599,6 @@ void Com_Init( char *commandLine ) { Sys_Init(); - if( Sys_WritePIDFile( ) ) { -#ifndef DEDICATED - const char *message = "The last time " CLIENT_WINDOW_TITLE " ran, " - "it didn't exit properly. This may be due to inappropriate video " - "settings. Would you like to start with \"safe\" video settings?"; - - if( Sys_Dialog( DT_YES_NO, message, "Abnormal Exit" ) == DR_YES ) { - Cvar_Set( "com_abnormalExit", "1" ); - } -#endif - } - // Pick a random port value Com_RandomBytes( (byte*)&qport, sizeof(int) ); Netchan_Init( qport & 0xffff ); diff --git a/src/qcommon/qcommon.h b/src/qcommon/qcommon.h index e8764ef3..c896ccbe 100644 --- a/src/qcommon/qcommon.h +++ b/src/qcommon/qcommon.h @@ -1112,8 +1112,6 @@ typedef enum dialogResult_t Sys_Dialog( dialogType_t type, const char *message, const char *title ); -qboolean Sys_WritePIDFile( void ); - /* This is based on the Adaptive Huffman algorithm described in Sayood's Data * Compression book. The ranks are not actually stored, but implicitly defined * by the location of a node within a doubly-linked list */ 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; -} |