diff options
author | Lauri Aarnio <Lauri.Aarnio@iki.fi> | 2009-01-15 22:00:09 +0200 |
---|---|---|
committer | Lauri Leukkunen <lle@rahina.org> | 2009-01-20 06:54:33 +0200 |
commit | 7db7147a29eb96bfb9dfee11bd0a5f80024079b3 (patch) | |
tree | 6243fc75fab2fdf93c4ce8714f2634409723ada0 /lua_scripts | |
parent | 5d5da9ed775681bc7c4e8e676f6d226cb5fac9d3 (diff) |
Automatically created mapping rules for toolchain components (used by "devel")
- Mapping rules can be automatically generated for all components of the
toolchain. for example, /usr/bin/gcc can be mapped to the real compiler.
- Currently "devel" mode is the only one which uses this.
- (previously, the toolchain components have been handled only by the exec
preprocessing code. Now normal filesystem accesses lead to the same files,
too)
Diffstat (limited to 'lua_scripts')
-rw-r--r-- | lua_scripts/create_argvmods_usr_bin_rules.lua | 58 | ||||
-rw-r--r-- | lua_scripts/mapping.lua | 5 | ||||
-rw-r--r-- | lua_scripts/pathmaps/devel/00_default.lua | 3 |
3 files changed, 66 insertions, 0 deletions
diff --git a/lua_scripts/create_argvmods_usr_bin_rules.lua b/lua_scripts/create_argvmods_usr_bin_rules.lua new file mode 100644 index 0000000..d617a5e --- /dev/null +++ b/lua_scripts/create_argvmods_usr_bin_rules.lua @@ -0,0 +1,58 @@ +-- Copyright (c) 2009 Nokia Corporation. +-- Author: Lauri T. Aarnio +-- +-- Licensed under MIT license + +-- This script is executed after a new SB2 session has been created, +-- to create mapping rules for toolchain components: +-- For example, /usr/bin/gcc will be mapped to the toolchain. These rules +-- are used for other filesystem operations than exec* +-- (for example, when the shell is looking for a program, it must be +-- possible to stat() the destination) +-- + +gcc_rule_file_path = session_dir .. "/gcc-conf.lua" + +default_rule = os.getenv("SBOX_ARGVMODS_USR_BIN_DEFAULT_RULE") + +function argvmods_to_mapping_rules() + local n + print("argvmods_rules_for_usr_bin = {") + print(" rules = {") + for n in pairs(argvmods) do + local rule = argvmods[n] + -- print("-- rule ", n, " new_filename=", rule.new_filename) + local k + for k=1,table.maxn(rule.path_prefixes) do + if rule.path_prefixes[k] == "/usr/bin/" and + rule.new_filename ~= nil then + -- this rule maps "n" from /usr/bin to + -- another file + if sb.path_exists(rule.new_filename) then + print(" {path=\"/usr/bin/"..n.."\",") + print(" replace_by=\"" .. + rule.new_filename.."\"},") + else + print(" -- WARNING: " .. + rule.new_filename .. + " does not exist") + end + end + end + end + if (default_rule ~= nil) then + print(" -- default:") + print(" {prefix=\"/usr/bin\",", default_rule, "}") + end + print(" }") + print("}") +end + +print("-- Argvmods-to-mapping-rules converter:") +print("-- Automatically generated mapping rules. Do not modify:") + +do_file(session_dir .. "/lua_scripts/argvenvp.lua") +argvmods_to_mapping_rules() + +print("-- End of rules created by argvmods-to-mapping-rules converter.") + diff --git a/lua_scripts/mapping.lua b/lua_scripts/mapping.lua index 22a48be..6af7121 100644 --- a/lua_scripts/mapping.lua +++ b/lua_scripts/mapping.lua @@ -87,6 +87,11 @@ function load_and_check_rules() export_chains = {} exec_policy_chains = {} + tools = tools_root + if (not tools) then + tools = "/" + end + -- Differences between version 17 and 18: -- - added sb2_procfs_mapper() -- Differences between version 16 and 17: diff --git a/lua_scripts/pathmaps/devel/00_default.lua b/lua_scripts/pathmaps/devel/00_default.lua index 35a27f3..8e4c0da 100644 --- a/lua_scripts/pathmaps/devel/00_default.lua +++ b/lua_scripts/pathmaps/devel/00_default.lua @@ -280,6 +280,9 @@ devel_mode_rules_usr = { {path = "/usr/bin/localedef", map_to = target_root, readonly = true}, + -- automatically generated rules for /usr/bin: + {dir = "/usr/bin", chain = argvmods_rules_for_usr_bin}, + -- ----------------------------------------------- -- 40. /usr/lib/* -- Most of /usr/lib should come from target_root, but |