I don't want to use a closure in the lua funcition, so i did a global var to set the sandbox path. Added build.requirements() and build.compile() to lua

This commit is contained in:
2025-08-20 13:37:24 -03:00
parent 4cd007886c
commit 8f07394cc0
2 changed files with 21 additions and 9 deletions

View File

@@ -1345,6 +1345,7 @@ func Unninstall(realname string) error {
defer L.Close()
if !Unsafe {
internal.SandboxDir = filepath.Join(cfg.Config.DataDir, realname)
osObject := L.GetGlobal("os").(*lua.LTable)
ioObject := L.GetGlobal("io").(*lua.LTable)
@@ -1358,6 +1359,14 @@ func Unninstall(realname string) error {
L.SetGlobal("path_join", L.NewFunction(internal.Ljoin))
// Packets build functions
build := L.NewTable()
L.SetField(build, "requirements", L.NewFunction(internal.CompileRequirements))
L.SetField(build, "compile", L.NewFunction(internal.LuaCompile))
L.SetGlobal("build", build)
osObject.RawSetString("execute", lua.LNil)
osObject.RawSetString("exit", lua.LNil)
osObject.RawSetString("getenv", lua.LNil)
@@ -1377,6 +1386,7 @@ func Unninstall(realname string) error {
ioObject.RawSetString("stdin", lua.LNil)
ioObject.RawSetString("lines", lua.LNil)
ioObject.RawSetString("open", L.NewFunction(internal.SafeOpen))
}
if err := L.DoFile(filepath.Join(cfg.Config.DataDir, realname, manifest.Hooks.Remove)); err != nil {