diff options
author | Lauri Leukkunen <lle@rahina.org> | 2007-12-10 06:01:29 +0200 |
---|---|---|
committer | Lauri Leukkunen <lle@rahina.org> | 2007-12-10 06:01:29 +0200 |
commit | 4ee4e9f76b624ee3250f4924ce7575a3d9ce453a (patch) | |
tree | ed72f8a3e5b90cfcf2169125728208cd5a502133 /luaif | |
parent | a0f578e0faa723f01a663fce09f0f74dbf09e3ec (diff) |
Generic execve() mangling
sb_gcc_wrapper functionality is now implemented directly in libsb2.so as
a lua script directly managing the execve(file, argv, envp) call.
Same functionality can be used to do other things as well, see for
the dpkg-architecture example in lua_scripts/argvenvp.lua
Signed-off-by: Lauri Leukkunen <lle@rahina.org>
Diffstat (limited to 'luaif')
-rw-r--r-- | luaif/argvenvp.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/luaif/argvenvp.c b/luaif/argvenvp.c index 92ef282..795fca7 100644 --- a/luaif/argvenvp.c +++ b/luaif/argvenvp.c @@ -16,7 +16,7 @@ extern int lua_engine_state; static char *argvenvp_mode; -int sb_argvenvp(const char *binary_name, char ***argv, char ***envp) +int sb_execve_mod(char **file, char ***argv, char ***envp) { struct lua_instance *luaif; char **p; @@ -56,8 +56,9 @@ int sb_argvenvp(const char *binary_name, char ***argv, char ***envp) return 0; } - lua_getfield(luaif->lua, LUA_GLOBALSINDEX, "sbox_argvenvp"); - lua_pushstring(luaif->lua, binary_name); + lua_getfield(luaif->lua, LUA_GLOBALSINDEX, "sbox_execve_mod"); + lua_pushstring(luaif->lua, *file); + free(*file); lua_newtable(luaif->lua); for (p = *argv, i = 1; *p; p++, i++) { @@ -78,10 +79,11 @@ int sb_argvenvp(const char *binary_name, char ***argv, char ***envp) free(*envp); /* args: binaryname, argv, envp - * returns: err, argc, argv, envc, envp */ - lua_call(luaif->lua, 3, 5); - - res = lua_tointeger(luaif->lua, -5); + * returns: err, file, argc, argv, envc, envp */ + lua_call(luaif->lua, 3, 6); + + res = lua_tointeger(luaif->lua, -6); + *file = strdup(lua_tostring(luaif->lua, -5)); new_argc = lua_tointeger(luaif->lua, -4); new_envc = lua_tointeger(luaif->lua, -2); @@ -104,5 +106,5 @@ int sb_argvenvp(const char *binary_name, char ***argv, char ***envp) } (*envp)[i] = NULL; - return 0; + return res; } |