mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-05 18:41:05 +00:00
Refactor ScriptApiSecurity for cleaner separation of concerns
This commit is contained in:
parent
4c44942a39
commit
1fd4e0b82d
11 changed files with 229 additions and 135 deletions
|
@ -494,18 +494,13 @@ int ModApiUtil::l_request_insecure_environment(lua_State *L)
|
|||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
|
||||
// Just return _G if security is disabled
|
||||
if (!ScriptApiSecurity::isSecure(L)) {
|
||||
lua_getglobal(L, "_G");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!ScriptApiSecurity::checkWhitelisted(L, "secure.trusted_mods")) {
|
||||
return 0;
|
||||
if (ScriptApiSecurity::isSecure(L)) {
|
||||
if (!ScriptApiSecurity::checkWhitelisted(L, "secure.trusted_mods"))
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Push insecure environment
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_GLOBALS_BACKUP);
|
||||
ScriptApiSecurity::getGlobalsBackup(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue