diff options
author | Lauri Aarnio <Lauri.Aarnio@iki.fi> | 2008-06-08 06:53:01 +0300 |
---|---|---|
committer | Lauri Leukkunen <lle@rahina.org> | 2008-06-17 10:08:27 +0300 |
commit | aa757a67a1f376716f9228c3f3bf6c319527b516 (patch) | |
tree | d6ce4b6516610401197d5ecfba5f0918baa7e513 /preload | |
parent | ab0a08d18700182ee37c0fd3628c3cb5cdea2147 (diff) |
Bugfix: Fixed execution of host-* tools
- Execution of host-gcc and other host-* tools failed when SBOX_TOOLS_ROOT
was set, because do_exec() did not check if the exec mangling code
disabled all mapping; it tried to start gcc from SBOX_TOOLS_ROOT and not
from the host (which of course failed, because rest of the universe didn't
come from SBOX_TOOLS_ROOT)
Diffstat (limited to 'preload')
-rw-r--r-- | preload/sb_exec.c | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/preload/sb_exec.c b/preload/sb_exec.c index d038106..785f202 100644 --- a/preload/sb_exec.c +++ b/preload/sb_exec.c @@ -823,6 +823,19 @@ static void compare_and_log_strvec_changes(const char *vecname, } } +static int strvec_contains(char *const *strvec, const char *id) +{ + char *const *ptr2vec = strvec; + + while (*ptr2vec) { + if (!strcmp(*ptr2vec, id)) { + return(1); + } + ptr2vec++; + } + return(0); +} + int do_exec(const char *exec_fn_name, const char *file, char *const *argv, char *const *envp) { @@ -865,18 +878,28 @@ int do_exec(const char *exec_fn_name, const char *file, compare_and_log_strvec_changes("envp", *my_envp_copy, *my_envp); } - /* now we have to do path mapping for *my_file to find exactly - * what is the path we're supposed to deal with - */ + /* test if mapping is enabled during the exec().. + * (host-* tools disable it) + */ + if (strvec_contains(*my_envp, "SBOX_DISABLE_MAPPING=1")) { + SB_LOG(SB_LOGLEVEL_DEBUG, + "do_exec(): mapping disabled, *my_file = %s", + *my_file); + mapped_file = strdup(*my_file); + } else { + /* now we have to do path mapping for *my_file to find exactly + * what is the path we're supposed to deal with + */ - mapped_file = scratchbox_path("do_exec", *my_file, - NULL/*RO-flag addr.*/, 0/*dont_resolve_final_symlink*/); - SB_LOG(SB_LOGLEVEL_DEBUG, - "do_exec(): *my_file = %s, mapped_file = %s", - *my_file, mapped_file); + mapped_file = scratchbox_path("do_exec", *my_file, + NULL/*RO-flag addr.*/, 0/*dont_resolve_final_symlink*/); + SB_LOG(SB_LOGLEVEL_DEBUG, + "do_exec(): *my_file = %s, mapped_file = %s", + *my_file, mapped_file); + } - type = inspect_binary(mapped_file); /* inspect the completely mangled - * filename */ + /* inspect the completely mangled filename */ + type = inspect_binary(mapped_file); switch (type) { case BIN_HASHBANG: |