]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blobdiff - tests/src/test-runner.c
Fix warning about status timeout
[sojka/lightdm.git] / tests / src / test-runner.c
index 017811d017f82081422d24b0f48099a9f937fecc..018007046f71256aaa1d644c3ca82e3d70fbe86c 100644 (file)
@@ -81,6 +81,28 @@ static const GDBusInterfaceVTable user_vtable =
     handle_user_call,
     handle_user_get_property,
 };
+static GDBusNodeInfo *ck_session_info;
+typedef struct
+{
+    gchar *cookie;
+    gchar *path;
+    guint id;
+    gboolean locked;
+} CKSession;
+static GList *ck_sessions = NULL;
+static gint ck_session_index = 0;
+static void handle_ck_session_call (GDBusConnection       *connection,
+                                    const gchar           *sender,
+                                    const gchar           *object_path,
+                                    const gchar           *interface_name,
+                                    const gchar           *method_name,
+                                    GVariant              *parameters,
+                                    GDBusMethodInvocation *invocation,
+                                    gpointer               user_data);
+static const GDBusInterfaceVTable ck_session_vtable =
+{
+    handle_ck_session_call,
+};
 
 typedef struct
 {
@@ -88,6 +110,7 @@ typedef struct
     gchar *path;
     gboolean can_graphical;
     gboolean can_multi_session;
+    gchar *active_session;
 } Login1Seat;
 
 static GList *login1_seats = NULL;
@@ -116,10 +139,12 @@ static GList *status_clients = NULL;
 
 static void ready (void);
 static void quit (int status);
+static gboolean status_timeout_cb (gpointer data);
 static void check_status (const gchar *status);
 static AccountsUser *get_accounts_user_by_uid (guint uid);
 static AccountsUser *get_accounts_user_by_name (const gchar *username);
 static void accounts_user_set_hidden (AccountsUser *user, gboolean hidden, gboolean emit_signal);
+static Login1Session *find_login1_session (const gchar *id);
 
 static gboolean
 kill_timeout_cb (gpointer data)
@@ -498,11 +523,26 @@ handle_command (const gchar *command)
     }
     else if (strcmp (name, "WAIT") == 0)
     {
+        const gchar *v;
+        int duration;
+
+        /* Stop status timeout */
+        if (status_timeout)
+            g_source_remove (status_timeout);
+        status_timeout = 0;
+
         /* Use a main loop so that our DBus functions are still responsive */
         GMainLoop *loop = g_main_loop_new (NULL, FALSE);
-        g_timeout_add_seconds (1, stop_loop, loop);
+        v = g_hash_table_lookup (params, "DURATION");
+        duration = v ? atoi (v) : 1;
+        if (duration < 1)
+            duration = 1;
+        g_timeout_add_seconds (duration, stop_loop, loop);
         g_main_loop_run (loop);
         g_main_loop_unref (loop);
+
+        /* Restart status timeout */
+        status_timeout = g_timeout_add (status_timeout_ms, status_timeout_cb, NULL);
     }
     else if (strcmp (name, "ADD-SEAT") == 0)
     {
@@ -518,6 +558,25 @@ handle_command (const gchar *command)
         if (v)
             seat->can_multi_session = strcmp (v, "TRUE") == 0;
     }
+    else if (strcmp (name, "ADD-LOCAL-X-SEAT") == 0)
+    {
+        GVariant *result;
+        const gchar *v;
+
+        v = g_hash_table_lookup (params, "DISPLAY");
+        result = g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
+                                              "org.freedesktop.DisplayManager",
+                                              "/org/freedesktop/DisplayManager",
+                                              "org.freedesktop.DisplayManager",
+                                              "AddLocalXSeat",
+                                              g_variant_new ("(i)", v ? atoi (v) : -1),
+                                              G_VARIANT_TYPE ("(o)"),
+                                              G_DBUS_CALL_FLAGS_NONE,
+                                              G_MAXINT,
+                                              NULL,
+                                              NULL);
+        g_variant_unref (result);
+    }
     else if (strcmp (name, "UPDATE-SEAT") == 0)
     {
         Login1Seat *seat;
@@ -545,6 +604,13 @@ handle_command (const gchar *command)
                 seat->can_multi_session = strcmp (v, "TRUE") == 0;
                 g_variant_builder_add (&invalidated_properties, "s", "CanMultiSession");
             }
+            v = g_hash_table_lookup (params, "ACTIVE-SESSION");
+            if (v)
+            {
+                g_free (seat->active_session);
+                seat->active_session = g_strdup (v);
+                g_variant_builder_add (&invalidated_properties, "s", "ActiveSession");
+            }
 
             g_dbus_connection_emit_signal (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
                                            NULL,
@@ -806,6 +872,7 @@ handle_command (const gchar *command)
         GString *status_text;
         gchar *username;
         AccountsUser *user;
+        GError *error = NULL;
 
         status_text = g_string_new ("RUNNER UPDATE-USER USERNAME=");
 
@@ -814,81 +881,68 @@ handle_command (const gchar *command)
         user = get_accounts_user_by_name (username);
         if (user)
         {
-            GVariantBuilder invalidated_properties;
-            GError *error = NULL;
-
-            g_variant_builder_init (&invalidated_properties, G_VARIANT_TYPE_ARRAY);
-
             if (g_hash_table_lookup (params, "NAME"))
             {
                 user->user_name = g_strdup (g_hash_table_lookup (params, "NAME"));
                 g_string_append_printf (status_text, " NAME=%s", user->user_name);
-                g_variant_builder_add (&invalidated_properties, "s", "UserName");
             }
             if (g_hash_table_lookup (params, "REAL-NAME"))
             {
                 user->real_name = g_strdup (g_hash_table_lookup (params, "REAL-NAME"));
                 g_string_append_printf (status_text, " REAL-NAME=%s", user->real_name);
-                g_variant_builder_add (&invalidated_properties, "s", "RealName");
             }
             if (g_hash_table_lookup (params, "HOME-DIRECTORY"))
             {
                 user->home_directory = g_strdup (g_hash_table_lookup (params, "HOME-DIRECTORY"));
                 g_string_append_printf (status_text, " HOME-DIRECTORY=%s", user->home_directory);
-                g_variant_builder_add (&invalidated_properties, "s", "HomeDirectory");
             }
             if (g_hash_table_lookup (params, "IMAGE"))
             {
                 user->image = g_strdup (g_hash_table_lookup (params, "IMAGE"));
                 g_string_append_printf (status_text, " IMAGE=%s", user->image);
-                g_variant_builder_add (&invalidated_properties, "s", "IconFile");
             }
             if (g_hash_table_lookup (params, "BACKGROUND"))
             {
                 user->background = g_strdup (g_hash_table_lookup (params, "BACKGROUND"));
                 g_string_append_printf (status_text, " BACKGROUND=%s", user->background);
-                g_variant_builder_add (&invalidated_properties, "s", "BackgroundFile");
             }
             if (g_hash_table_lookup (params, "LANGUAGE"))
             {
                 user->language = g_strdup (g_hash_table_lookup (params, "LANGUAGE"));
                 g_string_append_printf (status_text, " LANGUAGE=%s", user->language);
-                g_variant_builder_add (&invalidated_properties, "s", "Language");
             }
             if (g_hash_table_lookup (params, "LAYOUTS"))
             {
                 const gchar *value = g_hash_table_lookup (params, "LAYOUTS");
                 user->layouts = g_strsplit (value, ";", -1);
                 g_string_append_printf (status_text, " LAYOUTS=%s", value);
-                g_variant_builder_add (&invalidated_properties, "s", "XKeyboardLayouts");
             }
             if (g_hash_table_lookup (params, "HAS-MESSAGES"))
             {
                 user->has_messages = g_strcmp0 (g_hash_table_lookup (params, "HAS-MESSAGES"), "TRUE") == 0;
                 g_string_append_printf (status_text, " HAS-MESSAGES=%s", user->has_messages ? "TRUE" : "FALSE");
-                g_variant_builder_add (&invalidated_properties, "s", "XHasMessages");
             }
             if (g_hash_table_lookup (params, "SESSION"))
             {
                 user->xsession = g_strdup (g_hash_table_lookup (params, "SESSION"));
                 g_string_append_printf (status_text, " SESSION=%s", user->xsession);
-                g_variant_builder_add (&invalidated_properties, "s", "XSession");
             }
 
             g_dbus_connection_emit_signal (accounts_connection,
                                            NULL,
                                            user->path,
-                                           "org.freedesktop.DBus.Properties",
-                                           "PropertiesChanged",
-                                           g_variant_new ("(sa{sv}as)", "org.freedesktop.Accounts.User", NULL, &invalidated_properties),
+                                           "org.freedesktop.Accounts.User",
+                                           "Changed",
+                                           g_variant_new ("()"),
                                            &error);
-            if (error)
-                g_warning ("Failed to emit PropertiesChanged: %s", error->message);
-            g_clear_error (&error);
         }
         else
             g_warning ("Unknown user %s", username);
 
+        if (error)
+            g_warning ("Failed to emit Changed: %s", error->message);
+        g_clear_error (&error);
+
         check_status (status_text->str);
         g_string_free (status_text, TRUE);
     }
@@ -908,10 +962,32 @@ handle_command (const gchar *command)
         check_status (status_text);
         g_free (status_text);
     }
+    else if (strcmp (name, "UNLOCK-SESSION") == 0)
+    {
+        gchar *status_text, *id;
+        Login1Session *session;
+        
+        id = g_hash_table_lookup (params, "SESSION");
+        session = find_login1_session (id);
+        if (session)
+        {
+            if (!session->locked)
+                g_warning ("Session %s is not locked", id);
+            session->locked = FALSE;
+        }
+        else
+            g_warning ("Unknown session %s", id);
+
+        status_text = g_strdup_printf ("RUNNER UNLOCK-SESSION SESSION=%s", id);
+        check_status (status_text);
+        g_free (status_text);
+    }
     /* Forward to external processes */
     else if (g_str_has_prefix (name, "SESSION-") ||
              g_str_has_prefix (name, "GREETER-") ||
              g_str_has_prefix (name, "XSERVER-") ||
+             g_str_has_prefix (name, "XMIR-") ||
+             g_str_has_prefix (name, "XVNC-") ||
              strcmp (name, "UNITY-SYSTEM-COMPOSITOR") == 0)
     {
         GList *link;
@@ -967,10 +1043,12 @@ status_timeout_cb (gpointer data)
 {
     ScriptLine *line;
 
+    status_timeout = 0;
+
     line = get_script_line (NULL);
     fail ("(timeout)", line ? line->text : NULL);
 
-    return FALSE;
+    return G_SOURCE_REMOVE;
 }
 
 static void
@@ -1199,6 +1277,267 @@ start_upower_daemon (void)
                     NULL);
 }
 
+static CKSession *
+open_ck_session (GDBusConnection *connection, GVariant *params)
+{
+    CKSession *session;
+    GString *cookie;
+    GVariantIter *iter;
+    const gchar *name;
+    GVariant *value;
+    GError *error = NULL;
+
+    session = g_malloc0 (sizeof (CKSession));
+    ck_sessions = g_list_append (ck_sessions, session);
+
+    cookie = g_string_new ("ck-cookie");
+    g_variant_get (params, "a(sv)", &iter);
+    while (g_variant_iter_loop (iter, "(&sv)", &name, &value))
+    {
+        if (strcmp (name, "x11-display") == 0)
+        {
+            const gchar *display;
+            g_variant_get (value, "&s", &display);
+            g_string_append_printf (cookie, "-x%s", display);
+        }
+    }
+
+    session->cookie = cookie->str;
+    g_string_free (cookie, FALSE);
+    session->path = g_strdup_printf ("/org/freedesktop/ConsoleKit/Session%d", ck_session_index++);
+    session->id = g_dbus_connection_register_object (connection,
+                                                     session->path,
+                                                     ck_session_info->interfaces[0],
+                                                     &ck_session_vtable,
+                                                     session,
+                                                     NULL,
+                                                     &error);
+    if (error)
+        g_warning ("Failed to register CK Session: %s", error->message);
+    g_clear_error (&error);
+
+    return session;
+}
+
+static void
+handle_ck_call (GDBusConnection       *connection,
+                const gchar           *sender,
+                const gchar           *object_path,
+                const gchar           *interface_name,
+                const gchar           *method_name,
+                GVariant              *parameters,
+                GDBusMethodInvocation *invocation,
+                gpointer               user_data)
+{
+    if (strcmp (method_name, "CanRestart") == 0)
+    {
+        check_status ("CONSOLE-KIT CAN-RESTART");
+        g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", TRUE));
+    }
+    else if (strcmp (method_name, "CanStop") == 0)
+    {
+        check_status ("CONSOLE-KIT CAN-STOP");
+        g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", TRUE));
+    }
+    else if (strcmp (method_name, "CloseSession") == 0)
+        g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", TRUE));
+    else if (strcmp (method_name, "OpenSession") == 0)
+    {
+        GVariantBuilder params;
+        g_variant_builder_init (&params, G_VARIANT_TYPE ("a(sv)"));
+        CKSession *session = open_ck_session (connection, g_variant_builder_end (&params));
+        g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", session->cookie));
+    }
+    else if (strcmp (method_name, "OpenSessionWithParameters") == 0)
+    {
+        CKSession *session = open_ck_session (connection, g_variant_get_child_value (parameters, 0));
+        g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", session->cookie));
+    }
+    else if (strcmp (method_name, "GetSessionForCookie") == 0)
+    {
+        GList *link;
+        gchar *cookie;
+
+        g_variant_get (parameters, "(&s)", &cookie);
+
+        for (link = ck_sessions; link; link = link->next)
+        {
+            CKSession *session = link->data;
+            if (strcmp (session->cookie, cookie) == 0)
+            {
+                g_dbus_method_invocation_return_value (invocation, g_variant_new ("(o)", session->path));
+                return;
+            }
+        }
+
+        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Unable to find session for cookie");
+    }
+    else if (strcmp (method_name, "Restart") == 0)
+    {
+        check_status ("CONSOLE-KIT RESTART");
+        g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
+    }
+    else if (strcmp (method_name, "Stop") == 0)
+    {
+        check_status ("CONSOLE-KIT STOP");
+        g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
+    }
+    else
+        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "No such method: %s", method_name);
+}
+
+static void
+handle_ck_session_call (GDBusConnection       *connection,
+                        const gchar           *sender,
+                        const gchar           *object_path,
+                        const gchar           *interface_name,
+                        const gchar           *method_name,
+                        GVariant              *parameters,
+                        GDBusMethodInvocation *invocation,
+                        gpointer               user_data)
+{
+    CKSession *session = user_data;
+
+    if (strcmp (method_name, "GetXDGRuntimeDir") == 0 && !g_key_file_get_boolean (config, "test-runner-config", "ck-no-xdg-runtime", NULL))
+    {
+        g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", "/run/console-kit"));
+    }
+    else if (strcmp (method_name, "Lock") == 0)
+    {
+        if (!session->locked)
+            check_status ("CONSOLE-KIT LOCK-SESSION");
+        session->locked = TRUE;
+        g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
+    }
+    else if (strcmp (method_name, "Unlock") == 0)
+    {
+        if (session->locked)
+            check_status ("CONSOLE-KIT UNLOCK-SESSION");
+        session->locked = FALSE;
+        g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
+    }
+    else if (strcmp (method_name, "Activate") == 0)
+    {
+        gchar *status = g_strdup_printf ("CONSOLE-KIT ACTIVATE-SESSION SESSION=%s", session->cookie);
+        check_status (status);
+        g_free (status);
+
+        g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
+    }
+    else
+        g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "No such method: %s", method_name);
+}
+
+static void
+ck_name_acquired_cb (GDBusConnection *connection,
+                     const gchar     *name,
+                     gpointer         user_data)
+{
+    const gchar *ck_interface =
+        "<node>"
+        "  <interface name='org.freedesktop.ConsoleKit.Manager'>"
+        "    <method name='CanRestart'>"
+        "      <arg name='can_restart' direction='out' type='b'/>"
+        "    </method>"
+        "    <method name='CanStop'>"
+        "      <arg name='can_stop' direction='out' type='b'/>"
+        "    </method>"
+        "    <method name='CloseSession'>"
+        "      <arg name='cookie' direction='in' type='s'/>"
+        "      <arg name='result' direction='out' type='b'/>"
+        "    </method>"
+        "    <method name='OpenSession'>"
+        "      <arg name='cookie' direction='out' type='s'/>"
+        "    </method>"
+        "    <method name='OpenSessionWithParameters'>"
+        "      <arg name='parameters' direction='in' type='a(sv)'/>"
+        "      <arg name='cookie' direction='out' type='s'/>"
+        "    </method>"
+        "    <method name='GetSessionForCookie'>"
+        "      <arg name='cookie' direction='in' type='s'/>"
+        "      <arg name='ssid' direction='out' type='o'/>"
+        "    </method>"
+        "    <method name='Restart'/>"
+        "    <method name='Stop'/>"
+        "    <signal name='SeatAdded'>"
+        "      <arg name='seat' type='o'/>"
+        "    </signal>"
+        "    <signal name='SeatRemoved'>"
+        "      <arg name='seat' type='o'/>"
+        "    </signal>"
+        "  </interface>"
+        "</node>";
+    static const GDBusInterfaceVTable ck_vtable =
+    {
+        handle_ck_call,
+    };
+    const gchar *ck_session_interface_old =
+        "<node>"
+        "  <interface name='org.freedesktop.ConsoleKit.Session'>"
+        "    <method name='Lock'/>"
+        "    <method name='Unlock'/>"
+        "    <method name='Activate'/>"
+        "  </interface>"
+        "</node>";
+    const gchar *ck_session_interface =
+        "<node>"
+        "  <interface name='org.freedesktop.ConsoleKit.Session'>"
+        "    <method name='GetXDGRuntimeDir'>"
+        "      <arg name='dir' direction='out' type='s'/>"
+        "    </method>"
+        "    <method name='Lock'/>"
+        "    <method name='Unlock'/>"
+        "    <method name='Activate'/>"
+        "  </interface>"
+        "</node>";
+    GDBusNodeInfo *ck_info;
+    GError *error = NULL;
+
+    ck_info = g_dbus_node_info_new_for_xml (ck_interface, &error);
+    if (error)
+        g_warning ("Failed to parse D-Bus interface: %s", error->message);
+    g_clear_error (&error);
+    if (!ck_info)
+        return;
+    if (g_key_file_get_boolean (config, "test-runner-config", "ck-no-xdg-runtime", NULL))
+        ck_session_info = g_dbus_node_info_new_for_xml (ck_session_interface_old, &error);
+    else
+        ck_session_info = g_dbus_node_info_new_for_xml (ck_session_interface, &error);  
+    if (error)
+        g_warning ("Failed to parse D-Bus interface: %s", error->message);
+    g_clear_error (&error);
+    if (!ck_session_info)
+        return;
+    g_dbus_connection_register_object (connection,
+                                       "/org/freedesktop/ConsoleKit/Manager",
+                                       ck_info->interfaces[0],
+                                       &ck_vtable,
+                                       NULL, NULL,
+                                       &error);
+    if (error)
+        g_warning ("Failed to register console kit service: %s", error->message);
+    g_clear_error (&error);
+    g_dbus_node_info_unref (ck_info);
+
+    service_count--;
+    if (service_count == 0)
+        ready ();
+}
+
+static void
+start_console_kit_daemon (void)
+{
+    service_count++;
+    g_bus_own_name (G_BUS_TYPE_SYSTEM,
+                    "org.freedesktop.ConsoleKit",
+                    G_BUS_NAME_OWNER_FLAGS_NONE,
+                    NULL,
+                    ck_name_acquired_cb,
+                    NULL,
+                    NULL,
+                    NULL);
+}
+
 static void
 handle_login1_seat_call (GDBusConnection       *connection,
                          const gchar           *sender,
@@ -1229,6 +1568,22 @@ handle_login1_seat_get_property (GDBusConnection       *connection,
         return g_variant_new_boolean (seat->can_multi_session);
     else if (strcmp (property_name, "Id") == 0)
         return g_variant_new_string (seat->id);
+    else if (strcmp (property_name, "ActiveSession") == 0)
+    {
+        if (seat->active_session)
+        {
+            gchar *path;
+            GVariant *ret;
+            
+            path = g_strdup_printf ("/org/freedesktop/login1/session/%s", seat->active_session);
+            ret = g_variant_new ("(so)", seat->active_session, path);
+            g_free (path);
+
+            return ret;
+        }
+        else 
+            return NULL;
+    }
     else
         return NULL;
 }
@@ -1245,6 +1600,7 @@ add_login1_seat (GDBusConnection *connection, const gchar *id, gboolean emit_sig
         "  <interface name='org.freedesktop.login1.Seat'>"
         "    <property name='CanGraphical' type='b' access='read'/>"
         "    <property name='CanMultiSession' type='b' access='read'/>"
+        "    <property name='ActiveSession' type='(so)' access='read'/>"
         "    <property name='Id' type='s' access='read'/>"
         "  </interface>"
         "</node>";
@@ -1260,6 +1616,7 @@ add_login1_seat (GDBusConnection *connection, const gchar *id, gboolean emit_sig
     seat->path = g_strdup_printf ("/org/freedesktop/login1/seat/%s", seat->id);
     seat->can_graphical = TRUE;
     seat->can_multi_session = TRUE;
+    seat->active_session = NULL;
 
     login1_seat_info = g_dbus_node_info_new_for_xml (login1_seat_interface, &error);
     if (error)
@@ -1337,6 +1694,7 @@ remove_login1_seat (GDBusConnection *connection, const gchar *id)
     login1_seats = g_list_remove (login1_seats, seat);
     g_free (seat->id);
     g_free (seat->path);
+    g_free (seat->active_session);
     g_free (seat);
 }
 
@@ -1909,7 +2267,6 @@ handle_user_call (GDBusConnection       *connection,
     if (strcmp (method_name, "SetXSession") == 0)
     {
         gchar *xsession;
-        GVariantBuilder invalidated_properties;
 
         g_variant_get (parameters, "(&s)", &xsession);
 
@@ -1919,14 +2276,12 @@ handle_user_call (GDBusConnection       *connection,
         g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
 
         /* And notify others that it took */
-        g_variant_builder_init (&invalidated_properties, G_VARIANT_TYPE_ARRAY);
-        g_variant_builder_add (&invalidated_properties, "s", "XSession");
         g_dbus_connection_emit_signal (accounts_connection,
                                        NULL,
                                        user->path,
-                                       "org.freedesktop.DBus.Properties",
-                                       "PropertiesChanged",
-                                       g_variant_new ("(sa{sv}as)", "org.freedesktop.Accounts.User", NULL, &invalidated_properties),
+                                       "org.freedesktop.Accounts.User",
+                                       "Changed",
+                                       g_variant_new ("()"),
                                        NULL);
     }
     else
@@ -2022,6 +2377,7 @@ accounts_name_acquired_cb (GDBusConnection *connection,
         "    <property name='XSession' type='s' access='read'/>"
         "    <property name='XKeyboardLayouts' type='as' access='read'/>"
         "    <property name='XHasMessages' type='b' access='read'/>"
+        "    <signal name='Changed' />"
         "  </interface>"
         "</node>";
     GError *error = NULL;
@@ -2285,6 +2641,7 @@ main (int argc, char **argv)
 
     /* Set up a skeleton file system */
     g_mkdir_with_parents (g_strdup_printf ("%s/etc", temp_dir), 0755);
+    g_mkdir_with_parents (g_strdup_printf ("%s/run", temp_dir), 0755);
     g_mkdir_with_parents (g_strdup_printf ("%s/usr/share", temp_dir), 0755);
     g_mkdir_with_parents (g_strdup_printf ("%s/usr/share/lightdm/sessions", temp_dir), 0755);
     g_mkdir_with_parents (g_strdup_printf ("%s/usr/share/lightdm/remote-sessions", temp_dir), 0755);
@@ -2299,6 +2656,8 @@ main (int argc, char **argv)
     if (!g_key_file_has_key (config, "test-runner-config", "have-config", NULL) || g_key_file_get_boolean (config, "test-runner-config", "have-config", NULL))
         if (system (g_strdup_printf ("cp %s %s/etc/lightdm/lightdm.conf", config_path, temp_dir)))
             perror ("Failed to copy configuration");
+    if (system (g_strdup_printf ("cp %s/tests/data/keys.conf %s/etc/lightdm/", SRCDIR, temp_dir)))
+        perror ("Failed to copy key configuration");
 
     additional_system_config = g_key_file_get_string (config, "test-runner-config", "additional-system-config", NULL);
     if (additional_system_config)
@@ -2548,6 +2907,8 @@ main (int argc, char **argv)
     /* Start D-Bus services */
     if (!g_key_file_get_boolean (config, "test-runner-config", "disable-upower", NULL))
         start_upower_daemon ();
+    if (!g_key_file_get_boolean (config, "test-runner-config", "disable-console-kit", NULL))
+        start_console_kit_daemon ();
     if (!g_key_file_get_boolean (config, "test-runner-config", "disable-login1", NULL))
         start_login1_daemon ();
     if (!g_key_file_get_boolean (config, "test-runner-config", "disable-accounts-service", NULL))