Luanti 5.19.0-dev
Loading...
Searching...
No Matches
s_security.cpp File Reference
#include "cpp_api/s_security.h"
#include "lua_api/l_base.h"
#include "filesys.h"
#include "util/hashing.h"
#include "util/hex.h"
#include "builtin_files.h"
#include "server.h"
#include "content/mods.h"
#include "settings.h"
#include "constants.h"
#include <cerrno>
#include <string>
#include <algorithm>
#include <iostream>
Include dependency graph for s_security.cpp:

Macros

#define SECURE_API(lib, name)
#define RETURN_WRITE_ALLOWED(v)

Functions

static void recursive_copy (lua_State *L, int idx, int t_global)
static void copy_safe (lua_State *L, const char *list[], unsigned len, int from=-2, int to=-1)
static void push_original (lua_State *L, const char *lib, const char *func)
static int l_nop (lua_State *L)
static void replace_string_metatable (lua_State *L)
static bool checkModNameWhitelisted (const std::string &mod_name, const std::string &setting)

Macro Definition Documentation

◆ RETURN_WRITE_ALLOWED

#define RETURN_WRITE_ALLOWED ( v)
Value:
do { \
bool real_write_allowed = (v); \
if (write_allowed) \
*write_allowed = real_write_allowed; \
return !write_required || real_write_allowed; \
} while (0)

Referenced by ScriptApiSecurity::checkPathWithGamedef().

◆ SECURE_API

#define SECURE_API ( lib,
name )
Value:
lua_pushcfunction(L, sl_##lib##_##name); \
lua_setfield(L, -2, #name);
#define _(String)
Definition gettext.h:28

Referenced by ScriptApiSecurity::initializeSecurity().

Function Documentation

◆ checkModNameWhitelisted()

bool checkModNameWhitelisted ( const std::string & mod_name,
const std::string & setting )
static

References checkModNameWhitelisted(), CONTAINS, g_settings, Settings::get(), str_split(), and str_starts_with().

Referenced by checkModNameWhitelisted(), and ScriptApiSecurity::checkWhitelisted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_safe()

void copy_safe ( lua_State * L,
const char * list[],
unsigned len,
int from = -2,
int to = -1 )
inlinestatic

References copy_safe(), and recursive_copy().

Referenced by copy_safe(), and ScriptApiSecurity::initializeSecurity().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ l_nop()

int l_nop ( lua_State * L)
static

References l_nop().

Referenced by ScriptApiSecurity::initializeSecurity(), and l_nop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ push_original()

void push_original ( lua_State * L,
const char * lib,
const char * func )
inlinestatic

References CUSTOM_RIDX_GLOBALS_BACKUP, and push_original().

Referenced by push_original(), ScriptApiSecurity::sl_debug_getinfo(), ScriptApiSecurity::sl_io_input(), ScriptApiSecurity::sl_io_lines(), ScriptApiSecurity::sl_io_open(), ScriptApiSecurity::sl_io_output(), ScriptApiSecurity::sl_os_remove(), ScriptApiSecurity::sl_os_rename(), and ScriptApiSecurity::sl_os_setlocale().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ recursive_copy()

void recursive_copy ( lua_State * L,
int idx,
int t_global )
static

References idx, and recursive_copy().

Referenced by copy_safe(), and recursive_copy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replace_string_metatable()

void replace_string_metatable ( lua_State * L)
inlinestatic

References replace_string_metatable().

Referenced by ScriptApiSecurity::initializeSecurity(), and replace_string_metatable().

Here is the call graph for this function:
Here is the caller graph for this function: