use safer ecore_exe flags that close stdin/out/err if possible

this is specifically needed for wayland but is relevant to x with
startx too ... dont let processes that e runs like apps inherit
stdin/out/err as it may be a tty and thus allow apps to do nasty
things with that tty.

@fix
This commit is contained in:
Carsten Haitzler 2017-09-23 23:08:37 +09:00
parent 40e8bb044c
commit b9d166f804
10 changed files with 30 additions and 13 deletions

View File

@ -261,7 +261,7 @@ e_desklock_show(Eina_Bool suspend)
if (e_config->xkb.lock_layout)
e_xkb_layout_set(e_config->xkb.lock_layout);
_e_custom_desklock_exe =
ecore_exe_run(e_config->desklock_custom_desklock_cmd, NULL);
e_util_exe_safe_run(e_config->desklock_custom_desklock_cmd, NULL);
_e_desklock_state = EINA_TRUE;
e_bindings_disabled_set(1);
/* TODO: ensure layer is correct on external desklocks? */

View File

@ -490,8 +490,8 @@ _e_exec_cb_exec(void *data, Efreet_Desktop *desktop, char *exec, int remaining)
eina_strbuf_append(sb, tdesktop->exec);
eina_strbuf_append(sb, " -e ");
eina_strbuf_append_escaped(sb, exec);
exe = ecore_exe_run(eina_strbuf_string_get(sb),
inst);
exe = e_util_exe_safe_run
(eina_strbuf_string_get(sb), inst);
eina_strbuf_free(sb);
}
}
@ -511,11 +511,11 @@ _e_exec_cb_exec(void *data, Efreet_Desktop *desktop, char *exec, int remaining)
snprintf(sb, size, "%s/enlightenment_open ", e_prefix_bin_get());
len = strlen(sb);
sb = e_util_string_append_quoted(sb, &size, &len, desktop->url);
exe = ecore_exe_run(sb, inst);
exe = e_util_exe_safe_run(sb, inst);
free(sb);
}
else
exe = ecore_exe_run(exec, inst);
exe = e_util_exe_safe_run(exec, inst);
}
if (!exe)

View File

@ -347,7 +347,8 @@ e_intl_input_method_set(const char *imc_path)
{
// if you see valgrind complain about memory
// definitely lost here... it's wrong.
_e_intl_input_method_exec = ecore_exe_run(imc->e_im_exec, NULL);
_e_intl_input_method_exec = e_util_exe_safe_run
(imc->e_im_exec, NULL);
ecore_exe_tag_set(_e_intl_input_method_exec, "E/im_exec");
if ((!_e_intl_input_method_exec) ||

View File

@ -46,7 +46,7 @@ e_remember_init(E_Startup_Mode mode)
{
if ((rem->apply & E_REMEMBER_APPLY_RUN) && (rem->prop.command))
{
if (!ecore_exe_run(rem->prop.command, NULL))
if (!e_util_exe_safe_run(rem->prop.command, NULL))
{
e_util_dialog_show(_("Run Error"),
_("Enlightenment was unable to fork a child process:<ps/>"

View File

@ -139,7 +139,7 @@ e_thumb_icon_begin(Evas_Object *obj)
snprintf(buf, sizeof(buf), "%s/enlightenment/utils/enlightenment_thumb --nice=%d", e_prefix_lib_get(),
e_config->thumb_nice);
exe = ecore_exe_run(buf, NULL);
exe = e_util_exe_safe_run(buf, NULL);
_thumbnailers_exe = eina_list_append(_thumbnailers_exe, exe);
}
_thumb_queue = eina_list_append(_thumb_queue, eth);

View File

@ -1487,7 +1487,21 @@ e_util_open(const char *exe, void *data)
snprintf(sb, size, "%s/enlightenment_open ", e_prefix_bin_get());
len = strlen(sb);
sb = e_util_string_append_quoted(sb, &size, &len, exe);
ret = ecore_exe_run(sb, data);
ret = e_util_exe_safe_run(sb, data);
free(sb);
return ret;
}
E_API Ecore_Exe *
e_util_exe_safe_run(const char *cmd, void *data)
{
Ecore_Exe_Flags flags = ECORE_EXE_NONE;
#if (ECORE_VERSION_MAJOR >= 1) && (ECORE_VERSION_MINOR >= 21)
flags |= ECORE_EXE_ISOLATE_IO;
#else
flags |= 1024; // isolate_io is bit 10 .... it will be ignored if
// efl doesnt do it, so harmless
#endif
return ecore_exe_pipe_run(cmd, flags, data);
}

View File

@ -68,6 +68,8 @@ E_API void e_util_memclear(void *s, size_t n);
E_API Ecore_Exe *e_util_open(const char *exe, void *data);
E_API Ecore_Exe *e_util_exe_safe_run(const char *cmd, void *data);
static inline Eina_Bool
isedje(const Evas_Object *obj)
{

View File

@ -264,7 +264,7 @@ _e_imc_setup_cb(void *data, void *data2 EINA_UNUSED)
cmd = imc->e_im_setup_exec;
exe = ecore_exe_run(cmd, NULL);
exe = e_util_exe_safe_run(cmd, NULL);
if (!exe)
{
@ -518,7 +518,7 @@ _e_imc_adv_setup_cb(void *data, void *data2 EINA_UNUSED)
cmd = cfdata->imc.e_im_setup_exec;
exe = ecore_exe_run(cmd, NULL);
exe = e_util_exe_safe_run(cmd, NULL);
if (!exe)
{

View File

@ -445,7 +445,7 @@ _emixer_exec_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_
_popup_del(inst);
if (mixer_context->emixer) return;
mixer_context->emixer = ecore_exe_run("emixer", NULL);
mixer_context->emixer = e_util_exe_safe_run("emixer", NULL);
if (mixer_context->emix_event_handler)
ecore_event_handler_del(mixer_context->emix_event_handler);
mixer_context->emix_event_handler =

View File

@ -383,7 +383,7 @@ _emixer_exec_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_
elm_ctxpopup_dismiss(inst->popup);
if (gmixer_context->emixer) return;
gmixer_context->emixer = ecore_exe_run("emixer", NULL);
gmixer_context->emixer = e_util_exe_safe_run("emixer", NULL);
if (gmixer_context->emix_event_handler)
ecore_event_handler_del(gmixer_context->emix_event_handler);
gmixer_context->emix_event_handler =