]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
categorize anticheat features in safe, controversial, unsafe
authorRudolf Polzer <divverent@xonotic.org>
Sat, 13 Jul 2013 09:39:22 +0000 (11:39 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Sat, 13 Jul 2013 09:39:22 +0000 (11:39 +0200)
cmd.c
host_cmd.c
netconn.c
quakedef.h
sys.h
sys_linux.c
sys_sdl.c
sys_shared.c
vid_glx.c
vid_sdl.c
vid_wgl.c

diff --git a/cmd.c b/cmd.c
index 7d71050c70a0e1da67fc8cda315fa7c4604f0bc9..27f2c9a76b8d4412aa52b6502a0a5bb56b310ed3 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -94,7 +94,7 @@ static void Cmd_Defer_f (void)
                        Mem_Free(cmd);
                }
        } else if(Cmd_Argc() == 3
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_CONTROVERSIAL
                && (cls.state != ca_connected || cls.demoplayback)
 #endif
        )
@@ -121,7 +121,7 @@ static void Cmd_Defer_f (void)
                  cmd_deferred_list = defcmd;*/
        } else {
                Con_Printf("usage: defer <seconds> <command>\n"
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_CONTROVERSIAL
                           "         (only works while not connected)\n"
 #endif
                           "       defer clear\n");
@@ -386,7 +386,7 @@ void Cbuf_Execute (void)
 
 void Cbuf_Frame(void)
 {
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_CONTROVERSIAL
        if(cls.state != ca_connected || cls.demoplayback)
 #endif
        Cbuf_Execute_Deferred();
index 109726588ad721ecb60beea65473c1461da565b9..0e932af906c0a78d868d735f8706a3834a99db43 100644 (file)
@@ -3033,7 +3033,7 @@ void Host_InitCommands (void)
        Cmd_AddCommand ("pingplreport", Host_PingPLReport_f, "command sent by server containing client ping and packet loss values for scoreboard, triggered by pings command from client (not used by QW servers)");
 
        Cmd_AddCommand ("fixtrans", Image_FixTransparentPixels_f, "change alpha-zero pixels in an image file to sensible values, and write out a new TGA (warning: SLOW)");
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_UNSAFE
        Cmd_AddCommand ("checkmemory", Sys_AntiCheat_CheckMemory_f, "check memory for patterns");
 #endif
 
index 50f25522c90c195be06e19278721c68af2a83c0e..0c89fa9b923ac4a81b1ac7a1b1ee36fc0b418142 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -2627,7 +2627,7 @@ static const char *RCon_Authenticate(lhnetaddress_t *peeraddress, const char *pa
        qboolean have_usernames = false;
        char vabuf[1024];
 
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_CONTROVERSIAL
        if(cls.state != ca_dedicated)
                return NULL;
 #endif
index e5680f527f94bbef3c6c0a78d32279884eb16059..07d405d2fa8acfe32ad757e645bc78e0aa7d2b4f 100644 (file)
@@ -32,13 +32,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define DP_FUNC_NORETURN
 #endif
 
+// Security features:
+// HARDENING: disable some nasty things evil servers may do via stuffcmd
+// ANTICHEAT_SAFE: some safe anti-cheating means
+// ANTICHEAT_CONTROVERSIAL: some controversial anti-cheating means
+// ANTICHEAT_UNSAFE: some more problematic anti-cheating means
+
 #ifdef HARDENING
 # define IS_HARDENED false
 #else
 # define IS_HARDENED true
 #endif
 
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_UNSAFE
 # ifdef __linux__
 #  define _GNU_SOURCE // for memmem
 # endif
diff --git a/sys.h b/sys.h
index acce3acf016148fcb0461622db3c616276a78b45..6d992cd59a35f94af4ea2b9e6b673ac14492c025 100644 (file)
--- a/sys.h
+++ b/sys.h
@@ -117,7 +117,7 @@ void Sys_MakeProcessMean (void);
 
 // call this from main(); if it returns false, exit using return
 qboolean Sys_AntiCheat_Init(char **envp);
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_UNSAFE
 typedef enum
 {
        CHECKMEMORY_N_A,
index 50982ffb719e7a825ac3e44c7ffe59669e4b04cd..95fd865509d1083f1ccda9e14147adc4a907db01 100644 (file)
@@ -76,7 +76,7 @@ void Sys_PrintToTerminal(const char *text)
 
 char *Sys_ConsoleInput(void)
 {
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_CONTROVERSIAL
        if (cls.state == ca_dedicated)
 #endif
        {
index aadbe83d50f1d198cc01d41bfd38a232a9546e60..62e6addabd365d29f1239c2e4daf216ccdc09e49 100644 (file)
--- a/sys_sdl.c
+++ b/sys_sdl.c
@@ -83,7 +83,7 @@ void Sys_PrintToTerminal(const char *text)
 
 char *Sys_ConsoleInput(void)
 {
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_CONTROVERSIAL
        if (cls.state == ca_dedicated)
 #endif
        {
index 8297a87a4821a242647fe8d57bb510932d47c035..0d2f62fbeeedad1a0de5d6c12158a52ab01f3ed4 100644 (file)
@@ -641,7 +641,7 @@ void Sys_MakeProcessMean (void)
 }
 #endif
 
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_UNSAFE
 # ifndef WIN32
 #  include <sys/ptrace.h>
 #  include <sys/wait.h>
@@ -649,7 +649,7 @@ void Sys_MakeProcessMean (void)
 # endif
 #endif
 
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_UNSAFE
 // whole function only exists if anticheat is enabled
 Sys_AntiCheat_CheckMemory_Result_t Sys_AntiCheat_CheckMemory(const char *dllsubstring, qboolean dllsubstringmode, const void *pattern, size_t length)
 {
@@ -730,16 +730,14 @@ void Sys_AntiCheat_CheckMemory_f(void)
 
 qboolean Sys_AntiCheat_Init(char **envp)
 {
-#ifdef ANTICHEAT
-# define FAIL return false
-
+#ifdef ANTICHEAT_CONTROVERSIAL
        // anti LD_PRELOAD
        // note that we're using envp here, so one doesn't simply hook into getenv()
        static char *unsecure_envvars =
                // UNSECURE_ENVVARS from glibc
                "GCONV_PATH\0" // libraries are loaded from here
-               //"GETCONF_DIR\0" // harmless, can only fake getconf() output
-               //"HOSTALIASES\0" // harmless, just messes with DNS
+               // "GETCONF_DIR\0" // harmless, can only fake getconf() output
+               // "HOSTALIASES\0" // harmless, just messes with DNS
                "LD_AUDIT\0" // loads libraries
                // "LD_DEBUG\0" // harmless, just shows data
                // "LD_DEBUG_OUTPUT\0" // harmless, just shows data
@@ -759,6 +757,7 @@ qboolean Sys_AntiCheat_Init(char **envp)
                // "RES_OPTIONS\0" // harmless, just messes with DNS
                // "TMPDIR\0" // harmless, we don't use temp files anyway
                // "TZDIR\0" // harmless, just enables time travel
+
                // EXTRA_UNSECURE_ENVVARS from glibc
                "LD_AOUT_LIBRARY_PATH\0" // loads libraries
                "LD_AOUT_PRELOAD\0" // loads libraries
@@ -778,7 +777,7 @@ qboolean Sys_AntiCheat_Init(char **envp)
                                        ++q;
                                }
                                if(*p == 0 && *q == '=')
-                                       FAIL; // match!
+                                       return false; // match!
                                // next!
                                while(*p)
                                        ++p;
@@ -787,13 +786,15 @@ qboolean Sys_AntiCheat_Init(char **envp)
                        ++envp;
                }
        }
+#endif
 
+#ifdef ANTICHEAT_UNSAFE
 # ifndef WIN32
        // anti ptrace; also, make a forked process copy to detach from debuggers
        {
                pid_t pid = fork();
                if(pid < 0)
-                       FAIL;
+                       return false;
                if(pid == 0)
                {
                        // nothing to do here
@@ -805,14 +806,14 @@ qboolean Sys_AntiCheat_Init(char **envp)
                        if(ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0)
                        {
                                kill(pid, SIGKILL);
-                               FAIL;
+                               return false;
                        }
                        for(;;)
                        {
                                if(waitpid(pid, &status, 0) == (pid_t) -1)
                                {
                                        if(errno == ECHILD) // process no longer exists
-                                               FAIL;
+                                               return false;
                                }
                                if(WIFEXITED(status))
                                {
index d1d4545f4f1669ce70bb9d5fc2212d2393c111d6..7ca3ee6c95f29873ac63bbbe7df162de41c03b78 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -587,7 +587,7 @@ static void HandleEvents(void)
        {
                XNextEvent(vidx11_display, &event);
 
-#ifdef ANTICHEAT
+#ifdef ANTICHEAT_SAFE
                if(event.xany.send_event && event.type != MotionNotify)
                        continue;
                // note: synthetic MotionNotify already only change
@@ -1341,7 +1341,7 @@ static qboolean VID_InitModeGL(viddef_mode_t *mode)
        drivername = "libGL.so.1";
 #endif
 
-#ifndef ANTICHEAT
+#ifndef ANTICHEAT_CONTROVERSIAL
 // COMMANDLINEOPTION: Linux GLX: -gl_driver <drivername> selects a GL driver library, default is libGL.so.1, useful only for using fxmesa or similar, if you don't know what this is for, you don't need it
 // COMMANDLINEOPTION: BSD GLX: -gl_driver <drivername> selects a GL driver library, default is libGL.so.1, useful only for using fxmesa or similar, if you don't know what this is for, you don't need it
 // LordHavoc: although this works on MacOSX, it's useless there (as there is only one system libGL)
index 89db707b02b159b59e636bd4f8ff36cdb641d2db..e72f01f705c54da219efa948b044b515fa7b017d 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -2046,7 +2046,7 @@ static qboolean VID_InitModeGL(viddef_mode_t *mode)
        // SDL usually knows best
        drivername = NULL;
 
-#ifndef ANTICHEAT
+#ifndef ANTICHEAT_CONTROVERSIAL
 // COMMANDLINEOPTION: SDL GL: -gl_driver <drivername> selects a GL driver library, default is whatever SDL recommends, useful only for 3dfxogl.dll/3dfxvgl.dll or fxmesa or similar, if you don't know what this is for, you don't need it
        i = COM_CheckParm("-gl_driver");
        if (i && i < com_argc - 1)
index f764bc3171118c119fa0af755793bea7126d61e8..a8ed947a0e73cf71aad0e0fc9eb09672c3ebcb9e 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -994,7 +994,7 @@ qboolean VID_InitModeGL(viddef_mode_t *mode)
 
        gldrivername = "opengl32.dll";
 
-#ifndef ANTICHEAT
+#ifndef ANTICHEAT_CONTROVERSIAL
 // COMMANDLINEOPTION: Windows WGL: -gl_driver <drivername> selects a GL driver library, default is opengl32.dll, useful only for 3dfxogl.dll or 3dfxvgl.dll, if you don't know what this is for, you don't need it
        i = COM_CheckParm("-gl_driver");
        if (i && i < com_argc - 1)