[gnome-shell] app: Work around pkexec restriction when launching



commit 053b8da89c5260351199d8c51821db1a2f91cdf4
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Mar 25 02:46:25 2017 +0100

    app: Work around pkexec restriction when launching
    
    Unless automatic child reaping is disabled in GSpawnFlags, glib's
    g_spawn_* functions will reparent the spawned process to init by
    double-forking. Unfortunately pkexec bails out in this case[0],
    which means that it no longer works in .desktop files since the
    PID tracking removal in commit 01c6392c1373.
    Fix this by going back to manual child reaping.
    
    [0] https://cgit.freedesktop.org/polkit/tree/src/programs/pkexec.c#n728
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763531

 src/shell-app.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/shell-app.c b/src/shell-app.c
index b383d9c..335147c 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -1196,6 +1196,14 @@ app_child_setup (gpointer user_data)
 }
 #endif
 
+static void
+wait_pid (GDesktopAppInfo *appinfo,
+          GPid             pid,
+          gpointer         user_data)
+{
+  g_child_watch_add (pid, (GChildWatchFunc) g_spawn_close_pid, NULL);
+}
+
 /**
  * shell_app_launch:
  * @timestamp: Event timestamp, or 0 for current event timestamp
@@ -1234,13 +1242,13 @@ shell_app_launch (ShellApp     *app,
 
   ret = g_desktop_app_info_launch_uris_as_manager (app->info, NULL,
                                                    context,
-                                                   G_SPAWN_SEARCH_PATH,
+                                                   G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
 #ifdef HAVE_SYSTEMD
                                                    app_child_setup, (gpointer)shell_app_get_id (app),
 #else
                                                    NULL, NULL,
 #endif
-                                                   NULL, NULL,
+                                                   wait_pid, NULL,
                                                    error);
   g_object_unref (context);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]