diff options
author | Lauri Aarnio <Lauri.Aarnio@iki.fi> | 2009-02-14 20:10:49 +0200 |
---|---|---|
committer | Lauri Leukkunen <lle@rahina.org> | 2009-02-16 11:50:39 +0200 |
commit | 6fcca3809509eb9d0f067e66383ea7985041b974 (patch) | |
tree | 834218c26471358d5fadbc5527c73872eb240600 /lua_scripts/argvenvp.lua | |
parent | cc817ba72a05d3593219e052805908f4686a3431 (diff) |
Script interpreter mapping: Added support for multiple mapping rules
- an exec policy can now define more than one rule to map the script
interpreter (previously only one rule was allowed)
- "devel" mode: Added yet another SB1 compatibility feature: Support
for mapping interpreters from /scratchbox/tools/bin to <tools_root>/usr/bin
- Interface version of the mapping engine <-> mapping rules interface
was incremented (this is the lua<->lua interface version, C<->lua interface
was not modified)
Diffstat (limited to 'lua_scripts/argvenvp.lua')
-rw-r--r-- | lua_scripts/argvenvp.lua | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/lua_scripts/argvenvp.lua b/lua_scripts/argvenvp.lua index 5bb5c80..0c273a3 100644 --- a/lua_scripts/argvenvp.lua +++ b/lua_scripts/argvenvp.lua @@ -310,21 +310,31 @@ function sb_execve_map_script_interpreter(rule, exec_policy, interpreter, exec_policy.name)) end - if (exec_policy.script_interpreter_rule ~= nil) then + if (exec_policy.script_interpreter_rules ~= nil) then + local min_path_len = 0 + local rule = nil local exec_pol_2, mapped_interpreter, ro_flag - exec_pol_2, mapped_interpreter, ro_flag = sbox_execute_rule( - interpreter, "map_script_interpreter", - interpreter, interpreter, - exec_policy.script_interpreter_rule) - - if exec_policy.script_set_argv0_to_mapped_interpreter then - argv[1] = mapped_interpreter - return rule, exec_pol_2, 0, - mapped_interpreter, #argv, argv, #envp, envp + rule, min_path_len = find_rule(exec_policy.script_interpreter_rules, + "map_script_interpreter", interpreter) + + if (rule) then + exec_pol_2, mapped_interpreter, ro_flag = sbox_execute_rule( + interpreter, "map_script_interpreter", + interpreter, interpreter, rule) + + if exec_policy.script_set_argv0_to_mapped_interpreter then + argv[1] = mapped_interpreter + return rule, exec_pol_2, 0, + mapped_interpreter, #argv, argv, #envp, envp + else + return rule, exec_pol_2, 1, + mapped_interpreter, #argv, argv, #envp, envp + end else - return rule, exec_pol_2, 1, - mapped_interpreter, #argv, argv, #envp, envp + sb.log("warning", string.format( + "Failed to find script interpreter mapping rule for %s", + interpreter)) end end |