From 8278f24b6ad39039bad4a6575196a4f32e5294ca Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Wed, 4 Dec 2013 09:47:34 +0000 Subject: [PATCH] Avoid double forking when launching external apps. Some security conscious applications such as pkexec detect double forks and refuse to operate. Avoiding the double fork here is very simple. I've not reindented to save code churn. See https://bugzilla.xfce.org/show_bug.cgi?id=9373 and https://bugzilla.gnome.org/show_bug.cgi?id=686059 --- libxfce4ui/xfce-spawn.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libxfce4ui/xfce-spawn.c b/libxfce4ui/xfce-spawn.c index e023c55..b2b47aa 100644 --- a/libxfce4ui/xfce-spawn.c +++ b/libxfce4ui/xfce-spawn.c @@ -389,17 +389,13 @@ xfce_spawn_on_screen_with_child_watch (GdkScreen *screen, startup_id = sn_launcher_context_get_startup_id (sn_launcher); if (G_LIKELY (startup_id != NULL)) cenvp[n_cenvp++] = g_strconcat ("DESKTOP_STARTUP_ID=", startup_id, NULL); - - /* we want to watch the child process */ - flags |= G_SPAWN_DO_NOT_REAP_CHILD; } } } #endif - /* watch the child when the user supplied a closure too */ - if (child_watch_closure != NULL) - flags |= G_SPAWN_DO_NOT_REAP_CHILD; + /* We always want to not reap the child to prevent double forking */ + flags |= G_SPAWN_DO_NOT_REAP_CHILD; /* test if the working directory exists */ if (working_directory == NULL || *working_directory == '\0') @@ -423,8 +419,6 @@ xfce_spawn_on_screen_with_child_watch (GdkScreen *screen, if (G_LIKELY (succeed)) { - if ((flags & G_SPAWN_DO_NOT_REAP_CHILD) != 0) - { /* setup data to watch the child */ spawn_data = g_slice_new0 (XfceSpawnData); spawn_data->pid = pid; @@ -453,7 +447,6 @@ xfce_spawn_on_screen_with_child_watch (GdkScreen *screen, xfce_spawn_startup_timeout_destroy); } #endif - } } else { -- 1.8.4.4