diff options
author | Lauri Leukkunen <lle@rahina.org> | 2006-12-29 16:13:12 +0200 |
---|---|---|
committer | Lauri Leukkunen <lleukkun@leka.rahina.org> | 2006-12-29 16:13:12 +0200 |
commit | 13859ab9690119a35fbb3a4b8befb4beb9a08226 (patch) | |
tree | 303cfb3bd36fab65a6899895bc82a8b8da938866 | |
parent | 541bc5fe6dd9b826444a904333b98c7a9391d3a0 (diff) |
* add argv[] mapping for ln and rm1.99.0.1
-rw-r--r-- | include/lua_bindings.h | 2 | ||||
-rw-r--r-- | lua/lua_bindings.c | 33 | ||||
-rw-r--r-- | preload/libsb2.c | 37 | ||||
-rw-r--r-- | redir_scripts/parts/default.lua | 8 |
4 files changed, 60 insertions, 20 deletions
diff --git a/include/lua_bindings.h b/include/lua_bindings.h index 8c130d0..851ee3d 100644 --- a/include/lua_bindings.h +++ b/include/lua_bindings.h @@ -8,6 +8,8 @@ #define LUA_BINDINGS_H char *scratchbox_path(const char *func_name, const char *path); +char *scratchbox_path2(const char *binary_name, const char *func_name, const char *path); + #include <sys/types.h> typedef pid_t pidfunction(void); diff --git a/lua/lua_bindings.c b/lua/lua_bindings.c index d5ceee3..4accec4 100644 --- a/lua/lua_bindings.c +++ b/lua/lua_bindings.c @@ -120,6 +120,10 @@ static char *decolonize_path(const char *path) break; } *index = '\0'; + if (index == (start)) { + goto proceed; /* skip over empty strings resulting from // */ + } + if (strcmp(start, "..") == 0) { /* travel up one */ if (!work->prev) goto proceed; @@ -438,12 +442,25 @@ static int sb_getdirlisting(lua_State *l) return 1; } - char *scratchbox_path(const char *func_name, const char *path) -{ +{ char binary_name[PATH_MAX+1]; + char *tmp; + + memset(binary_name, '\0', PATH_MAX+1); + tmp = getenv("__SB2_BINARYNAME"); + if (tmp) { + strcpy(binary_name, tmp); + } else { + strcpy(binary_name, "DUMMY"); + } + return scratchbox_path2(binary_name, func_name, path); +} + +char *scratchbox_path2(const char *binary_name, const char *func_name, const char *path) +{ char work_dir[PATH_MAX+1]; - char *tmp, *decolon_path; + char *tmp = NULL, *decolon_path = NULL; char pidlink[17]; /* /proc/2^8/exe */ if (!path) return NULL; @@ -461,18 +478,12 @@ char *scratchbox_path(const char *func_name, const char *path) return strdup(path); } - memset(binary_name, '\0', PATH_MAX+1); - tmp = getenv("__SB2_BINARYNAME"); - if (tmp) { - strcpy(binary_name, tmp); - } else { - strcpy(binary_name, "DUMMY"); - } /* first try from the cache */ #ifndef DISABLE_CACHE - tmp = read_sb2cache(binary_name, func_name, decolon_path); + tmp = NULL; + if (rsdir && main_lua) tmp = read_sb2cache(binary_name, func_name, decolon_path); if (tmp) { if (strcmp(tmp, decolon_path) == 0) { diff --git a/preload/libsb2.c b/preload/libsb2.c index 62176e5..3e624cf 100644 --- a/preload/libsb2.c +++ b/preload/libsb2.c @@ -943,6 +943,7 @@ static int do_exec(const char *file, char *const *argv, char *const *envp) my_envp[i++] = strdup(tmp); free(tmp); + my_envp[i] = NULL; char const* const* new_env=(char const* const*)my_envp; @@ -961,9 +962,21 @@ static int do_exec(const char *file, char *const *argv, char *const *envp) my_file = strdup(sb_gcc_wrapper); } /*DBGOUT("we've a gcc tool!\n");*/ - my_argv[i++] = strdup(binaryname); + //my_argv[i++] = strdup(binaryname); } + for (p = (char **)argv; *p; p++) { + if (*p[0] == '/' && ( + strcmp(binaryname, "rm") == 0 + || strcmp(binaryname, "ln") == 0)) { + my_argv[i++] = scratchbox_path2(binaryname, "execve", *p); + //my_argv[i++] = *p; + } else { + my_argv[i++] = *p; + } + } + my_argv[i] = NULL; + /* printf("type: %i\n", type);*/ switch (type) { case BIN_FOREIGN: @@ -977,14 +990,14 @@ static int do_exec(const char *file, char *const *argv, char *const *envp) case BIN_DYNAMIC: { if (getenv("SBOX_TOOLS_ROOT")) { - return ld_so_run_app((char *)my_file, (char **)argv, my_envp); + return ld_so_run_app((char *)my_file, (char **)my_argv, my_envp); } else { - return run_app((char *)my_file, (char **)argv, my_envp); + return run_app((char *)my_file, (char **)my_argv, my_envp); } } case BIN_TARGET: /* DBGOUT("cpu transparency needed\n"); */ - return run_cputransparency(my_file, (char **)argv, my_envp); + return run_cputransparency(my_file, (char **)my_argv, my_envp); case BIN_NONE: case BIN_UNKNOWN: @@ -993,7 +1006,7 @@ static int do_exec(const char *file, char *const *argv, char *const *envp) break; } - return next_execve(my_file, argv, (char *const*)new_env); + return next_execve(my_file, my_argv, (char *const*)new_env); } @@ -1338,10 +1351,16 @@ void *dlopen (const char *filename, int flag) /* #include <unistd.h> */ int euidaccess (const char *pathname, int mode) { - char *fakechroot_path; - expand_chroot_path(pathname, fakechroot_path); - if (next_euidaccess == NULL) fakechroot_init(); - return next_euidaccess(pathname, mode); + char *fakechroot_path; + int ret; + expand_chroot_path(pathname, fakechroot_path); + if (next_euidaccess == NULL) fakechroot_init(); + ret = next_euidaccess(pathname, mode); + if (ret < 0) { + DBGOUT("ret: %i\n", ret); + perror("joo"); + } + return ret; } #endif diff --git a/redir_scripts/parts/default.lua b/redir_scripts/parts/default.lua index 0ac13f8..97d1fcd 100644 --- a/redir_scripts/parts/default.lua +++ b/redir_scripts/parts/default.lua @@ -74,6 +74,12 @@ install = { map_to = "=" } +ln = { + binary = "^ln$", + path = ".*", + map_to = "=" +} + cp = { binary = "^cp$", path = ".*", @@ -130,6 +136,7 @@ hostgcc = { map_to = "=" } + -- catch all rule to map everything else to TARGETDIR/ default_rootdir = { path = "^/", @@ -137,6 +144,7 @@ default_rootdir = { } export_rules = { + ln, install, cp, rm, |