diff options
-rw-r--r-- | include/sb2.h | 4 | ||||
-rw-r--r-- | lua_scripts/create_reverse_rules.lua | 4 | ||||
-rw-r--r-- | lua_scripts/main.lua | 2 | ||||
-rw-r--r-- | lua_scripts/mapping.lua | 10 | ||||
-rw-r--r-- | lua_scripts/pathmaps/devel/00_default.lua | 298 | ||||
-rw-r--r-- | lua_scripts/pathmaps/emulate/00_default.lua | 2 | ||||
-rw-r--r-- | lua_scripts/pathmaps/install/00_default.lua | 2 | ||||
-rw-r--r-- | lua_scripts/pathmaps/simple/00_default.lua | 2 | ||||
-rw-r--r-- | lua_scripts/pathmaps/tools/00_default.lua | 2 | ||||
-rw-r--r-- | luaif/luaif.c | 2 |
10 files changed, 206 insertions, 122 deletions
diff --git a/include/sb2.h b/include/sb2.h index f3274b1..32ad22f 100644 --- a/include/sb2.h +++ b/include/sb2.h @@ -37,10 +37,12 @@ struct lua_instance { * - sbox_translate_path(): as above * * Differences between "35,lta-2008-10-01" and "53,lta-2008-11-10" * - added new functions sb.get_forced_mapmode() and sb.get_session_perm() + * * Differences between "59,lta-2008-12-04" and "53,lta-2008-11-10" + * - part of rule selection logic is now implemented in C. * * NOTE: the corresponding identifier for Lua is in lua_scripts/main.lua */ -#define SB2_LUA_C_INTERFACE_VERSION "53,lta-2008-11-10" +#define SB2_LUA_C_INTERFACE_VERSION "59,lta-2008-12-04" struct lua_instance *get_lua(void); diff --git a/lua_scripts/create_reverse_rules.lua b/lua_scripts/create_reverse_rules.lua index d206a2f..fc712dc 100644 --- a/lua_scripts/create_reverse_rules.lua +++ b/lua_scripts/create_reverse_rules.lua @@ -58,6 +58,8 @@ function reverse_one_rule(output_rules, rule, n) forward_path = rule.prefix elseif (rule.path) then forward_path = rule.path + elseif (rule.dir) then + forward_path = rule.dir else forward_path = nil new_rule.error = string.format( @@ -141,6 +143,8 @@ function reverse_rules(input_rules) if rule.virtual_path then -- don't reverse virtual paths print("-- virtual_path set, not reversing", n) + elseif rule.chain then + reverse_rules(rule.chain.rules) else reverse_one_rule(output_rules, rule, n) end diff --git a/lua_scripts/main.lua b/lua_scripts/main.lua index fedc5fe..4915486 100644 --- a/lua_scripts/main.lua +++ b/lua_scripts/main.lua @@ -15,7 +15,7 @@ debug_messages_enabled = sb.debug_messages_enabled() -- -- NOTE: the corresponding identifier for C is in include/sb2.h, -- see that file for description about differences -sb2_lua_c_interface_version = "53,lta-2008-11-10" +sb2_lua_c_interface_version = "59,lta-2008-12-04" function do_file(filename) if (debug_messages_enabled) then diff --git a/lua_scripts/mapping.lua b/lua_scripts/mapping.lua index 244ab7c..6771339 100644 --- a/lua_scripts/mapping.lua +++ b/lua_scripts/mapping.lua @@ -71,6 +71,9 @@ function load_and_check_rules() export_chains = {} exec_policy_chains = {} + -- Differences between version 16 and 17: + -- - Added support for hierarcic rules (i.e. rule + -- trees. 16 supports only linear rule lists) -- Differences between version 15 and 16: -- - "match" rules are not supported anymore -- - interface to custom_map_func was modified: @@ -79,7 +82,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 = "16" + local current_rule_interface_version = "17" do_file(rule_file_path) @@ -328,6 +331,11 @@ function find_rule(chain, func, full_path) min_path_len = sb.test_path_match(full_path, rule.dir, rule.prefix, rule.path) if min_path_len >= 0 then + if (rule.chain) then + return find_rule(rule.chain, + func, full_path) + end + -- Path matches, test if other conditions are -- also OK: if ((not rule.func_name diff --git a/lua_scripts/pathmaps/devel/00_default.lua b/lua_scripts/pathmaps/devel/00_default.lua index 12062d3..938b708 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 = "16" +rule_file_interface_version = "17" ---------------------------------- tools = tools_root @@ -98,92 +98,10 @@ test_first_tools_default_is_target = { -- =========== Mapping rule chains =========== -simple_chain = { - next_chain = nil, - binary = nil, +-- Used when dir = "/usr/share/aclocal": +devel_mode_rules_usr_share_aclocal = { rules = { -- ----------------------------------------------- - -- 1. General SB2 environment: - - {prefix = "/usr/bin/sb2-", - use_orig_path = true, readonly = true}, - {prefix = "/usr/share/scratchbox2/host_usr", - replace_by = "/usr", readonly = true}, - {prefix = "/usr/share/scratchbox2", - use_orig_path = true, readonly = true}, - - -- ----------------------------------------------- - -- 2. Development environment special destinations: - - {prefix = "/sb2/wrappers", - replace_by = session_dir .. "/wrappers." .. active_mapmode, - readonly = true}, - - {prefix = "/sb2/scripts", - replace_by = sbox_dir.."/share/scratchbox2/scripts", - readonly = true}, - - -- tools_root should not be mapped twice. - {prefix = tools, use_orig_path = true, readonly = true}, - - -- ----------------------------------------------- - -- 5. Maemo SDK+ - - {prefix = "/opt/maemo", - use_orig_path = true, readonly = true}, - - -- ----------------------------------------------- - -- 10. Home directories - - {prefix = sbox_user_home_dir, use_orig_path = true}, - - -- "user" is a special username at least on the Maemo platform: - -- (but note that if the real user name is "user", - -- our previous rule handled that and this rule won't be used) - {prefix = "/home/user", map_to = target_root}, - - -- Home directories = not mapped, R/W access - {prefix = "/home", use_orig_path = true}, - - -- ----------------------------------------------- - -- 20. /bin/* and /usr/bin/*: - -- tools that need special processing: - - {path = "/bin/sh", - replace_by = tools .. "/bin/bash", readonly = true}, - {prefix = "/usr/bin/host-", - use_orig_path = true, readonly = true}, - - -- "localedef" *must* be used from the target, the version - -- which exists in tools_root appers to work but doesn't.. - {path = "/usr/bin/localedef", map_to = target_root, - readonly = true}, - - -- ----------------------------------------------- - -- 30. /lib/* - - {prefix = "/lib", map_to = target_root, readonly = true}, - - -- ----------------------------------------------- - -- 40. /usr/lib/* - -- Most of /usr/lib should come from target_root, but - -- there are exceptions: Some tools have private subdirectories - -- there. - - {prefix = "/usr/lib/gcc", map_to = tools, readonly = true}, - {prefix = "/usr/lib/perl", map_to = tools, readonly = true}, - {prefix = "/usr/lib/dpkg", map_to = tools, readonly = true}, - {prefix = "/usr/lib/apt", map_to = tools, readonly = true}, - {prefix = "/usr/lib/cdbs", map_to = tools, readonly = true}, - {prefix = "/usr/lib/libfakeroot", map_to = tools, readonly = true}, - {prefix = "/usr/lib/man-db", map_to = tools, readonly = true}, - - -- /usr/lib/python* from tools_root - {prefix = "/usr/lib/python", map_to = tools, readonly = true}, - - {prefix = "/usr/lib", map_to = target_root, readonly = true}, - - -- ----------------------------------------------- -- 45. /usr/share/aclocal* -- This is more than a bit complex, we must mix files from -- both places: @@ -222,6 +140,22 @@ simple_chain = { -- exists, but default is target_root {prefix = "/usr/share/aclocal", actions = test_first_tools_default_is_target}, + } +} + +-- Used when dir = "/usr/share": +devel_mode_rules_usr_share = { + rules = { + {dir = "/usr/share/aclocal", + chain = devel_mode_rules_usr_share_aclocal}, + + -- ----------------------------------------------- + -- 1. General SB2 environment: + + {prefix = "/usr/share/scratchbox2/host_usr", + replace_by = "/usr", readonly = true}, + {prefix = "/usr/share/scratchbox2", + use_orig_path = true, readonly = true}, -- ----------------------------------------------- -- 46. /usr/share/* (other than /usr/share/aclocal*) @@ -279,9 +213,53 @@ simple_chain = { {prefix = "/usr/share/modest", map_to = target_root, readonly = true}, - -- default rules: - {path = "/usr/share", map_to = tools, readonly = true}, - {prefix = "/usr/share/", map_to = tools, readonly = true}, + -- ----------------------------------------------- + -- 100. DEFAULT RULES: + {dir = "/usr/share", map_to = tools, readonly = true}, + } +} + +-- Used when dir = "/usr": +devel_mode_rules_usr = { + rules = { + {dir = "/usr/share", chain = devel_mode_rules_usr_share}, + + -- ----------------------------------------------- + -- 1. General SB2 environment: + + {prefix = "/usr/bin/sb2-", + use_orig_path = true, readonly = true}, + + -- ----------------------------------------------- + -- 20. /bin/* and /usr/bin/*: + -- tools that need special processing: + + {prefix = "/usr/bin/host-", + use_orig_path = true, readonly = true}, + + -- "localedef" *must* be used from the target, the version + -- which exists in tools_root appers to work but doesn't.. + {path = "/usr/bin/localedef", map_to = target_root, + readonly = true}, + + -- ----------------------------------------------- + -- 40. /usr/lib/* + -- Most of /usr/lib should come from target_root, but + -- there are exceptions: Some tools have private subdirectories + -- there. + + {prefix = "/usr/lib/gcc", map_to = tools, readonly = true}, + {prefix = "/usr/lib/perl", map_to = tools, readonly = true}, + {prefix = "/usr/lib/dpkg", map_to = tools, readonly = true}, + {prefix = "/usr/lib/apt", map_to = tools, readonly = true}, + {prefix = "/usr/lib/cdbs", map_to = tools, readonly = true}, + {prefix = "/usr/lib/libfakeroot", map_to = tools, readonly = true}, + {prefix = "/usr/lib/man-db", map_to = tools, readonly = true}, + + -- /usr/lib/python* from tools_root + {prefix = "/usr/lib/python", map_to = tools, readonly = true}, + + {prefix = "/usr/lib", map_to = target_root, readonly = true}, -- ----------------------------------------------- -- 50. /usr/src/* @@ -303,6 +281,20 @@ simple_chain = { readonly = true}, -- ----------------------------------------------- + -- 100. DEFAULT RULES: + -- the root directory must not be mapped: + + -- "standard" directories are mapped to tools_root, + -- but everything else defaults to the host system + -- (so that things like /mnt, /media and /opt are + -- used from the host) + {prefix = "/usr", map_to = tools, readonly = true}, + } +} + +devel_mode_rules_etc = { + rules = { + -- ----------------------------------------------- -- 70. /etc/* -- {prefix = "/etc/gconf/2", map_to = target_root, @@ -325,9 +317,12 @@ simple_chain = { use_orig_path = true, readonly = true}, -- default rules: - {path = "/etc", map_to = tools, readonly = true}, - {prefix = "/etc/", map_to = tools, readonly = true}, + {dir = "/etc", map_to = tools, readonly = true}, + } +} +devel_mode_rules_var = { + rules = { -- ----------------------------------------------- -- 80. /var/* @@ -355,33 +350,18 @@ simple_chain = { {prefix = "/var/log", map_to = target_root, readonly = true}, - -- ----------------------------------------------- - -- 85. /tmp - {prefix = session_dir, use_orig_path = true}, - {prefix = "/tmp", map_to = session_dir}, - - -- ----------------------------------------------- - -- 90. Top-level directories that must not be mapped: - {prefix = "/dev", use_orig_path = true}, - {prefix = "/proc", use_orig_path = true}, - {prefix = "/sys", - use_orig_path = true, readonly = true}, - - -- ----------------------------------------------- - -- 95. Some virtual paths: - {prefix = "/host_usr", map_to = target_root, readonly = true}, - - -- unmodified view of the rootstrap, can be used as destination - -- directory when installing stuff to the rootstrap - -- This provides is R/W access to the target_root! - {prefix = "/target_root", replace_by = target_root}, + -- default rules: + {dir = "/var", map_to = tools, readonly = true}, + } +} +devel_mode_rules_scratchbox1 = { + rules = { -- ----------------------------------------------- -- 98. Scratchbox 1 emulation rules -- (some packages have hard-coded paths to the SB1 enviroment; -- replace those by the correct locations in our environment) -- (these are marked "virtual"; these won't be reversed) - -- "libtool" for arm {prefix = "/scratchbox/compilers/cs2005q3.2-glibc2.5-arm/arch_tools/share/libtool", replace_by = sb2_share_dir .. "/libtool", @@ -407,6 +387,99 @@ simple_chain = { -- otherwise, don't map /scratchbox, some people still -- keep their projects there. {prefix = "/scratchbox", use_orig_path = true}, + } +} + +simple_chain = { + next_chain = nil, + binary = nil, + rules = { + + -- ----------------------------------------------- + -- 2. Development environment special destinations: + + {prefix = "/sb2/wrappers", + replace_by = session_dir .. "/wrappers." .. active_mapmode, + readonly = true}, + + {prefix = "/sb2/scripts", + replace_by = sbox_dir.."/share/scratchbox2/scripts", + readonly = true}, + + -- tools_root should not be mapped twice. + {prefix = tools, use_orig_path = true, readonly = true}, + + -- ----------------------------------------------- + -- 5. Maemo SDK+ + + {prefix = "/opt/maemo", + use_orig_path = true, readonly = true}, + + -- ----------------------------------------------- + -- 10. Home directories + + {prefix = sbox_user_home_dir, use_orig_path = true}, + + -- "user" is a special username at least on the Maemo platform: + -- (but note that if the real user name is "user", + -- our previous rule handled that and this rule won't be used) + {prefix = "/home/user", map_to = target_root}, + + -- Home directories = not mapped, R/W access + {prefix = "/home", use_orig_path = true}, + + -- ----------------------------------------------- + -- 20. /bin/*: + -- tools that need special processing: + + {path = "/bin/sh", + replace_by = tools .. "/bin/bash", readonly = true}, + + -- ----------------------------------------------- + -- 30. /lib/* + + {prefix = "/lib", map_to = target_root, readonly = true}, + + -- ----------------------------------------------- + -- 40. /usr + {dir = "/usr", chain = devel_mode_rules_usr}, + + -- ----------------------------------------------- + -- 70. /etc/* + -- + {dir = "/etc", chain = devel_mode_rules_etc}, + + -- ----------------------------------------------- + -- 80. /var/* + {dir = "/var", chain = devel_mode_rules_var}, + + -- ----------------------------------------------- + -- 85. /tmp + {prefix = session_dir, use_orig_path = true}, + {prefix = "/tmp", map_to = session_dir}, + + -- ----------------------------------------------- + -- 90. Top-level directories that must not be mapped: + {prefix = "/dev", use_orig_path = true}, + {prefix = "/proc", use_orig_path = true}, + {prefix = "/sys", + use_orig_path = true, readonly = true}, + + -- ----------------------------------------------- + -- 95. Some virtual paths: + {prefix = "/host_usr", map_to = target_root, readonly = true}, + + -- unmodified view of the rootstrap, can be used as destination + -- directory when installing stuff to the rootstrap + -- This provides is R/W access to the target_root! + {prefix = "/target_root", replace_by = target_root}, + + -- ----------------------------------------------- + -- 98. Scratchbox 1 emulation rules + -- (some packages have hard-coded paths to the SB1 enviroment; + -- replace those by the correct locations in our environment) + -- (these are marked "virtual"; these won't be reversed) + {dir = "/scratchbox", chain = devel_mode_rules_scratchbox1}, -- ----------------------------------------------- -- 100. DEFAULT RULES: @@ -418,10 +491,7 @@ simple_chain = { -- (so that things like /mnt, /media and /opt are -- used from the host) {prefix = "/bin", map_to = tools, readonly = true}, - {prefix = "/etc", map_to = tools, readonly = true}, {prefix = "/sbin", map_to = tools, readonly = true}, - {prefix = "/usr", map_to = tools, readonly = true}, - {prefix = "/var", map_to = tools, readonly = true}, -- Default = Host, R/W access {prefix = "/", use_orig_path = true} diff --git a/lua_scripts/pathmaps/emulate/00_default.lua b/lua_scripts/pathmaps/emulate/00_default.lua index 530db6f..052222e 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 = "16" +rule_file_interface_version = "17" ---------------------------------- 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 199bf13..9721d5b 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 = "16" +rule_file_interface_version = "17" ---------------------------------- 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 b66f02c..617cf27 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 = "16" +rule_file_interface_version = "17" ---------------------------------- tools = tools_root diff --git a/lua_scripts/pathmaps/tools/00_default.lua b/lua_scripts/pathmaps/tools/00_default.lua index 29b3b23..9320d58 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 = "16" +rule_file_interface_version = "17" ---------------------------------- -- If the permission token exists and contains "root", tools_root directories diff --git a/luaif/luaif.c b/luaif/luaif.c index db73ae6..1f7ab38 100644 --- a/luaif/luaif.c +++ b/luaif/luaif.c @@ -657,7 +657,7 @@ static int lua_sb_test_path_match(lua_State *l) /* test a directory prefix: the next char after the * prefix must be '\0' or '/', unless we are accessing * the root directory */ - if (!strncmp(str_path, str_rule_prefix, prefixlen)) { + if (!strncmp(str_path, str_rule_dir, prefixlen)) { if ( ((prefixlen == 1) && (*str_path=='/')) || (str_path[prefixlen] == '/') || (str_path[prefixlen] == '\0') ) { |