]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/script/cpp_api/s_security.cpp
Revert "Make Lint Happy"
[dragonfireclient.git] / src / script / cpp_api / s_security.cpp
index 2afa3a191d1ce7b8b451c89cebba44570dc24caa..9d65819c0ed0d61988a72e27e290c030e3e4ea36 100644 (file)
@@ -90,6 +90,7 @@ void ScriptApiSecurity::initializeSecurity()
                "math",
        };
        static const char *io_whitelist[] = {
+               "open",
                "close",
                "flush",
                "read",
@@ -173,7 +174,7 @@ void ScriptApiSecurity::initializeSecurity()
        copy_safe(L, io_whitelist, sizeof(io_whitelist));
 
        // And replace unsafe ones
-       SECURE_API(io, open);
+       //SECURE_API(io, open);
        SECURE_API(io, input);
        SECURE_API(io, output);
        SECURE_API(io, lines);
@@ -267,7 +268,6 @@ void ScriptApiSecurity::initializeSecurityClient()
                "getinfo",
                "traceback"
        };
-
 #if USE_LUAJIT
        static const char *jit_whitelist[] = {
                "arch",
@@ -287,6 +287,10 @@ void ScriptApiSecurity::initializeSecurityClient()
        lua_State *L = getStack();
        int thread = getThread(L);
 
+       // Backup globals to the registry
+       lua_getglobal(L, "_G");
+       lua_rawseti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_GLOBALS_BACKUP);
+
        // create an empty environment
        createEmptyEnv(L);
 
@@ -303,8 +307,6 @@ void ScriptApiSecurity::initializeSecurityClient()
        SECURE_API(g, require);
        lua_pop(L, 2);
 
-
-
        // Copy safe OS functions
        lua_getglobal(L, "os");
        lua_newtable(L);
@@ -319,6 +321,7 @@ void ScriptApiSecurity::initializeSecurityClient()
        copy_safe(L, debug_whitelist, sizeof(debug_whitelist));
        lua_setfield(L, -3, "debug");
        lua_pop(L, 1);  // Pop old debug
+       
 
 #if USE_LUAJIT
        // Copy safe jit functions, if they exist