mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Implement script sandboxing for main menu
This commit is contained in:
parent
1fd4e0b82d
commit
ea4ae55e24
10 changed files with 146 additions and 126 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "cpp_api/s_base.h"
|
||||
#include "cpp_api/s_mainmenu.h"
|
||||
#include "cpp_api/s_security.h"
|
||||
#include "cpp_api/s_async.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -14,7 +15,8 @@
|
|||
|
||||
class MainMenuScripting
|
||||
: virtual public ScriptApiBase,
|
||||
public ScriptApiMainMenu
|
||||
public ScriptApiMainMenu,
|
||||
public ScriptApiSecurity
|
||||
{
|
||||
public:
|
||||
MainMenuScripting(GUIEngine* guiengine);
|
||||
|
@ -29,6 +31,19 @@ public:
|
|||
u32 queueAsync(std::string &&serialized_func,
|
||||
std::string &&serialized_param);
|
||||
|
||||
// Is the main menu allowed writeable access to this path?
|
||||
static bool mayModifyPath(const std::string &path);
|
||||
|
||||
// (public implementation so it can be used from AsyncEngine)
|
||||
static bool checkPathAccess(const std::string &abs_path, bool write_required,
|
||||
bool *write_allowed);
|
||||
|
||||
protected:
|
||||
bool checkPathInternal(const std::string &abs_path, bool write_required,
|
||||
bool *write_allowed) override {
|
||||
return checkPathAccess(abs_path, write_required, write_allowed);
|
||||
}
|
||||
|
||||
private:
|
||||
void initializeModApi(lua_State *L, int top);
|
||||
static void registerLuaClasses(lua_State *L, int top);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue