From 7db6fb3ca74d38a0c054233207b545836669785a Mon Sep 17 00:00:00 2001 From: raymoo Date: Thu, 17 Nov 2016 20:19:33 -0800 Subject: [PATCH] mod security compatibility --- exchange.lua | 3 ++- init.lua | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/exchange.lua b/exchange.lua index e3bfdee..316b10a 100644 --- a/exchange.lua +++ b/exchange.lua @@ -1,5 +1,6 @@ -local sql = require("lsqlite3") +local insecure_env = ... +local sql = insecure_env.require("lsqlite3") local exports = {} local init_query = [=[ diff --git a/init.lua b/init.lua index aed516b..460040d 100644 --- a/init.lua +++ b/init.lua @@ -1,16 +1,19 @@ +local insecure_env = minetest.request_insecure_environment() +assert(insecure_env, + "global_exchange needs to be trusted to run under mod security.") + local modpath = minetest.get_modpath(minetest.get_current_modname()) .. "/" local income = tonumber(minetest.setting_get("citizens_income")) or 10 - local income_interval = 1200 - local income_msg = "You receive your citizen's income (+" .. income .. ")" local next_payout = os.time() + income_interval -local exchange = (dofile(modpath .. "exchange.lua")).open_exchange( - minetest.get_worldpath() .. "/global_exchange.db" +local exchange = + assert(loadfile(modpath .. "exchange.lua"))(insecure_env).open_exchange( + minetest.get_worldpath() .. "/global_exchange.db" )