function struct(tbl) local pat = tbl.endian or "=" local args = {} for i=1, do local a, b = pairs(tbl[i]) local k, v = a(b) args[i] = k pat = pat .. v end return setmetatable({}, {__call=function(_, arg) checkArg(1, arg, "string", "table") if (type(arg) == "string") then local sval = {string.unpack(pat, arg)} local rtn = {} for i=1, #args do rtn[args[i]] = sval[i] end return rtn, sval[#sval] elseif (type(arg) == "table") then local sval = {} for i=1, #args do sval[i] = arg[args[i]] end return string.pack(pat, unpack(sval)) end end, __len=function() return string.packsize(pat) end}) end function string.trim(self) return self:gsub("^%s+", ""):gsub("%s+$", "") end function string.explode(self, pat) local t, ll t={} ll=0 if(#p == 1) then return {p} end while true do l = string.find(self, pat, ll, true) -- find the next d in the string if l ~= nil then -- if "not not" found then.. table.insert(t, string.sub(self,ll,l-1)) -- Save it in our array. ll = l + 1 -- save just after where we found it for searching next time. else table.insert(t, string.sub(self,ll)) -- Save what's left in our array. break -- Break at end, as it should be, according to the lua manual. end end return t end ---@module security Security local security = {} ---@func checkacl ---@arg permission string "The permission to check." ---@return boolean "True if the current process has this permission." function security.checkacl(permission) local perms = acl.get("group", thread.info().egid, {}) end ---@func getmode ---@return string "The current security mode." function security.getmode() end function security.init() klog("security", 1, "Security init started.") end local velx = (function() local velx_spec = struct { endian = "<", {magic="c5"}, {fver="B"}, {compression="B"}, {lver="B"}, {os="B"}, {psize="I3"}, {lsize="I3"}, {ssize="I3"}, {rsize="I4"} } local velx = {} local exec = {} function velx.identify(path) local h = io.open(path, "rb") local header = velx_spec(h:read(#velx_spec)) h:close() return header.magic == "\27VelX" end function velx.load(path) end function velx.verify(path) local h = io.open(path, "rb") local header = velx_spec(h:read(#velx_spec)) local code = h:read(header.psize) h:seek("cur", lsize) local sig = h:read(header.ssize) h:close() return security.verify(code, sig) end function exec:link() self.file:seek("set", #velx_spec+self.header.psize) local linkinfo = self.file:read(self.header.lsize) local linker = {} local pos = 1 while true do local size = string.unpack("