[gnome-settings-daemon] common: Whitelist the plugins that should run under gdm



commit c07ef560dfeda2269ea69f05d8f5977b484fb11d
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Oct 5 13:19:59 2016 +0200

    common: Whitelist the plugins that should run under gdm
    
    As we don't have a way to restrict which plugins get enabled from the
    gdm side, do it ourselves.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772370

 plugins/common/daemon-skeleton-gtk.h |   49 +++++++++++++++++++++++++++++-----
 plugins/common/daemon-skeleton.h     |   49 +++++++++++++++++++++++++++++-----
 2 files changed, 84 insertions(+), 14 deletions(-)
---
diff --git a/plugins/common/daemon-skeleton-gtk.h b/plugins/common/daemon-skeleton-gtk.h
index 05d94a2..09b5251 100644
--- a/plugins/common/daemon-skeleton-gtk.h
+++ b/plugins/common/daemon-skeleton-gtk.h
@@ -38,6 +38,38 @@ static GOptionEntry entries[] = {
         {NULL}
 };
 
+static const char *gdm_helpers[] = {
+       "gsd-a11y-keyboard",
+       "gsd-a11y-settings",
+       "gsd-clipboard",
+       "gsd-color",
+       "gsd-keyboard",
+       "gsd-media-keys",
+       "gsd-orientation",
+       "gsd-power",
+       "gsd-smartcard",
+       "gsd-sound",
+       "gsd-xrandr",
+       "gsd-xsettings"
+};
+
+static gboolean
+should_run (void)
+{
+       const char *session_mode;
+       guint i;
+
+       session_mode = g_getenv ("GNOME_SHELL_SESSION_MODE");
+       if (g_strcmp0 (session_mode, "gdm") != 0)
+               return TRUE;
+
+       for (i = 0; i < G_N_ELEMENTS (gdm_helpers); i++) {
+               if (g_str_equal (PLUGIN_NAME, gdm_helpers[i]))
+                       return TRUE;
+       }
+       return FALSE;
+}
+
 static void
 respond_to_end_session (GDBusProxy *proxy)
 {
@@ -161,16 +193,19 @@ main (int argc, char **argv)
         manager = NEW ();
        register_with_gnome_session ();
 
-        error = NULL;
-        if (!START (manager, &error)) {
-                fprintf (stderr, "Failed to start: %s\n", error->message);
-                g_error_free (error);
-                exit (1);
-        }
+       if (should_run ()) {
+               error = NULL;
+               if (!START (manager, &error)) {
+                       fprintf (stderr, "Failed to start: %s\n", error->message);
+                       g_error_free (error);
+                       exit (1);
+               }
+       }
 
         gtk_main ();
 
-        STOP (manager);
+       if (should_run ())
+               STOP (manager);
         g_object_unref (manager);
 
         return 0;
diff --git a/plugins/common/daemon-skeleton.h b/plugins/common/daemon-skeleton.h
index be71442..7c93ced 100644
--- a/plugins/common/daemon-skeleton.h
+++ b/plugins/common/daemon-skeleton.h
@@ -37,6 +37,38 @@ static GOptionEntry entries[] = {
         {NULL}
 };
 
+static const char *gdm_helpers[] = {
+       "gsd-a11y-keyboard",
+       "gsd-a11y-settings",
+       "gsd-clipboard",
+       "gsd-color",
+       "gsd-keyboard",
+       "gsd-media-keys",
+       "gsd-orientation",
+       "gsd-power",
+       "gsd-smartcard",
+       "gsd-sound",
+       "gsd-xrandr",
+       "gsd-xsettings"
+};
+
+static gboolean
+should_run (void)
+{
+       const char *session_mode;
+       guint i;
+
+       session_mode = g_getenv ("GNOME_SHELL_SESSION_MODE");
+       if (g_strcmp0 (session_mode, "gdm") != 0)
+               return TRUE;
+
+       for (i = 0; i < G_N_ELEMENTS (gdm_helpers); i++) {
+               if (g_str_equal (PLUGIN_NAME, gdm_helpers[i]))
+                       return TRUE;
+       }
+       return FALSE;
+}
+
 static void
 respond_to_end_session (GDBusProxy *proxy)
 {
@@ -165,16 +197,19 @@ main (int argc, char **argv)
         manager = NEW ();
        register_with_gnome_session (loop);
 
-        error = NULL;
-        if (!START (manager, &error)) {
-                fprintf (stderr, "Failed to start: %s\n", error->message);
-                g_error_free (error);
-                exit (1);
-        }
+       if (should_run ()) {
+               error = NULL;
+               if (!START (manager, &error)) {
+                       fprintf (stderr, "Failed to start: %s\n", error->message);
+                       g_error_free (error);
+                       exit (1);
+               }
+       }
 
         g_main_loop_run (loop);
 
-        STOP (manager);
+       if (should_run ())
+               STOP (manager);
         g_object_unref (manager);
 
         return 0;


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