summaryrefslogtreecommitdiff
path: root/redir_scripts
diff options
context:
space:
mode:
authorLauri Leukkunen <lle@rahina.org>2006-12-22 03:29:16 +0200
committerLauri Leukkunen <lleukkun@leka.rahina.org>2006-12-22 03:29:16 +0200
commit7b4a706e21f953e26cdc6ed10c862a4f3e8b4f79 (patch)
tree86490a03c3d707fba0ba3d9b24176e8c914bcae0 /redir_scripts
parent67c02b7662589ce6ba67312fc676a08c9a8a8ec1 (diff)
* rework everything to get rid of chroot requirement
Diffstat (limited to 'redir_scripts')
-rw-r--r--redir_scripts/main.lua25
-rw-r--r--redir_scripts/parts/default.lua85
2 files changed, 85 insertions, 25 deletions
diff --git a/redir_scripts/main.lua b/redir_scripts/main.lua
index 86979bf..596cad3 100644
--- a/redir_scripts/main.lua
+++ b/redir_scripts/main.lua
@@ -5,10 +5,15 @@
tools_root = os.getenv("SBOX_TOOLS_ROOT")
if (tools_root == nil) then
- print("SBOX_TOOLS_ROOT not set")
tools_root = "/scratchbox/sarge"
end
+target_root = os.getenv("SBOX_TARGET_ROOT")
+if (target_root == nil) then
+ target_root = "/"
+end
+
+
-- SBOX_REDIR_SCRIPTS environment variable controls where
-- we look for the scriptlets defining the path mappings
@@ -77,15 +82,15 @@ end
function sbox_map_to(binary_name, func_name, work_dir, rp, path, rule)
ret = ""
- if (rule.map_to ~= nil) then
+ if (rule.map_to) then
if (string.sub(rule.map_to, 1, 1) == "=") then
- ret = tools_root .. string.sub(rule.map_to, 2)
+ ret = target_root .. string.sub(rule.map_to, 2)
else
- ret = tools_root .. rule.map_to
+ ret = target_root .. rule.map_to
end
end
- -- print("mapping to: " .. ret .. path)
+ --print("mapping to: " .. ret .. path)
return ret .. path
end
@@ -95,8 +100,8 @@ end
-- translating
function sbox_translate_path(binary_name, func_name, work_dir, path)
-
- -- print(string.format("debug: [%s][%s][%s][%s]", binary_name, func_name, work_dir, path))
+ --print(string.format("[%s]:", binary_name))
+ --print(string.format("debug: [%s][%s][%s][%s]", binary_name, func_name, work_dir, path))
ret = path
rp = sb.sb_realpath(path)
@@ -114,12 +119,14 @@ function sbox_translate_path(binary_name, func_name, work_dir, path)
if (rules[n].custom_map_func ~= nil) then
return rules[n].custom_map_func(binary_name, func_name, work_dir, rp, path, rules[n])
else
- return sbox_map_to(binary_name, func_name, work_dir, rp, path, rules[n])
+ ret = sbox_map_to(binary_name, func_name, work_dir, rp, path, rules[n])
+ --print(string.format("%s(%s) -> [%s]", func_name, path, ret))
+ return ret
end
end
end
-- fail safe, if none matched, map
- return tools_root .. rp
+ return target_root .. rp
end
diff --git a/redir_scripts/parts/default.lua b/redir_scripts/parts/default.lua
index 839e3ba..f379b68 100644
--- a/redir_scripts/parts/default.lua
+++ b/redir_scripts/parts/default.lua
@@ -7,8 +7,8 @@
-- except the map_to and custom_map_func fields.
-- In map_to these have special meaning:
--
--- "=" map to tools_root .. "/" .. path
--- "=/some/path" map to tools_root .. "/some/path" .. "/" .. path
+-- "=" map to TARGETDIR .. "/" .. path
+-- "=/some/path" map to TARGETDIR .. "/some/path" .. "/" .. path
-- nil no mapping, use straight
--
-- Any other value is prepended to path (map_to .. "/" .. path).
@@ -25,29 +25,31 @@
-- and is expected to return the mapped path. rule argument contains
-- the rule which triggered the function invocation.
-default_rule1 = {
+
+-- three exec rules for running binaries
+default_bin = {
binary = ".*",
func_name = ".*",
func_param = nil,
path = "^/bin",
- map_to = "=",
+ map_to = nil,
custom_map_func = nil
}
-default_rule2 = {
+default_usrbin = {
binary = ".*",
- func_name = "^exec",
+ func_name = ".*",
func_param = nil,
path = "^/usr/bin",
- map_to = "=",
+ map_to = nil,
custom_map_func = nil
}
-default_rule3 = {
+default_usrlocalbin = {
binary = ".*",
func_name = ".*",
func_param = nil,
- path = "^/scratchbox",
+ path = "^/usr/local/bin",
map_to = nil,
custom_map_func = nil
}
@@ -61,20 +63,71 @@ default_home = {
custom_map_func = nil
}
-default_rootdir = {
+default_proc = {
binary = ".*",
func_name = ".*",
func_param = nil,
- path = "^/[^/]*$",
+ path = "^/proc",
map_to = nil,
custom_map_func = nil
}
+default_tmp = {
+ binary = ".*",
+ func_name = ".*",
+ func_param = nil,
+ path = "^/tmp",
+ map_to = nil,
+ custom_map_func = nil
+}
+
+default_etc = {
+ binary = ".*",
+ func_name = ".*",
+ func_param = nil,
+ path = "^/etc",
+ map_to = nil,
+ custom_map_func = nil
+}
+
+default_scratchbox = {
+ binary = ".*",
+ func_name = ".*",
+ func_param = nil,
+ path = "^/scratchbox",
+ map_to = nil,
+ custom_map_func = nil
+}
+
+default_root = {
+ binary = ".*",
+ func_name = ".*",
+ func_param = nil,
+ path = "/",
+ map_to = nil,
+ custom_map_func = nil
+}
+
+-- catch all rule to map everything else to TARGETDIR/
+default_rootdir = {
+ binary = ".*",
+ func_name = ".*",
+ func_param = nil,
+ path = "^/",
+ map_to = "=",
+ custom_map_func = nil
+}
+
export_rules = {
- default_rule1,
- default_rule2,
- default_rule3,
- default_rootdir,
- default_home
+ default_bin,
+ default_usrbin,
+ default_usrlocalbin,
+ default_scratchbox,
+ default_home,
+ default_proc,
+ default_tmp,
+ default_etc,
+ default_root,
+ default_rootdir
}