]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
Just create proxy and ask for owner rather than manually calling StartServiceByName...
authorMichael Terry <michael.terry@canonical.com>
Wed, 14 May 2014 20:19:00 +0000 (16:19 -0400)
committerMichael Terry <michael.terry@canonical.com>
Wed, 14 May 2014 20:19:00 +0000 (16:19 -0400)
src/login1.c
tests/src/libsystem.c

index 60eec45781f41bba46a25f7d4f4a4a0fb18df532..cd780c58999a691994a1d2b72d2d453470320513 100644 (file)
 #include "login1.h"
 
 static gboolean
-start_login1 (void)
+check_login1 (void)
 {
-    GDBusConnection *bus;
-    GVariant *result;
-    guint32 success;
-
-    bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
-    if (!bus)
+    GDBusProxy *proxy;
+    gchar *owner;
+    gboolean success;
+
+    proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+                                           G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+                                           NULL,
+                                           "org.freedesktop.login1",
+                                           "/org/freedesktop/login1",
+                                           "org.freedesktop.login1.Manager",
+                                           NULL,
+                                           NULL);
+    if (!proxy)
         return FALSE;
 
-    result = g_dbus_connection_call_sync (bus,
-                                          "org.freedesktop.DBus",
-                                          "/org/freedesktop/DBus",
-                                          "org.freedesktop.DBus",
-                                          "StartServiceByName",
-                                          g_variant_new ("(su)",
-                                                         "org.freedesktop.login1",
-                                                         0),
-                                          G_VARIANT_TYPE ("(u)"),
-                                          G_DBUS_CALL_FLAGS_NONE,
-                                          -1,
-                                          NULL,
-                                          NULL);
-    g_object_unref (bus);
-    if (!result)
-        return FALSE;
+    owner = g_dbus_proxy_get_name_owner (proxy);
+    g_object_unref (proxy);
 
-    g_variant_get (result, "(u)", &success);
-    g_variant_unref (result);
+    success = (owner != NULL);
+    g_free (owner);
 
-    return success == 1 || success == 2; // started or already existed
+    return success;
 }
 
 gboolean
@@ -57,7 +50,7 @@ login1_is_running (void)
     if (!have_checked)
     {
         have_checked = TRUE;
-        is_running = start_login1();
+        is_running = check_login1();
     }
 
     return is_running;
index 0c25b8c435628cd5acbbd51a9dafbc25e24a1eb8..83f2467d176660df0516b3bed745a22383542ffd 100644 (file)
@@ -331,10 +331,6 @@ access (const char *pathname, int mode)
     gchar *new_path = NULL;
     int ret;
 
-    /* Look like systemd is always running */
-    if (strcmp (pathname, "/run/systemd/seats/") == 0)
-        return 1;
-
     _access = (int (*)(const char *pathname, int mode)) dlsym (RTLD_NEXT, "access");
 
     new_path = redirect_path (pathname);