Commit 3f042f36 authored by Lauri Aarnio's avatar Lauri Aarnio

Execs: Postprocess native dynamic binaries with C code

- Part of Lua code (sb_execve_postprocess_native_executable()
  in argvenvp.lua) was implemented in C (=> added new file
  execs/exec_postprocess.c)
parent aee5e70e
......@@ -4,6 +4,7 @@ objs := $(D)/exec_ruletree_maint.o \
$(D)/exec_policy_selection.o \
$(D)/exec_map_script_interp.o \
$(D)/exec_policy_ruletree.o \
$(D)/exec_postprocess.o \
$(D)/sb_exec.o
$(D)/sb_exec.o: preload/exported.h
......
......@@ -50,8 +50,13 @@ const char *exec_policy_get_string(exec_policy_handle_t eph,
offs = ruletree_catalog_find_value_from_catalog(
eph.exec_policy_offset, s_name);
str = offset_to_ruletree_string_ptr(offs, NULL);
SB_LOG(SB_LOGLEVEL_NOISE,
"%s: %s='%s'", __func__, s_name, str, fldoffs);
if (str) {
SB_LOG(SB_LOGLEVEL_NOISE,
"%s: %s='%s'", __func__, s_name, str, fldoffs);
} else {
SB_LOG(SB_LOGLEVEL_NOISE,
"%s: No %s", __func__, s_name, fldoffs);
}
return(str);
}
return(NULL);
......
This diff is collapsed.
......@@ -27,6 +27,26 @@ extern const char *find_exec_policy_name(const char *mapped_path, const char *vi
* (see the EXEC_POLICY_GET_* macros and exec_policy_get_* functions)
*/
struct exec_policy_fields {
char log_level;
char log_message;
char native_app_ld_so;
char native_app_ld_library_path;
char native_app_ld_library_path_prefix;
char native_app_ld_library_path_suffix;
char native_app_ld_preload;
char native_app_ld_preload_prefix;
char native_app_ld_preload_suffix;
char native_app_ld_so_rpath_prefix;
char native_app_ld_so_supports_rpath_prefix;
char native_app_ld_so_supports_argv0;
char native_app_ld_so_supports_nodefaultdirs;
char native_app_locale_path;
char native_app_gconv_path;
char script_log_level;
char script_log_message;
char script_deny_exec;
......@@ -38,6 +58,8 @@ typedef struct {
ruletree_object_offset_t exec_policy_offset;
} exec_policy_handle_t;
#define exec_policy_handle_is_valid(eph) ((eph).exec_policy_offset != 0)
extern exec_policy_handle_t find_exec_policy_handle(const char *policyname);
extern const char *exec_policy_get_string(exec_policy_handle_t eph,
......@@ -70,5 +92,15 @@ extern int exec_map_script_interpreter(
const char **new_exec_policy_p,
char **mapped_interpreter_p);
int exec_postprocess_native_executable(
const char *exec_policy_name,
char **mapped_file,
char **filename,
const char *binary_name,
const char **orig_argv,
const char ***set_argv,
const char **orig_env,
const char ***set_envp);
#endif /* __EXEC_INTERNAL_H */
......@@ -1222,7 +1222,9 @@ static int prepare_exec(const char *exec_fn_name,
char ***new_argv,
char ***new_envp) /* *new_envp must be filled by the caller */
{
char **my_envp = *new_envp;
char **my_envp = *new_envp; /* FIXME */
const char **my_new_envp = NULL;
const char **my_new_argv = NULL;
char **my_argv = NULL, *my_file = NULL;
char *binaryname, *tmp, *mapped_file;
int err = 0;
......@@ -1342,10 +1344,19 @@ static int prepare_exec(const char *exec_fn_name,
SB_LOG(SB_LOGLEVEL_DEBUG, "Exec/host-dynamic %s",
mapped_file);
#if 0
postprocess_result = sb_execve_postprocess("native",
exec_policy_name,
&mapped_file, &my_file, binaryname,
&my_argv, &my_envp);
#else
postprocess_result = exec_postprocess_native_executable(
exec_policy_name,
&mapped_file, &my_file, binaryname,
(const char **)my_argv, &my_new_argv, (const char **)*new_envp, &my_new_envp);
my_envp = (char**)my_new_envp; /* FIXME */
my_argv = (char**)my_new_argv; /* FIXME */
#endif
if (postprocess_result < 0) {
errno = EINVAL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment