2 * Copyright (C) 2010-2011 Robert Ancell.
3 * Author: Robert Ancell <robert.ancell@canonical.com>
5 * This program is free software: you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option) any later
8 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
18 #include <glib/gi18n.h>
24 #include "configuration.h"
25 #include "display-manager.h"
26 #include "xdmcp-server.h"
27 #include "vnc-server.h"
28 #include "seat-xdmcp-session.h"
29 #include "seat-xvnc.h"
32 #include "session-child.h"
33 #include "shared-data-manager.h"
34 #include "user-list.h"
37 static gchar *config_path = NULL;
38 static GMainLoop *loop = NULL;
39 static GTimer *log_timer;
40 static int log_fd = -1;
41 static gboolean debug = FALSE;
43 static DisplayManager *display_manager = NULL;
44 static XDMCPServer *xdmcp_server = NULL;
45 static VNCServer *vnc_server = NULL;
46 static guint bus_id = 0;
47 static GDBusConnection *bus = NULL;
48 static guint reg_id = 0;
49 static GDBusNodeInfo *seat_info;
50 static GHashTable *seat_bus_entries = NULL;
51 static guint seat_index = 0;
52 static GDBusNodeInfo *session_info;
53 static GHashTable *session_bus_entries = NULL;
54 static guint session_index = 0;
55 static gint exit_code = EXIT_SUCCESS;
69 #define LIGHTDM_BUS_NAME "org.freedesktop.DisplayManager"
71 static gboolean update_login1_seat (Login1Seat *login1_seat);
74 log_cb (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer data)
79 switch (log_level & G_LOG_LEVEL_MASK)
81 case G_LOG_LEVEL_ERROR:
84 case G_LOG_LEVEL_CRITICAL:
87 case G_LOG_LEVEL_WARNING:
90 case G_LOG_LEVEL_MESSAGE:
93 case G_LOG_LEVEL_INFO:
96 case G_LOG_LEVEL_DEBUG:
104 text = g_strdup_printf ("[%+.2fs] %s %s\n", g_timer_elapsed (log_timer, NULL), prefix, message);
106 /* Log everything to a file */
110 n_written = write (log_fd, text, strlen (text));
112 ; /* Check result so compiler doesn't warn about it */
115 /* Log to stderr if requested */
117 g_printerr ("%s", text);
119 g_log_default_handler (log_domain, log_level, message, data);
127 gchar *log_dir, *path, *old_path;
129 log_timer = g_timer_new ();
132 log_dir = config_get_string (config_get_instance (), "LightDM", "log-directory");
133 path = g_build_filename (log_dir, "lightdm.log", NULL);
136 /* Move old file out of the way */
137 old_path = g_strdup_printf ("%s.old", path);
138 rename (path, old_path);
141 /* Create new file and log to it */
142 log_fd = open (path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
143 fcntl (log_fd, F_SETFD, FD_CLOEXEC);
144 g_log_set_default_handler (log_cb, NULL);
146 g_debug ("Logging to %s", path);
151 get_config_sections (const gchar *seat_name)
154 GList *config_sections = NULL;
156 config_sections = g_list_append (config_sections, g_strdup ("SeatDefaults"));
159 return config_sections;
161 groups = config_get_groups (config_get_instance ());
162 for (i = groups; *i; i++)
164 if (g_str_has_prefix (*i, "Seat:"))
166 const gchar *seat_name_glob = *i + strlen ("Seat:");
167 if (g_pattern_match_simple (seat_name_glob, seat_name))
168 config_sections = g_list_append (config_sections, g_strdup (*i));
173 return config_sections;
177 set_seat_properties (Seat *seat, const gchar *seat_name)
179 GList *sections, *link;
183 sections = get_config_sections (seat_name);
184 for (link = sections; link; link = link->next)
186 const gchar *section = link->data;
187 g_debug ("Loading properties from config section %s", section);
188 keys = config_get_keys (config_get_instance (), section);
189 for (i = 0; keys && keys[i]; i++)
191 gchar *value = config_get_string (config_get_instance (), section, keys[i]);
192 seat_set_property (seat, keys[i], value);
197 g_list_free_full (sections, g_free);
201 signal_cb (Process *process, int signum)
203 g_debug ("Caught %s signal, shutting down", g_strsignal (signum));
204 display_manager_stop (display_manager);
205 // FIXME: Stop XDMCP server
209 display_manager_stopped_cb (DisplayManager *display_manager)
211 g_debug ("Stopping daemon");
212 g_main_loop_quit (loop);
216 display_manager_seat_removed_cb (DisplayManager *display_manager, Seat *seat)
220 Seat *next_seat = NULL;
223 /* If we have fallback types registered for the seat, let's try them
225 types = seat_get_string_list_property (seat, "type");
226 next_types = g_string_new ("");
227 for (iter = types; iter && *iter; iter++)
230 continue; // skip first one, that is our current seat type
234 next_seat = seat_new (*iter, seat_get_name (seat));
235 g_string_assign (next_types, *iter);
239 // Build up list of types to try next time
240 g_string_append_c (next_types, ';');
241 g_string_append (next_types, *iter);
248 set_seat_properties (next_seat, seat_get_name (seat));
250 // We set this manually on default seat. Let's port it over if needed.
251 if (seat_get_boolean_property (seat, "exit-on-failure"))
252 seat_set_property (next_seat, "exit-on-failure", "true");
254 seat_set_property (next_seat, "type", next_types->str);
256 display_manager_add_seat (display_manager, next_seat);
257 g_object_unref (next_seat);
259 else if (seat_get_boolean_property (seat, "exit-on-failure"))
261 g_debug ("Required seat has stopped");
262 exit_code = EXIT_FAILURE;
263 display_manager_stop (display_manager);
266 g_string_free (next_types, TRUE);
272 GVariantBuilder builder;
276 g_variant_builder_init (&builder, G_VARIANT_TYPE ("ao"));
277 g_hash_table_iter_init (&iter, seat_bus_entries);
278 while (g_hash_table_iter_next (&iter, NULL, &value))
280 SeatBusEntry *entry = value;
281 g_variant_builder_add_value (&builder, g_variant_new_object_path (entry->path));
284 return g_variant_builder_end (&builder);
288 get_session_list (const gchar *seat_path)
290 GVariantBuilder builder;
294 g_variant_builder_init (&builder, G_VARIANT_TYPE ("ao"));
296 g_hash_table_iter_init (&iter, session_bus_entries);
297 while (g_hash_table_iter_next (&iter, NULL, &value))
299 SessionBusEntry *entry = value;
300 if (seat_path == NULL || strcmp (entry->seat_path, seat_path) == 0)
301 g_variant_builder_add_value (&builder, g_variant_new_object_path (entry->path));
304 return g_variant_builder_end (&builder);
308 handle_display_manager_get_property (GDBusConnection *connection,
310 const gchar *object_path,
311 const gchar *interface_name,
312 const gchar *property_name,
316 if (g_strcmp0 (property_name, "Seats") == 0)
317 return get_seat_list ();
318 else if (g_strcmp0 (property_name, "Sessions") == 0)
319 return get_session_list (NULL);
325 handle_display_manager_call (GDBusConnection *connection,
327 const gchar *object_path,
328 const gchar *interface_name,
329 const gchar *method_name,
330 GVariant *parameters,
331 GDBusMethodInvocation *invocation,
334 if (g_strcmp0 (method_name, "AddSeat") == 0)
335 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "AddSeat is deprecated");
336 else if (g_strcmp0 (method_name, "AddLocalXSeat") == 0)
341 if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(i)")))
343 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid arguments");
347 g_variant_get (parameters, "(i)", &display_number);
349 g_debug ("Adding local X seat :%d", display_number);
351 seat = seat_new ("xremote", "xremote0"); // FIXME: What to use for a name?
354 gchar *display_number_string;
356 set_seat_properties (seat, NULL);
357 display_number_string = g_strdup_printf ("%d", display_number);
358 seat_set_property (seat, "xserver-display-number", display_number_string);
359 g_free (display_number_string);
364 // FIXME: Need to make proper error
365 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Unable to create local X seat");
369 if (display_manager_add_seat (display_manager, seat))
373 entry = g_hash_table_lookup (seat_bus_entries, seat);
374 g_dbus_method_invocation_return_value (invocation, g_variant_new ("(o)", entry->path));
376 else// FIXME: Need to make proper error
377 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Failed to start seat");
378 g_object_unref (seat);
381 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Unknown method");
385 handle_seat_get_property (GDBusConnection *connection,
387 const gchar *object_path,
388 const gchar *interface_name,
389 const gchar *property_name,
393 Seat *seat = user_data;
395 if (g_strcmp0 (property_name, "CanSwitch") == 0)
396 return g_variant_new_boolean (seat_get_can_switch (seat));
397 if (g_strcmp0 (property_name, "HasGuestAccount") == 0)
398 return g_variant_new_boolean (seat_get_allow_guest (seat));
399 else if (g_strcmp0 (property_name, "Sessions") == 0)
403 entry = g_hash_table_lookup (seat_bus_entries, seat);
404 return get_session_list (entry->path);
411 handle_seat_call (GDBusConnection *connection,
413 const gchar *object_path,
414 const gchar *interface_name,
415 const gchar *method_name,
416 GVariant *parameters,
417 GDBusMethodInvocation *invocation,
420 Seat *seat = user_data;
422 if (g_strcmp0 (method_name, "SwitchToGreeter") == 0)
424 if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("()")))
425 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid arguments");
427 if (seat_switch_to_greeter (seat))
428 g_dbus_method_invocation_return_value (invocation, NULL);
429 else// FIXME: Need to make proper error
430 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Failed to switch to greeter");
432 else if (g_strcmp0 (method_name, "SwitchToUser") == 0)
434 const gchar *username, *session_name;
436 if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(ss)")))
437 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid arguments");
439 g_variant_get (parameters, "(&s&s)", &username, &session_name);
440 if (strcmp (session_name, "") == 0)
443 if (seat_switch_to_user (seat, username, session_name))
444 g_dbus_method_invocation_return_value (invocation, NULL);
445 else// FIXME: Need to make proper error
446 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Failed to switch to user");
448 else if (g_strcmp0 (method_name, "SwitchToGuest") == 0)
450 const gchar *session_name;
452 if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(s)")))
453 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid arguments");
455 g_variant_get (parameters, "(&s)", &session_name);
456 if (strcmp (session_name, "") == 0)
459 if (seat_switch_to_guest (seat, session_name))
460 g_dbus_method_invocation_return_value (invocation, NULL);
461 else// FIXME: Need to make proper error
462 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Failed to switch to guest");
464 else if (g_strcmp0 (method_name, "Lock") == 0)
466 if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("()")))
467 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid arguments");
469 /* FIXME: Should only allow locks if have a session on this seat */
470 if (seat_lock (seat, NULL))
471 g_dbus_method_invocation_return_value (invocation, NULL);
472 else// FIXME: Need to make proper error
473 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Failed to lock seat");
476 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Unknown method");
480 get_seat_for_session (Session *session)
484 for (seat_link = display_manager_get_seats (display_manager); seat_link; seat_link = seat_link->next)
486 Seat *seat = seat_link->data;
489 for (session_link = seat_get_sessions (seat); session_link; session_link = session_link->next)
491 Session *s = session_link->data;
502 handle_session_get_property (GDBusConnection *connection,
504 const gchar *object_path,
505 const gchar *interface_name,
506 const gchar *property_name,
510 Session *session = user_data;
511 SessionBusEntry *entry;
513 entry = g_hash_table_lookup (session_bus_entries, session);
514 if (g_strcmp0 (property_name, "Seat") == 0)
515 return g_variant_new_object_path (entry ? entry->seat_path : "");
516 else if (g_strcmp0 (property_name, "UserName") == 0)
517 return g_variant_new_string (session_get_username (session));
523 handle_session_call (GDBusConnection *connection,
525 const gchar *object_path,
526 const gchar *interface_name,
527 const gchar *method_name,
528 GVariant *parameters,
529 GDBusMethodInvocation *invocation,
532 Session *session = user_data;
534 if (g_strcmp0 (method_name, "Lock") == 0)
538 if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("()")))
539 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "Invalid arguments");
541 seat = get_seat_for_session (session);
542 /* FIXME: Should only allow locks if have a session on this seat */
543 seat_lock (seat, session_get_username (session));
544 g_dbus_method_invocation_return_value (invocation, NULL);
547 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Unknown method");
550 static SeatBusEntry *
551 seat_bus_entry_new (const gchar *path)
555 entry = g_malloc0 (sizeof (SeatBusEntry));
556 entry->path = g_strdup (path);
561 static SessionBusEntry *
562 session_bus_entry_new (const gchar *path, const gchar *seat_path)
564 SessionBusEntry *entry;
566 entry = g_malloc0 (sizeof (SessionBusEntry));
567 entry->path = g_strdup (path);
568 entry->seat_path = g_strdup (seat_path);
574 emit_object_value_changed (GDBusConnection *bus, const gchar *path, const gchar *interface_name, const gchar *property_name, GVariant *property_value)
576 GVariantBuilder builder;
577 GError *error = NULL;
579 g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
580 g_variant_builder_add (&builder, "{sv}", property_name, property_value);
582 if (!g_dbus_connection_emit_signal (bus,
585 "org.freedesktop.DBus.Properties",
587 g_variant_new ("(sa{sv}as)", interface_name, &builder, NULL),
589 g_warning ("Failed to emit PropertiesChanged signal: %s", error->message);
590 g_clear_error (&error);
594 emit_object_signal (GDBusConnection *bus, const gchar *path, const gchar *signal_name, const gchar *object_path)
596 GError *error = NULL;
598 if (!g_dbus_connection_emit_signal (bus,
601 "org.freedesktop.DisplayManager",
603 g_variant_new ("(o)", object_path),
605 g_warning ("Failed to emit %s signal on %s: %s", signal_name, path, error->message);
606 g_clear_error (&error);
610 seat_bus_entry_free (gpointer data)
612 SeatBusEntry *entry = data;
614 g_free (entry->path);
619 session_bus_entry_free (gpointer data)
621 SessionBusEntry *entry = data;
623 g_free (entry->path);
624 g_free (entry->seat_path);
629 running_user_session_cb (Seat *seat, Session *session)
631 static const GDBusInterfaceVTable session_vtable =
634 handle_session_get_property
636 SeatBusEntry *seat_entry;
637 SessionBusEntry *session_entry;
639 GError *error = NULL;
641 /* Set environment variables when session runs */
642 seat_entry = g_hash_table_lookup (seat_bus_entries, seat);
643 session_set_env (session, "XDG_SEAT_PATH", seat_entry->path);
644 path = g_strdup_printf ("/org/freedesktop/DisplayManager/Session%d", session_index);
646 session_set_env (session, "XDG_SESSION_PATH", path);
647 g_object_set_data_full (G_OBJECT (session), "XDG_SESSION_PATH", path, g_free);
649 seat_entry = g_hash_table_lookup (seat_bus_entries, seat);
650 session_entry = session_bus_entry_new (g_object_get_data (G_OBJECT (session), "XDG_SESSION_PATH"), seat_entry ? seat_entry->path : NULL);
651 g_hash_table_insert (session_bus_entries, g_object_ref (session), session_entry);
653 g_debug ("Registering session with bus path %s", session_entry->path);
655 session_entry->bus_id = g_dbus_connection_register_object (bus,
657 session_info->interfaces[0],
659 g_object_ref (session), g_object_unref,
661 if (session_entry->bus_id == 0)
662 g_warning ("Failed to register user session: %s", error->message);
663 g_clear_error (&error);
665 emit_object_value_changed (bus, "/org/freedesktop/DisplayManager", "org.freedesktop.DisplayManager", "Sessions", get_session_list (NULL));
666 emit_object_signal (bus, "/org/freedesktop/DisplayManager", "SessionAdded", session_entry->path);
668 emit_object_value_changed (bus, seat_entry->path, "org.freedesktop.DisplayManager.Seat", "Sessions", get_session_list (session_entry->seat_path));
669 emit_object_signal (bus, seat_entry->path, "SessionAdded", session_entry->path);
673 session_removed_cb (Seat *seat, Session *session)
675 SessionBusEntry *entry;
676 gchar *seat_path = NULL;
678 g_signal_handlers_disconnect_matched (session, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, seat);
680 entry = g_hash_table_lookup (session_bus_entries, session);
683 g_dbus_connection_unregister_object (bus, entry->bus_id);
684 emit_object_signal (bus, "/org/freedesktop/DisplayManager", "SessionRemoved", entry->path);
685 emit_object_signal (bus, entry->seat_path, "SessionRemoved", entry->path);
686 seat_path = g_strdup (entry->seat_path);
689 g_hash_table_remove (session_bus_entries, session);
693 emit_object_value_changed (bus, "/org/freedesktop/DisplayManager", "org.freedesktop.DisplayManager", "Sessions", get_session_list (NULL));
694 emit_object_value_changed (bus, seat_path, "org.freedesktop.DisplayManager.Seat", "Sessions", get_session_list (seat_path));
700 seat_added_cb (DisplayManager *display_manager, Seat *seat)
702 static const GDBusInterfaceVTable seat_vtable =
705 handle_seat_get_property
709 GError *error = NULL;
711 path = g_strdup_printf ("/org/freedesktop/DisplayManager/Seat%d", seat_index);
714 entry = seat_bus_entry_new (path);
716 g_hash_table_insert (seat_bus_entries, g_object_ref (seat), entry);
718 g_debug ("Registering seat with bus path %s", entry->path);
720 entry->bus_id = g_dbus_connection_register_object (bus,
722 seat_info->interfaces[0],
724 g_object_ref (seat), g_object_unref,
726 if (entry->bus_id == 0)
727 g_warning ("Failed to register seat: %s", error->message);
728 g_clear_error (&error);
730 emit_object_value_changed (bus, "/org/freedesktop/DisplayManager", "org.freedesktop.DisplayManager", "Seats", get_seat_list ());
731 emit_object_signal (bus, "/org/freedesktop/DisplayManager", "SeatAdded", entry->path);
733 g_signal_connect (seat, SEAT_SIGNAL_RUNNING_USER_SESSION, G_CALLBACK (running_user_session_cb), NULL);
734 g_signal_connect (seat, SEAT_SIGNAL_SESSION_REMOVED, G_CALLBACK (session_removed_cb), NULL);
738 seat_removed_cb (DisplayManager *display_manager, Seat *seat)
742 entry = g_hash_table_lookup (seat_bus_entries, seat);
745 g_dbus_connection_unregister_object (bus, entry->bus_id);
746 emit_object_signal (bus, "/org/freedesktop/DisplayManager", "SeatRemoved", entry->path);
749 g_hash_table_remove (seat_bus_entries, seat);
751 emit_object_value_changed (bus, "/org/freedesktop/DisplayManager", "org.freedesktop.DisplayManager", "Seats", get_seat_list ());
755 xdmcp_session_cb (XDMCPServer *server, XDMCPSession *session)
757 SeatXDMCPSession *seat;
760 seat = seat_xdmcp_session_new (session);
761 set_seat_properties (SEAT (seat), NULL);
762 result = display_manager_add_seat (display_manager, SEAT (seat));
763 g_object_unref (seat);
769 vnc_connection_cb (VNCServer *server, GSocket *connection)
773 seat = seat_xvnc_new (connection);
774 set_seat_properties (SEAT (seat), NULL);
775 display_manager_add_seat (display_manager, SEAT (seat));
776 g_object_unref (seat);
780 bus_acquired_cb (GDBusConnection *connection,
784 const gchar *display_manager_interface =
786 " <interface name='org.freedesktop.DisplayManager'>"
787 " <property name='Seats' type='ao' access='read'/>"
788 " <property name='Sessions' type='ao' access='read'/>"
789 " <method name='AddSeat'>"
790 " <arg name='type' direction='in' type='s'/>"
791 " <arg name='properties' direction='in' type='a(ss)'/>"
792 " <arg name='seat' direction='out' type='o'/>"
794 " <method name='AddLocalXSeat'>"
795 " <arg name='display-number' direction='in' type='i'/>"
796 " <arg name='seat' direction='out' type='o'/>"
798 " <signal name='SeatAdded'>"
799 " <arg name='seat' type='o'/>"
801 " <signal name='SeatRemoved'>"
802 " <arg name='seat' type='o'/>"
804 " <signal name='SessionAdded'>"
805 " <arg name='session' type='o'/>"
807 " <signal name='SessionRemoved'>"
808 " <arg name='session' type='o'/>"
812 static const GDBusInterfaceVTable display_manager_vtable =
814 handle_display_manager_call,
815 handle_display_manager_get_property
817 const gchar *seat_interface =
819 " <interface name='org.freedesktop.DisplayManager.Seat'>"
820 " <property name='CanSwitch' type='b' access='read'/>"
821 " <property name='HasGuestAccount' type='b' access='read'/>"
822 " <property name='Sessions' type='ao' access='read'/>"
823 " <method name='SwitchToGreeter'/>"
824 " <method name='SwitchToUser'>"
825 " <arg name='username' direction='in' type='s'/>"
826 " <arg name='session-name' direction='in' type='s'/>"
828 " <method name='SwitchToGuest'>"
829 " <arg name='session-name' direction='in' type='s'/>"
831 " <method name='Lock'/>"
832 " <signal name='SessionAdded'>"
833 " <arg name='session' type='o'/>"
835 " <signal name='SessionRemoved'>"
836 " <arg name='session' type='o'/>"
840 const gchar *session_interface =
842 " <interface name='org.freedesktop.DisplayManager.Session'>"
843 " <property name='Seat' type='o' access='read'/>"
844 " <property name='UserName' type='s' access='read'/>"
845 " <method name='Lock'/>"
848 GDBusNodeInfo *display_manager_info;
850 GError *error = NULL;
852 g_debug ("Acquired bus name %s", name);
856 display_manager_info = g_dbus_node_info_new_for_xml (display_manager_interface, NULL);
857 g_assert (display_manager_info != NULL);
858 seat_info = g_dbus_node_info_new_for_xml (seat_interface, NULL);
859 g_assert (seat_info != NULL);
860 session_info = g_dbus_node_info_new_for_xml (session_interface, NULL);
861 g_assert (session_info != NULL);
863 reg_id = g_dbus_connection_register_object (connection,
864 "/org/freedesktop/DisplayManager",
865 display_manager_info->interfaces[0],
866 &display_manager_vtable,
870 g_warning ("Failed to register display manager: %s", error->message);
871 g_clear_error (&error);
872 g_dbus_node_info_unref (display_manager_info);
874 seat_bus_entries = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, seat_bus_entry_free);
875 session_bus_entries = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, session_bus_entry_free);
877 g_signal_connect (display_manager, DISPLAY_MANAGER_SIGNAL_SEAT_ADDED, G_CALLBACK (seat_added_cb), NULL);
878 g_signal_connect (display_manager, DISPLAY_MANAGER_SIGNAL_SEAT_REMOVED, G_CALLBACK (seat_removed_cb), NULL);
879 for (link = display_manager_get_seats (display_manager); link; link = link->next)
880 seat_added_cb (display_manager, (Seat *) link->data);
882 display_manager_start (display_manager);
884 /* Start the XDMCP server */
885 if (config_get_boolean (config_get_instance (), "XDMCPServer", "enabled"))
887 gchar *key_name, *key = NULL;
889 xdmcp_server = xdmcp_server_new ();
890 if (config_has_key (config_get_instance (), "XDMCPServer", "port"))
893 port = config_get_integer (config_get_instance (), "XDMCPServer", "port");
895 xdmcp_server_set_port (xdmcp_server, port);
897 g_signal_connect (xdmcp_server, XDMCP_SERVER_SIGNAL_NEW_SESSION, G_CALLBACK (xdmcp_session_cb), NULL);
899 key_name = config_get_string (config_get_instance (), "XDMCPServer", "key");
905 GError *error = NULL;
907 path = g_build_filename (config_get_directory (config_get_instance ()), "keys.conf", NULL);
909 keys = g_key_file_new ();
910 result = g_key_file_load_from_file (keys, path, G_KEY_FILE_NONE, &error);
912 g_debug ("Error getting key %s", error->message);
913 g_clear_error (&error);
917 if (g_key_file_has_key (keys, "keyring", key_name, NULL))
918 key = g_key_file_get_string (keys, "keyring", key_name, NULL);
920 g_debug ("Key %s not defined", key_name);
923 g_key_file_free (keys);
926 xdmcp_server_set_key (xdmcp_server, key);
930 g_debug ("Starting XDMCP server on UDP/IP port %d", xdmcp_server_get_port (xdmcp_server));
931 xdmcp_server_start (xdmcp_server);
934 /* Start the VNC server */
935 if (config_get_boolean (config_get_instance (), "VNCServer", "enabled"))
939 path = g_find_program_in_path ("Xvnc");
942 vnc_server = vnc_server_new ();
943 if (config_has_key (config_get_instance (), "VNCServer", "port"))
946 port = config_get_integer (config_get_instance (), "VNCServer", "port");
948 vnc_server_set_port (vnc_server, port);
950 g_signal_connect (vnc_server, VNC_SERVER_SIGNAL_NEW_CONNECTION, G_CALLBACK (vnc_connection_cb), NULL);
952 g_debug ("Starting VNC server on TCP/IP port %d", vnc_server_get_port (vnc_server));
953 vnc_server_start (vnc_server);
958 g_warning ("Can't start VNC server, Xvnc is not in the path");
963 name_lost_cb (GDBusConnection *connection,
968 g_printerr ("Failed to use bus name " LIGHTDM_BUS_NAME ", do you have appropriate permissions?\n");
970 g_printerr ("Failed to get D-Bus connection\n");
976 add_login1_seat (Login1Seat *login1_seat)
978 const gchar *seat_name = login1_seat_get_id (login1_seat);
979 gchar **types = NULL, **type;
980 GList *config_sections = NULL, *link;
982 gboolean is_seat0, started = FALSE;
984 g_debug ("New seat added from logind: %s", seat_name);
985 is_seat0 = strcmp (seat_name, "seat0") == 0;
987 config_sections = get_config_sections (seat_name);
988 for (link = g_list_last (config_sections); link; link = link->prev)
990 gchar *config_section = link->data;
991 types = config_get_string_list (config_get_instance (), config_section, "type");
995 g_list_free_full (config_sections, g_free);
997 for (type = types; !seat && type && *type; type++)
998 seat = seat_new (*type, seat_name);
1003 set_seat_properties (seat, seat_name);
1005 if (!login1_seat_get_can_multi_session (login1_seat))
1007 g_debug ("Seat %s has property CanMultiSession=no", seat_name);
1008 /* XXX: uncomment this line after bug #1371250 is closed.
1009 seat_set_property (seat, "allow-user-switching", "false"); */
1013 seat_set_property (seat, "exit-on-failure", "true");
1016 g_debug ("Unable to create seat: %s", seat_name);
1020 started = display_manager_add_seat (display_manager, seat);
1022 g_debug ("Failed to start seat: %s", seat_name);
1025 g_object_unref (seat);
1031 remove_login1_seat (Login1Seat *login1_seat)
1035 seat = display_manager_get_seat (display_manager, login1_seat_get_id (login1_seat));
1041 seat_stopped_cb (Seat *seat, Login1Seat *login1_seat)
1043 update_login1_seat (login1_seat);
1044 g_signal_handlers_disconnect_matched (seat, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, login1_seat);
1048 update_login1_seat (Login1Seat *login1_seat)
1050 if (!config_get_boolean (config_get_instance (), "LightDM", "logind-check-graphical") ||
1051 login1_seat_get_can_graphical (login1_seat))
1055 /* Wait for existing seat to stop or ignore if we already have a valid seat */
1056 seat = display_manager_get_seat (display_manager, login1_seat_get_id (login1_seat));
1059 if (seat_get_is_stopping (seat))
1060 g_signal_connect (seat, SEAT_SIGNAL_STOPPED, G_CALLBACK (seat_stopped_cb), login1_seat);
1064 return add_login1_seat (login1_seat);
1068 remove_login1_seat (login1_seat);
1074 login1_can_graphical_changed_cb (Login1Seat *login1_seat)
1076 g_debug ("Seat %s changes graphical state to %s", login1_seat_get_id (login1_seat), login1_seat_get_can_graphical (login1_seat) ? "true" : "false");
1077 update_login1_seat (login1_seat);
1081 login1_active_session_changed_cb (Login1Seat *login1_seat, const gchar *login1_session_id)
1083 g_debug ("Seat %s changes active session to %s", login1_seat_get_id (login1_seat), login1_session_id);
1086 seat = display_manager_get_seat (display_manager, login1_seat_get_id (login1_seat));
1090 Session *active_session;
1091 active_session = seat_get_expected_active_session (seat);
1093 if (g_strcmp0 (login1_session_id, session_get_login1_session_id (active_session)) == 0)
1095 // Session is already active
1096 g_debug ("Session %s is already active", login1_session_id);
1100 active_session = seat_find_session_by_login1_id (seat, login1_session_id);
1101 if (active_session != NULL)
1103 g_debug ("Activating session %s", login1_session_id);
1104 seat_set_externally_activated_session (seat, active_session);
1112 login1_add_seat (Login1Seat *login1_seat)
1114 if (config_get_boolean (config_get_instance (), "LightDM", "logind-check-graphical"))
1115 g_signal_connect (login1_seat, "can-graphical-changed", G_CALLBACK (login1_can_graphical_changed_cb), NULL);
1117 g_signal_connect (login1_seat, LOGIN1_SIGNAL_ACTIVE_SESION_CHANGED, G_CALLBACK (login1_active_session_changed_cb), NULL);
1119 return update_login1_seat (login1_seat);
1123 login1_service_seat_added_cb (Login1Service *service, Login1Seat *login1_seat)
1125 if (login1_seat_get_can_graphical (login1_seat))
1126 g_debug ("Seat %s added from logind", login1_seat_get_id (login1_seat));
1128 g_debug ("Seat %s added from logind without graphical output", login1_seat_get_id (login1_seat));
1130 login1_add_seat (login1_seat);
1134 login1_service_seat_removed_cb (Login1Service *service, Login1Seat *login1_seat)
1136 g_debug ("Seat %s removed from logind", login1_seat_get_id (login1_seat));
1137 g_signal_handlers_disconnect_matched (login1_seat, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, login1_can_graphical_changed_cb, NULL);
1138 g_signal_handlers_disconnect_matched (login1_seat, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, login1_active_session_changed_cb, NULL);
1139 remove_login1_seat (login1_seat);
1143 main (int argc, char **argv)
1146 GOptionContext *option_context;
1149 gboolean test_mode = FALSE;
1150 gchar *pid_path = "/var/run/lightdm.pid";
1151 gchar *log_dir = NULL;
1152 gchar *run_dir = NULL;
1153 gchar *cache_dir = NULL;
1154 gchar *default_log_dir = g_strdup (LOG_DIR);
1155 gchar *default_run_dir = g_strdup (RUN_DIR);
1156 gchar *default_cache_dir = g_strdup (CACHE_DIR);
1157 gboolean show_config = FALSE, show_version = FALSE;
1158 GList *link, *messages = NULL;
1159 GOptionEntry options[] =
1161 { "config", 'c', 0, G_OPTION_ARG_STRING, &config_path,
1162 /* Help string for command line --config flag */
1163 N_("Use configuration file"), "FILE" },
1164 { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug,
1165 /* Help string for command line --debug flag */
1166 N_("Print debugging messages"), NULL },
1167 { "test-mode", 0, 0, G_OPTION_ARG_NONE, &test_mode,
1168 /* Help string for command line --test-mode flag */
1169 N_("Run as unprivileged user, skipping things that require root access"), NULL },
1170 { "pid-file", 0, 0, G_OPTION_ARG_STRING, &pid_path,
1171 /* Help string for command line --pid-file flag */
1172 N_("File to write PID into"), "FILE" },
1173 { "log-dir", 0, 0, G_OPTION_ARG_STRING, &log_dir,
1174 /* Help string for command line --log-dir flag */
1175 N_("Directory to write logs to"), "DIRECTORY" },
1176 { "run-dir", 0, 0, G_OPTION_ARG_STRING, &run_dir,
1177 /* Help string for command line --run-dir flag */
1178 N_("Directory to store running state"), "DIRECTORY" },
1179 { "cache-dir", 0, 0, G_OPTION_ARG_STRING, &cache_dir,
1180 /* Help string for command line --cache-dir flag */
1181 N_("Directory to cache information"), "DIRECTORY" },
1182 { "show-config", 0, 0, G_OPTION_ARG_NONE, &show_config,
1183 /* Help string for command line --show-config flag */
1184 N_("Show combined configuration"), NULL },
1185 { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version,
1186 /* Help string for command line --version flag */
1187 N_("Show release version"), NULL },
1190 GError *error = NULL;
1192 /* When lightdm starts sessions it needs to run itself in a new mode */
1193 if (argc >= 2 && strcmp (argv[1], "--session-child") == 0)
1194 return session_child_run (argc, argv);
1196 #if !defined(GLIB_VERSION_2_36)
1199 loop = g_main_loop_new (NULL, FALSE);
1201 messages = g_list_append (messages, g_strdup_printf ("Starting Light Display Manager %s, UID=%i PID=%i", VERSION, getuid (), getpid ()));
1203 g_signal_connect (process_get_current (), PROCESS_SIGNAL_GOT_SIGNAL, G_CALLBACK (signal_cb), NULL);
1205 option_context = g_option_context_new (/* Arguments and description for --help test */
1206 _("- Display Manager"));
1207 g_option_context_add_main_entries (option_context, options, GETTEXT_PACKAGE);
1208 result = g_option_context_parse (option_context, &argc, &argv, &error);
1210 g_printerr ("%s\n", error->message);
1211 g_clear_error (&error);
1212 g_option_context_free (option_context);
1215 g_printerr (/* Text printed out when an unknown command-line argument provided */
1216 _("Run '%s --help' to see a full list of available command line options."), argv[0]);
1218 return EXIT_FAILURE;
1221 /* Show combined configuration if user requested it */
1224 GList *sources, *link;
1225 gchar **groups, *last_source, *empty_source;
1226 GHashTable *source_ids;
1229 if (!config_load_from_standard_locations (config_get_instance (), config_path, NULL))
1230 return EXIT_FAILURE;
1232 /* Number sources */
1233 sources = config_get_sources (config_get_instance ());
1234 source_ids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
1236 for (i = 0, link = sources; link; i++, link = link->next)
1242 id = g_strdup_printf ("%c", 'A' + i);
1244 id = g_strdup_printf ("%d", i);
1245 g_hash_table_insert (source_ids, g_strdup (path), id);
1248 empty_source = g_strdup (last_source);
1249 for (i = 0; empty_source[i] != '\0'; i++)
1250 empty_source[i] = ' ';
1252 /* Print out keys */
1253 groups = config_get_groups (config_get_instance ());
1254 for (i = 0; groups[i]; i++)
1261 g_printerr ("%s [%s]\n", empty_source, groups[i]);
1263 keys = config_get_keys (config_get_instance (), groups[i]);
1264 for (j = 0; keys && keys[j]; j++)
1266 const gchar *source, *id;
1269 source = config_get_source (config_get_instance (), groups[i], keys[j]);
1270 id = source ? g_hash_table_lookup (source_ids, source) : empty_source;
1271 value = config_get_string (config_get_instance (), groups[i], keys[j]);
1272 g_printerr ("%s %s=%s\n", id, keys[j], value);
1278 g_strfreev (groups);
1280 /* Show mapping from source number to path */
1282 g_printerr ("Sources:\n");
1283 for (link = sources; link; link = link->next)
1285 const gchar *path = link->data;
1286 const gchar *source;
1288 source = g_hash_table_lookup (source_ids, path);
1289 g_printerr ("%s %s\n", source, path);
1292 g_hash_table_destroy (source_ids);
1294 return EXIT_SUCCESS;
1299 /* NOTE: Is not translated so can be easily parsed */
1300 g_printerr ("lightdm %s\n", VERSION);
1301 return EXIT_SUCCESS;
1304 if (!test_mode && getuid () != 0)
1306 g_printerr ("Only root can run Light Display Manager. To run as a regular user for testing run with the --test-mode flag.\n");
1307 return EXIT_FAILURE;
1310 /* If running inside an X server use Xephyr for display */
1311 if (getenv ("DISPLAY") && getuid () != 0)
1313 gchar *x_server_path;
1315 x_server_path = g_find_program_in_path ("Xephyr");
1318 g_printerr ("Running inside an X server requires Xephyr to be installed but it cannot be found. Please install it or update your PATH environment variable.\n");
1319 return EXIT_FAILURE;
1321 g_free (x_server_path);
1324 /* Make sure the system binary directory (where the greeters are installed) is in the path */
1327 const gchar *path = g_getenv ("PATH");
1331 new_path = g_strdup_printf ("%s:%s", path, SBIN_DIR);
1333 new_path = g_strdup (SBIN_DIR);
1334 g_setenv ("PATH", new_path, TRUE);
1338 /* Write PID file */
1339 pid_file = fopen (pid_path, "w");
1342 fprintf (pid_file, "%d\n", getpid ());
1346 /* If not running as root write output to directories we control */
1349 g_free (default_log_dir);
1350 default_log_dir = g_build_filename (g_get_user_cache_dir (), "lightdm", "log", NULL);
1351 g_free (default_run_dir);
1352 default_run_dir = g_build_filename (g_get_user_cache_dir (), "lightdm", "run", NULL);
1353 g_free (default_cache_dir);
1354 default_cache_dir = g_build_filename (g_get_user_cache_dir (), "lightdm", "cache", NULL);
1357 /* Load config file(s) */
1358 if (!config_load_from_standard_locations (config_get_instance (), config_path, &messages))
1359 exit (EXIT_FAILURE);
1360 g_free (config_path);
1362 /* Set default values */
1363 if (!config_has_key (config_get_instance (), "LightDM", "start-default-seat"))
1364 config_set_boolean (config_get_instance (), "LightDM", "start-default-seat", TRUE);
1365 if (!config_has_key (config_get_instance (), "LightDM", "minimum-vt"))
1366 config_set_integer (config_get_instance (), "LightDM", "minimum-vt", 7);
1367 if (!config_has_key (config_get_instance (), "LightDM", "guest-account-script"))
1368 config_set_string (config_get_instance (), "LightDM", "guest-account-script", "guest-account");
1369 if (!config_has_key (config_get_instance (), "LightDM", "greeter-user"))
1370 config_set_string (config_get_instance (), "LightDM", "greeter-user", GREETER_USER);
1371 if (!config_has_key (config_get_instance (), "LightDM", "lock-memory"))
1372 config_set_boolean (config_get_instance (), "LightDM", "lock-memory", TRUE);
1373 if (!config_has_key (config_get_instance (), "SeatDefaults", "type"))
1374 config_set_string (config_get_instance (), "SeatDefaults", "type", "xlocal");
1375 if (!config_has_key (config_get_instance (), "SeatDefaults", "pam-service"))
1376 config_set_string (config_get_instance (), "SeatDefaults", "pam-service", "lightdm");
1377 if (!config_has_key (config_get_instance (), "SeatDefaults", "pam-autologin-service"))
1378 config_set_string (config_get_instance (), "SeatDefaults", "pam-autologin-service", "lightdm-autologin");
1379 if (!config_has_key (config_get_instance (), "SeatDefaults", "pam-greeter-service"))
1380 config_set_string (config_get_instance (), "SeatDefaults", "pam-greeter-service", "lightdm-greeter");
1381 if (!config_has_key (config_get_instance (), "SeatDefaults", "xserver-command"))
1382 config_set_string (config_get_instance (), "SeatDefaults", "xserver-command", "X");
1383 if (!config_has_key (config_get_instance (), "SeatDefaults", "xserver-share"))
1384 config_set_boolean (config_get_instance (), "SeatDefaults", "xserver-share", TRUE);
1385 if (!config_has_key (config_get_instance (), "SeatDefaults", "unity-compositor-command"))
1386 config_set_string (config_get_instance (), "SeatDefaults", "unity-compositor-command", "unity-system-compositor");
1387 if (!config_has_key (config_get_instance (), "SeatDefaults", "start-session"))
1388 config_set_boolean (config_get_instance (), "SeatDefaults", "start-session", TRUE);
1389 if (!config_has_key (config_get_instance (), "SeatDefaults", "allow-user-switching"))
1390 config_set_boolean (config_get_instance (), "SeatDefaults", "allow-user-switching", TRUE);
1391 if (!config_has_key (config_get_instance (), "SeatDefaults", "allow-guest"))
1392 config_set_boolean (config_get_instance (), "SeatDefaults", "allow-guest", TRUE);
1393 if (!config_has_key (config_get_instance (), "SeatDefaults", "greeter-allow-guest"))
1394 config_set_boolean (config_get_instance (), "SeatDefaults", "greeter-allow-guest", TRUE);
1395 if (!config_has_key (config_get_instance (), "SeatDefaults", "greeter-show-remote-login"))
1396 config_set_boolean (config_get_instance (), "SeatDefaults", "greeter-show-remote-login", TRUE);
1397 if (!config_has_key (config_get_instance (), "SeatDefaults", "greeter-session"))
1398 config_set_string (config_get_instance (), "SeatDefaults", "greeter-session", GREETER_SESSION);
1399 if (!config_has_key (config_get_instance (), "SeatDefaults", "user-session"))
1400 config_set_string (config_get_instance (), "SeatDefaults", "user-session", USER_SESSION);
1401 if (!config_has_key (config_get_instance (), "SeatDefaults", "session-wrapper"))
1402 config_set_string (config_get_instance (), "SeatDefaults", "session-wrapper", "lightdm-session");
1403 if (!config_has_key (config_get_instance (), "LightDM", "log-directory"))
1404 config_set_string (config_get_instance (), "LightDM", "log-directory", default_log_dir);
1405 g_free (default_log_dir);
1406 if (!config_has_key (config_get_instance (), "LightDM", "run-directory"))
1407 config_set_string (config_get_instance (), "LightDM", "run-directory", default_run_dir);
1408 g_free (default_run_dir);
1409 if (!config_has_key (config_get_instance (), "LightDM", "cache-directory"))
1410 config_set_string (config_get_instance (), "LightDM", "cache-directory", default_cache_dir);
1411 g_free (default_cache_dir);
1412 if (!config_has_key (config_get_instance (), "LightDM", "sessions-directory"))
1413 config_set_string (config_get_instance (), "LightDM", "sessions-directory", SESSIONS_DIR);
1414 if (!config_has_key (config_get_instance (), "LightDM", "remote-sessions-directory"))
1415 config_set_string (config_get_instance (), "LightDM", "remote-sessions-directory", REMOTE_SESSIONS_DIR);
1416 if (!config_has_key (config_get_instance (), "LightDM", "greeters-directory"))
1417 config_set_string (config_get_instance (), "LightDM", "greeters-directory", GREETERS_DIR);
1419 /* Override defaults */
1421 config_set_string (config_get_instance (), "LightDM", "log-directory", log_dir);
1424 config_set_string (config_get_instance (), "LightDM", "run-directory", run_dir);
1427 config_set_string (config_get_instance (), "LightDM", "cache-directory", cache_dir);
1430 /* Create run and cache directories */
1431 dir = config_get_string (config_get_instance (), "LightDM", "log-directory");
1432 if (g_mkdir_with_parents (dir, S_IRWXU | S_IXGRP | S_IXOTH) < 0)
1433 g_warning ("Failed to make log directory %s: %s", dir, strerror (errno));
1435 dir = config_get_string (config_get_instance (), "LightDM", "run-directory");
1436 if (g_mkdir_with_parents (dir, S_IRWXU | S_IXGRP | S_IXOTH) < 0)
1437 g_warning ("Failed to make run directory %s: %s", dir, strerror (errno));
1439 dir = config_get_string (config_get_instance (), "LightDM", "cache-directory");
1440 if (g_mkdir_with_parents (dir, S_IRWXU | S_IXGRP | S_IXOTH) < 0)
1441 g_warning ("Failed to make cache directory %s: %s", dir, strerror (errno));
1446 /* Show queued messages once logging is complete */
1447 for (link = messages; link; link = link->next)
1448 g_debug ("%s", (gchar *)link->data);
1449 g_list_free_full (messages, g_free);
1451 g_debug ("Using D-Bus name %s", LIGHTDM_BUS_NAME);
1452 bus_id = g_bus_own_name (getuid () == 0 ? G_BUS_TYPE_SYSTEM : G_BUS_TYPE_SESSION,
1454 G_BUS_NAME_OWNER_FLAGS_NONE,
1462 g_debug ("Running in user mode");
1463 if (getenv ("DISPLAY"))
1464 g_debug ("Using Xephyr for X servers");
1466 display_manager = display_manager_new ();
1467 g_signal_connect (display_manager, DISPLAY_MANAGER_SIGNAL_STOPPED, G_CALLBACK (display_manager_stopped_cb), NULL);
1468 g_signal_connect (display_manager, DISPLAY_MANAGER_SIGNAL_SEAT_REMOVED, G_CALLBACK (display_manager_seat_removed_cb), NULL);
1470 shared_data_manager_start (shared_data_manager_get_instance ());
1472 /* Connect to logind */
1473 if (login1_service_connect (login1_service_get_instance ()))
1475 /* Load dynamic seats from logind */
1476 g_debug ("Monitoring logind for seats");
1478 if (config_get_boolean (config_get_instance (), "LightDM", "start-default-seat"))
1480 g_signal_connect (login1_service_get_instance (), LOGIN1_SERVICE_SIGNAL_SEAT_ADDED, G_CALLBACK (login1_service_seat_added_cb), NULL);
1481 g_signal_connect (login1_service_get_instance (), LOGIN1_SERVICE_SIGNAL_SEAT_REMOVED, G_CALLBACK (login1_service_seat_removed_cb), NULL);
1483 for (link = login1_service_get_seats (login1_service_get_instance ()); link; link = link->next)
1485 Login1Seat *login1_seat = link->data;
1486 if (!login1_add_seat (login1_seat))
1487 return EXIT_FAILURE;
1493 if (config_get_boolean (config_get_instance (), "LightDM", "start-default-seat"))
1499 g_debug ("Adding default seat");
1501 types = config_get_string_list (config_get_instance (), "SeatDefaults", "type");
1502 for (type = types; type && *type; type++)
1504 seat = seat_new (*type, "seat0");
1511 set_seat_properties (seat, NULL);
1512 seat_set_property (seat, "exit-on-failure", "true");
1513 if (!display_manager_add_seat (display_manager, seat))
1514 return EXIT_FAILURE;
1515 g_object_unref (seat);
1519 g_warning ("Failed to create default seat");
1520 return EXIT_FAILURE;
1525 g_main_loop_run (loop);
1527 /* Clean up shared data manager */
1528 shared_data_manager_cleanup ();
1530 /* Clean up user list */
1531 common_user_list_cleanup ();
1533 /* Clean up display manager */
1534 g_object_unref (display_manager);
1535 display_manager = NULL;
1537 /* Remove D-Bus interface */
1538 g_dbus_connection_unregister_object (bus, reg_id);
1539 g_bus_unown_name (bus_id);
1540 if (seat_bus_entries)
1541 g_hash_table_unref (seat_bus_entries);
1542 if (session_bus_entries)
1543 g_hash_table_unref (session_bus_entries);
1545 g_debug ("Exiting with return value %d", exit_code);