diff options
author | Lauri Aarnio <Lauri.Aarnio@iki.fi> | 2008-10-09 12:00:50 +0300 |
---|---|---|
committer | Lauri Leukkunen <lle@rahina.org> | 2008-10-18 15:18:15 +0300 |
commit | bb32ad6c4372e62346ee5cfdc50479e1788e2084 (patch) | |
tree | 09e7ec87696b2a8ad570e67232dbcfa4a791b0c5 /lua_scripts | |
parent | 0de2d64763a7f827d67cad3360c84ce09a001c92 (diff) |
Optimized C/Lua interface and path resolution logic (performance optimizations)
Diffstat (limited to 'lua_scripts')
-rw-r--r-- | lua_scripts/main.lua | 5 | ||||
-rw-r--r-- | lua_scripts/mapping.lua | 42 |
2 files changed, 22 insertions, 25 deletions
diff --git a/lua_scripts/main.lua b/lua_scripts/main.lua index 9e141fe..b880af0 100644 --- a/lua_scripts/main.lua +++ b/lua_scripts/main.lua @@ -13,8 +13,9 @@ debug_messages_enabled = sb.debug_messages_enabled() -- Increment the serial number (first number) and update the initials -- and date whenever the interface beween Lua and C is changed. -- --- NOTE: the corresponding identifier for C is in include/sb2.h -sb2_lua_c_interface_version = "28,lta-2008-09-23" +-- NOTE: the corresponding identifier for C is in include/sb2.h, +-- see that file for description about differences +sb2_lua_c_interface_version = "35,lta-2008-10-01" function do_file(filename) if (debug_messages_enabled) then diff --git a/lua_scripts/mapping.lua b/lua_scripts/mapping.lua index 55fa8c7..1944e8a 100644 --- a/lua_scripts/mapping.lua +++ b/lua_scripts/mapping.lua @@ -197,7 +197,7 @@ end -- returns path and readonly_flag function sbox_execute_conditional_actions(binary_name, - func_name, work_dir, rp, path, rule) + func_name, rp, path, rule) local actions = rule.actions local a @@ -246,7 +246,7 @@ function sbox_execute_conditional_actions(binary_name, end -- returns exec_policy, path and readonly_flag -function sbox_execute_rule(binary_name, func_name, work_dir, rp, path, rule) +function sbox_execute_rule(binary_name, func_name, rp, path, rule) local ret_exec_policy = nil local ret_path = nil local ret_ro = false @@ -264,7 +264,7 @@ function sbox_execute_rule(binary_name, func_name, work_dir, rp, path, rule) -- FIXME: sbox_execute_conditional_actions should also -- be able to return exec_policy ret_path, ret_ro = sbox_execute_conditional_actions(binary_name, - func_name, work_dir, rp, path, rule) + func_name, rp, path, rule) elseif (rule.map_to) then if (rule.map_to == "/") then ret_path = path @@ -349,9 +349,16 @@ function find_rule(chain, func, full_path) return nil, 0 end --- returns the same values as sbox_translate_path --- (rule,exec_policy,path,ro_flag): -function map_using_rule(rule, binary_name, func_name, work_dir, path) +-- sbox_translate_path is the function called from libsb2.so +-- preload library and the FUSE system for each path that needs +-- translating. +-- +-- returns: +-- 1. the rule used to perform the mapping +-- 2. exec_policy +-- 3. path (mapping result) +-- 4. "readonly" flag +function sbox_translate_path(rule, binary_name, func_name, path) local ret = path local rp = path local readonly_flag = false @@ -364,7 +371,7 @@ function map_using_rule(rule, binary_name, func_name, work_dir, path) end if (debug_messages_enabled) then - sb.log("noise", string.format("map:%s:%s", work_dir, path)) + sb.log("noise", string.format("map:%s", path)) end if (rule.log_level) then @@ -378,30 +385,19 @@ function map_using_rule(rule, binary_name, func_name, work_dir, path) end if (rule.custom_map_func ~= nil) then - ret = rule.custom_map_func(binary_name, func_name, work_dir, rp, path, rules[n]) + -- FIXME: no work_dir, can't give it to custom_map_funct!! + ret = rule.custom_map_func(binary_name, func_name, "", rp, path, rules[n]) if (rule.readonly ~= nil) then readonly_flag = rule.readonly end else - exec_policy, ret, readonly_flag = sbox_execute_rule(binary_name, func_name, work_dir, rp, path, rule) + exec_policy, ret, readonly_flag = sbox_execute_rule( + binary_name, func_name, rp, path, rule) end return rule, exec_policy, ret, readonly_flag end --- sbox_translate_path is the function called from libsb2.so --- preload library and the FUSE system for each path that needs --- translating. --- --- returns: --- 1. the rule used to perform the mapping --- 2. exec_policy --- 3. path (mapping result) --- 4. "readonly" flag -function sbox_translate_path(rule, binary_name, func_name, work_dir, path) - return map_using_rule(rule, binary_name, func_name, work_dir, path) -end - function find_chain(chains_table, binary_name) local n @@ -419,7 +415,7 @@ end -- determine where to start resolving symbolic links; shorter paths than -- "min_path_len" should not be given to sbox_translate_path() -- returns "rule", "rule_found", "min_path_len" -function sbox_get_mapping_requirements(binary_name, func_name, work_dir, full_path) +function sbox_get_mapping_requirements(binary_name, func_name, full_path) -- loop through the chains, first match is used local min_path_len = 0 local rule = nil |