summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mapping/mapping.c3
-rw-r--r--redir_scripts/main.lua24
-rwxr-xr-xutils/sb24
3 files changed, 27 insertions, 4 deletions
diff --git a/mapping/mapping.c b/mapping/mapping.c
index f74b819..4a2fbdc 100644
--- a/mapping/mapping.c
+++ b/mapping/mapping.c
@@ -188,6 +188,9 @@ static char *read_sb2cache(const char *binary_name, const char *func_name, const
{
char *link_path = NULL;
struct stat64 s;
+
+ if (getenv("SBOX_DISABLE_MAPPING_CACHE")) return NULL;
+
char *cache_path = create_sb2cache_path(binary_name, func_name, path);
if (lstat64(cache_path, &s) < 0 ||
diff --git a/redir_scripts/main.lua b/redir_scripts/main.lua
index 63e2101..58d2815 100644
--- a/redir_scripts/main.lua
+++ b/redir_scripts/main.lua
@@ -39,7 +39,7 @@ if (t ~= nil) then
local i = 0
local r = 0
table.sort(t)
- -- load the individual parts ($SBOX_REDIR_SCRIPTS/parts/*.lua)
+ -- load the individual parts ($SBOX_REDIR_SCRIPTS/preload/*.lua)
for n = 1,table.maxn(t) do
if (string.match(t[n], "%a*%.lua$")) then
-- print("loading part: " .. t[n])
@@ -67,7 +67,14 @@ if (t ~= nil) then
print("path not specified for a rule in " .. filename)
os.exit(1)
end
+ export_chains[i].rules[r].lua_script = filename
+ if (export_chains[i].binary) then
+ export_chains[i].rules[r].binary_name = export_chains[i].binary
+ else
+ export_chains[i].rules[r].binary_name = "nil"
+ end
end
+ export_chains[i].filename = filename
table.insert(chains, export_chains[i])
end
end
@@ -103,6 +110,17 @@ function dirname(path)
end
+function sb_debug(msg)
+ local logfile = os.getenv("SBOX_MAPPING_LOGFILE")
+ local f
+ local err
+ if (not logfile) then return end
+ f, err = io.open(logfile, "a+")
+ if (not f) then return end
+ f:write(msg .. "\n")
+ io.close(f)
+end
+
function sbox_map_to(binary_name, func_name, work_dir, rp, path, rule)
local ret = nil
if (rule.map_to) then
@@ -156,7 +174,7 @@ function sbox_translate_path(binary_name, func_name, work_dir, path)
-- loop through the chains, first match is used
for n=1,table.maxn(chains) do
- -- print(string.format("looping through rules: %s, %s, %s", rules[n].binary, rules[n].func_name, rules[n].path))
+ -- print(string.format("looping through chains: %s", chains[n].binary))
if (string.match(binary_name, chains[n].binary)) then
rule = find_rule(chains[n], func_name, rp)
if (not rule) then
@@ -169,7 +187,7 @@ function sbox_translate_path(binary_name, func_name, work_dir, path)
else
ret = sbox_map_to(binary_name, func_name, work_dir, rp, path, rule)
if (verbose) then
- print(string.format("[%i]%s: %s(%s) -> [%s]", n, binary_name, func_name, path, ret))
+ sb_debug(string.format("[%s][%s|%s]:\n %s(%s) -> (%s)", basename(rule.lua_script), rule.binary_name, binary_name, func_name, path, ret))
end
return ret
end
diff --git a/utils/sb2 b/utils/sb2
index e6ba95d..bb4875e 100755
--- a/utils/sb2
+++ b/utils/sb2
@@ -56,7 +56,9 @@ sb_map_verbose=$1
sb_bash_args=$*
if [ "$sb_map_verbose" == "--verbose" ]; then
- export SBOX_MAPPING_VERBOSE=1
+ export SBOX_MAPPING_VERBOSE=1 # enable mapping rules debug output
+ export SBOX_DISABLE_MAPPING_CACHE=1 # disable the cache to force use of lua engine
+ export SBOX_MAPPING_LOGFILE=$PWD/sb2_mapping.log
sb_bash_args=$(echo $* | sed 's/^--verbose//')
fi