#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
if (!have_checked)
{
have_checked = TRUE;
- is_running = start_login1();
+ is_running = check_login1();
}
return is_running;
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);