summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua_scripts/argvenvp.lua34
-rw-r--r--lua_scripts/mapping.lua8
-rw-r--r--lua_scripts/pathmaps/devel/00_default.lua29
-rw-r--r--lua_scripts/pathmaps/emulate/00_default.lua2
-rw-r--r--lua_scripts/pathmaps/install/00_default.lua2
-rw-r--r--lua_scripts/pathmaps/simple/00_default.lua2
-rw-r--r--lua_scripts/pathmaps/tools/00_default.lua2
7 files changed, 48 insertions, 31 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
diff --git a/lua_scripts/mapping.lua b/lua_scripts/mapping.lua
index e4240ea..8052030 100644
--- a/lua_scripts/mapping.lua
+++ b/lua_scripts/mapping.lua
@@ -135,8 +135,10 @@ function load_and_check_rules()
-- exec mapping code (argvenp.lua) and the
-- rule files:
--
- -- (version 19 is in intermediate version;
- -- several interface changes will follow)
+ -- Version 20 changed "script_interpreter_rule" field in
+ -- exec policies to "script_interpreter_rules"; find_rule()
+ -- is now used to select the rule (there may be more than one!)
+ -- (version 19 was an intermediate version)
-- - added "all_exec_policies" list to all
-- mapping modes
-- Differences between version 17 and 18:
@@ -152,7 +154,7 @@ function load_and_check_rules()
-- (previously only one was expected)
-- - variables "esc_tools_root" and "esc_target_root"
-- were removed
- local current_rule_interface_version = "19"
+ local current_rule_interface_version = "20"
do_file(rule_file_path)
diff --git a/lua_scripts/pathmaps/devel/00_default.lua b/lua_scripts/pathmaps/devel/00_default.lua
index 19c5705..1de0619 100644
--- a/lua_scripts/pathmaps/devel/00_default.lua
+++ b/lua_scripts/pathmaps/devel/00_default.lua
@@ -8,7 +8,7 @@
-- Rule file interface version, mandatory.
--
-rule_file_interface_version = "19"
+rule_file_interface_version = "20"
----------------------------------
tools = tools_root
@@ -44,6 +44,15 @@ if ((tools_root ~= nil) and conf_tools_sb2_installed) then
end
end
+tools_script_interp_rules = {
+ rules = {
+ {dir = "/scratchbox/tools/bin",
+ replace_by = tools .. "/usr/bin", log_level = "warning"},
+
+ {prefix = "/", map_to = tools}
+ }
+}
+
exec_policy_tools = {
name = "Tools",
native_app_ld_so = devel_mode_tools_ld_so,
@@ -54,9 +63,7 @@ exec_policy_tools = {
script_log_level = "debug",
script_log_message = "SCRIPT from tools",
- script_interpreter_rule = {
- map_to = tools
- },
+ script_interpreter_rules = tools_script_interp_rules,
script_set_argv0_to_mapped_interpreter = true,
}
@@ -70,9 +77,7 @@ exec_policy_tools_perl = {
script_log_level = "debug",
script_log_message = "SCRIPT from tools (t.p)",
- script_interpreter_rule = {
- map_to = tools
- },
+ script_interpreter_rules = tools_script_interp_rules,
script_set_argv0_to_mapped_interpreter = true,
}
@@ -86,9 +91,7 @@ exec_policy_tools_python = {
script_log_level = "debug",
script_log_message = "SCRIPT from tools (t.p)",
- script_interpreter_rule = {
- map_to = tools
- },
+ script_interpreter_rules = tools_script_interp_rules,
script_set_argv0_to_mapped_interpreter = true,
}
@@ -132,8 +135,10 @@ exec_policy_host_os = {
log_level = "debug",
log_message = "executing in host OS mode",
- script_interpreter_rule = {
- use_orig_path = true
+ script_interpreter_rules = {
+ rules = {
+ {prefix = "/", use_orig_path = true}
+ }
},
}
diff --git a/lua_scripts/pathmaps/emulate/00_default.lua b/lua_scripts/pathmaps/emulate/00_default.lua
index 17c50d8..692cca9 100644
--- a/lua_scripts/pathmaps/emulate/00_default.lua
+++ b/lua_scripts/pathmaps/emulate/00_default.lua
@@ -3,7 +3,7 @@
-- Rule file interface version, mandatory.
--
-rule_file_interface_version = "19"
+rule_file_interface_version = "20"
----------------------------------
sb1_compat_dir = sbox_target_root .. "/scratchbox1-compat"
diff --git a/lua_scripts/pathmaps/install/00_default.lua b/lua_scripts/pathmaps/install/00_default.lua
index 7ca7161..1328f4d 100644
--- a/lua_scripts/pathmaps/install/00_default.lua
+++ b/lua_scripts/pathmaps/install/00_default.lua
@@ -4,7 +4,7 @@
-- Rule file interface version, mandatory.
--
-rule_file_interface_version = "19"
+rule_file_interface_version = "20"
----------------------------------
if (tools_root and tools_root ~= "/") then
diff --git a/lua_scripts/pathmaps/simple/00_default.lua b/lua_scripts/pathmaps/simple/00_default.lua
index 34ab4ca..24d9449 100644
--- a/lua_scripts/pathmaps/simple/00_default.lua
+++ b/lua_scripts/pathmaps/simple/00_default.lua
@@ -7,7 +7,7 @@
-- Rule file interface version, mandatory.
--
-rule_file_interface_version = "19"
+rule_file_interface_version = "20"
----------------------------------
tools = tools_root
diff --git a/lua_scripts/pathmaps/tools/00_default.lua b/lua_scripts/pathmaps/tools/00_default.lua
index dc6bfc7..7c9b1a5 100644
--- a/lua_scripts/pathmaps/tools/00_default.lua
+++ b/lua_scripts/pathmaps/tools/00_default.lua
@@ -6,7 +6,7 @@
-- Rule file interface version, mandatory.
--
-rule_file_interface_version = "19"
+rule_file_interface_version = "20"
----------------------------------
tools = tools_root