diff options
author | Jesús González <jgonzalez@gdr-sistemas.com> | 2015-04-28 02:12:04 +0200 |
---|---|---|
committer | Jesús González <jgonzalez@gdr-sistemas.com> | 2015-04-28 02:12:04 +0200 |
commit | 1afa5d0f606763524225dea9c5d0a953f808adf7 (patch) | |
tree | 5fccc0574da33903e35662613764bf82ed01b2ca /src | |
parent | 204e587976786ba3c5b2ee5c3b32d897246abd38 (diff) | |
parent | 2f5a6e856f88fedd27dc2defeecf3f8300b9be4e (diff) | |
download | lightdm-1afa5d0f606763524225dea9c5d0a953f808adf7.tar.gz |
Merged changes from parent branch.
Diffstat (limited to 'src')
-rw-r--r-- | src/greeter.c | 27 | ||||
-rw-r--r-- | src/lightdm.c | 76 | ||||
-rw-r--r-- | src/seat.c | 8 | ||||
-rw-r--r-- | src/session-child.c | 2 | ||||
-rw-r--r-- | src/session.c | 2 | ||||
-rw-r--r-- | src/unity-system-compositor.c | 3 |
6 files changed, 68 insertions, 50 deletions
diff --git a/src/greeter.c b/src/greeter.c index e1d47f86..b9f4f55a 100644 --- a/src/greeter.c +++ b/src/greeter.c @@ -76,6 +76,8 @@ struct GreeterPrivate gboolean guest_account_authenticated; /* Communication channels to communicate with */ + int to_greeter_input; + int from_greeter_output; GIOChannel *to_greeter_channel; GIOChannel *from_greeter_channel; guint from_greeter_watch; @@ -954,6 +956,7 @@ greeter_start (Session *session) { Greeter *greeter = GREETER (session); int to_greeter_pipe[2], from_greeter_pipe[2]; + int to_greeter_output, from_greeter_input; gboolean result = FALSE; gchar *value; GError *error = NULL; @@ -964,12 +967,16 @@ greeter_start (Session *session) g_warning ("Failed to create pipes: %s", strerror (errno)); return FALSE; } - greeter->priv->to_greeter_channel = g_io_channel_unix_new (to_greeter_pipe[1]); + to_greeter_output = to_greeter_pipe[0]; + greeter->priv->to_greeter_input = to_greeter_pipe[1]; + greeter->priv->to_greeter_channel = g_io_channel_unix_new (greeter->priv->to_greeter_input); g_io_channel_set_encoding (greeter->priv->to_greeter_channel, NULL, &error); if (error) g_warning ("Failed to set encoding on to greeter channel to binary: %s\n", error->message); g_clear_error (&error); - greeter->priv->from_greeter_channel = g_io_channel_unix_new (from_greeter_pipe[0]); + greeter->priv->from_greeter_output = from_greeter_pipe[0]; + from_greeter_input = from_greeter_pipe[1]; + greeter->priv->from_greeter_channel = g_io_channel_unix_new (greeter->priv->from_greeter_output); g_io_channel_set_encoding (greeter->priv->from_greeter_channel, NULL, &error); if (error) g_warning ("Failed to set encoding on from greeter channel to binary: %s\n", error->message); @@ -978,22 +985,22 @@ greeter_start (Session *session) greeter->priv->from_greeter_watch = g_io_add_watch (greeter->priv->from_greeter_channel, G_IO_IN | G_IO_HUP, read_cb, greeter); /* Let the greeter session know how to communicate with the daemon */ - value = g_strdup_printf ("%d", from_greeter_pipe[1]); + value = g_strdup_printf ("%d", from_greeter_input); session_set_env (SESSION (greeter), "LIGHTDM_TO_SERVER_FD", value); g_free (value); - value = g_strdup_printf ("%d", to_greeter_pipe[0]); + value = g_strdup_printf ("%d", to_greeter_output); session_set_env (SESSION (greeter), "LIGHTDM_FROM_SERVER_FD", value); g_free (value); /* Don't allow the daemon end of the pipes to be accessed in child processes */ - fcntl (to_greeter_pipe[1], F_SETFD, FD_CLOEXEC); - fcntl (from_greeter_pipe[0], F_SETFD, FD_CLOEXEC); + fcntl (greeter->priv->to_greeter_input, F_SETFD, FD_CLOEXEC); + fcntl (greeter->priv->from_greeter_output, F_SETFD, FD_CLOEXEC); result = SESSION_CLASS (greeter_parent_class)->start (session); /* Close the session ends of the pipe */ - close (to_greeter_pipe[0]); - close (from_greeter_pipe[1]); + close (to_greeter_output); + close (from_greeter_input); return result; } @@ -1029,6 +1036,8 @@ greeter_init (Greeter *greeter) greeter->priv->read_buffer = secure_malloc (greeter, HEADER_SIZE); greeter->priv->hints = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); greeter->priv->use_secure_memory = config_get_boolean (config_get_instance (), "LightDM", "lock-memory"); + greeter->priv->to_greeter_input = -1; + greeter->priv->from_greeter_output = -1; } static void @@ -1049,6 +1058,8 @@ greeter_finalize (GObject *object) g_signal_handlers_disconnect_matched (self->priv->authentication_session, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, self); g_object_unref (self->priv->authentication_session); } + close (self->priv->to_greeter_input); + close (self->priv->from_greeter_output); if (self->priv->to_greeter_channel) g_io_channel_unref (self->priv->to_greeter_channel); if (self->priv->from_greeter_channel) diff --git a/src/lightdm.c b/src/lightdm.c index 8c52d1e1..61ae3f2c 100644 --- a/src/lightdm.c +++ b/src/lightdm.c @@ -153,18 +153,16 @@ get_config_sections (const gchar *seat_name) gchar **groups, **i; GList *config_sections = NULL; + /* Keep this so it won't break existing config files using old [SeatDefaults] */ config_sections = g_list_append (config_sections, g_strdup ("SeatDefaults")); - if (!seat_name) - return config_sections; - groups = config_get_groups (config_get_instance ()); for (i = groups; *i; i++) { if (g_str_has_prefix (*i, "Seat:")) { const gchar *seat_name_glob = *i + strlen ("Seat:"); - if (g_pattern_match_simple (seat_name_glob, seat_name)) + if (g_pattern_match_simple (seat_name_glob, seat_name ? seat_name : "")) config_sections = g_list_append (config_sections, g_strdup (*i)); } } @@ -184,8 +182,13 @@ set_seat_properties (Seat *seat, const gchar *seat_name) for (link = sections; link; link = link->next) { const gchar *section = link->data; - g_debug ("Loading properties from config section %s", section); keys = config_get_keys (config_get_instance (), section); + + /* Keep this until [SeatDefaults] support is definitely removed */ + if (strcmp (section, "SeatDefaults") == 0 && keys) + l_warning (seat, "[SeatDefaults] is deprecated and won't be supported in the future. Use [Seat:*] instead!"); + + l_debug (seat, "Loading properties from config section %s", section); for (i = 0; keys && keys[i]; i++) { gchar *value = config_get_string (config_get_instance (), section, keys[i]); @@ -646,7 +649,6 @@ running_user_session_cb (Seat *seat, Session *session) session_set_env (session, "XDG_SESSION_PATH", path); g_object_set_data_full (G_OBJECT (session), "XDG_SESSION_PATH", path, g_free); - seat_entry = g_hash_table_lookup (seat_bus_entries, seat); session_entry = session_bus_entry_new (g_object_get_data (G_OBJECT (session), "XDG_SESSION_PATH"), seat_entry ? seat_entry->path : NULL); g_hash_table_insert (session_bus_entries, g_object_ref (session), session_entry); @@ -1370,36 +1372,36 @@ main (int argc, char **argv) config_set_string (config_get_instance (), "LightDM", "greeter-user", GREETER_USER); if (!config_has_key (config_get_instance (), "LightDM", "lock-memory")) config_set_boolean (config_get_instance (), "LightDM", "lock-memory", TRUE); - if (!config_has_key (config_get_instance (), "SeatDefaults", "type")) - config_set_string (config_get_instance (), "SeatDefaults", "type", "xlocal"); - if (!config_has_key (config_get_instance (), "SeatDefaults", "pam-service")) - config_set_string (config_get_instance (), "SeatDefaults", "pam-service", "lightdm"); - if (!config_has_key (config_get_instance (), "SeatDefaults", "pam-autologin-service")) - config_set_string (config_get_instance (), "SeatDefaults", "pam-autologin-service", "lightdm-autologin"); - if (!config_has_key (config_get_instance (), "SeatDefaults", "pam-greeter-service")) - config_set_string (config_get_instance (), "SeatDefaults", "pam-greeter-service", "lightdm-greeter"); - if (!config_has_key (config_get_instance (), "SeatDefaults", "xserver-command")) - config_set_string (config_get_instance (), "SeatDefaults", "xserver-command", "X"); - if (!config_has_key (config_get_instance (), "SeatDefaults", "xserver-share")) - config_set_boolean (config_get_instance (), "SeatDefaults", "xserver-share", TRUE); - if (!config_has_key (config_get_instance (), "SeatDefaults", "unity-compositor-command")) - config_set_string (config_get_instance (), "SeatDefaults", "unity-compositor-command", "unity-system-compositor"); - if (!config_has_key (config_get_instance (), "SeatDefaults", "start-session")) - config_set_boolean (config_get_instance (), "SeatDefaults", "start-session", TRUE); - if (!config_has_key (config_get_instance (), "SeatDefaults", "allow-user-switching")) - config_set_boolean (config_get_instance (), "SeatDefaults", "allow-user-switching", TRUE); - if (!config_has_key (config_get_instance (), "SeatDefaults", "allow-guest")) - config_set_boolean (config_get_instance (), "SeatDefaults", "allow-guest", TRUE); - if (!config_has_key (config_get_instance (), "SeatDefaults", "greeter-allow-guest")) - config_set_boolean (config_get_instance (), "SeatDefaults", "greeter-allow-guest", TRUE); - if (!config_has_key (config_get_instance (), "SeatDefaults", "greeter-show-remote-login")) - config_set_boolean (config_get_instance (), "SeatDefaults", "greeter-show-remote-login", TRUE); - if (!config_has_key (config_get_instance (), "SeatDefaults", "greeter-session")) - config_set_string (config_get_instance (), "SeatDefaults", "greeter-session", GREETER_SESSION); - if (!config_has_key (config_get_instance (), "SeatDefaults", "user-session")) - config_set_string (config_get_instance (), "SeatDefaults", "user-session", USER_SESSION); - if (!config_has_key (config_get_instance (), "SeatDefaults", "session-wrapper")) - config_set_string (config_get_instance (), "SeatDefaults", "session-wrapper", "lightdm-session"); + if (!config_has_key (config_get_instance (), "Seat:*", "type")) + config_set_string (config_get_instance (), "Seat:*", "type", "xlocal"); + if (!config_has_key (config_get_instance (), "Seat:*", "pam-service")) + config_set_string (config_get_instance (), "Seat:*", "pam-service", "lightdm"); + if (!config_has_key (config_get_instance (), "Seat:*", "pam-autologin-service")) + config_set_string (config_get_instance (), "Seat:*", "pam-autologin-service", "lightdm-autologin"); + if (!config_has_key (config_get_instance (), "Seat:*", "pam-greeter-service")) + config_set_string (config_get_instance (), "Seat:*", "pam-greeter-service", "lightdm-greeter"); + if (!config_has_key (config_get_instance (), "Seat:*", "xserver-command")) + config_set_string (config_get_instance (), "Seat:*", "xserver-command", "X"); + if (!config_has_key (config_get_instance (), "Seat:*", "xserver-share")) + config_set_boolean (config_get_instance (), "Seat:*", "xserver-share", TRUE); + if (!config_has_key (config_get_instance (), "Seat:*", "unity-compositor-command")) + config_set_string (config_get_instance (), "Seat:*", "unity-compositor-command", "unity-system-compositor"); + if (!config_has_key (config_get_instance (), "Seat:*", "start-session")) + config_set_boolean (config_get_instance (), "Seat:*", "start-session", TRUE); + if (!config_has_key (config_get_instance (), "Seat:*", "allow-user-switching")) + config_set_boolean (config_get_instance (), "Seat:*", "allow-user-switching", TRUE); + if (!config_has_key (config_get_instance (), "Seat:*", "allow-guest")) + config_set_boolean (config_get_instance (), "Seat:*", "allow-guest", TRUE); + if (!config_has_key (config_get_instance (), "Seat:*", "greeter-allow-guest")) + config_set_boolean (config_get_instance (), "Seat:*", "greeter-allow-guest", TRUE); + if (!config_has_key (config_get_instance (), "Seat:*", "greeter-show-remote-login")) + config_set_boolean (config_get_instance (), "Seat:*", "greeter-show-remote-login", TRUE); + if (!config_has_key (config_get_instance (), "Seat:*", "greeter-session")) + config_set_string (config_get_instance (), "Seat:*", "greeter-session", GREETER_SESSION); + if (!config_has_key (config_get_instance (), "Seat:*", "user-session")) + config_set_string (config_get_instance (), "Seat:*", "user-session", USER_SESSION); + if (!config_has_key (config_get_instance (), "Seat:*", "session-wrapper")) + config_set_string (config_get_instance (), "Seat:*", "session-wrapper", "lightdm-session"); if (!config_has_key (config_get_instance (), "LightDM", "log-directory")) config_set_string (config_get_instance (), "LightDM", "log-directory", default_log_dir); g_free (default_log_dir); @@ -1498,7 +1500,7 @@ main (int argc, char **argv) g_debug ("Adding default seat"); - types = config_get_string_list (config_get_instance (), "SeatDefaults", "type"); + types = config_get_string_list (config_get_instance (), "Seat:*", "type"); for (type = types; type && *type; type++) { seat = seat_new (*type, "seat0"); @@ -397,13 +397,15 @@ emit_upstart_signal (const gchar *signal) { g_return_if_fail (signal != NULL); g_return_if_fail (signal[0] != 0); + const gchar* argv[] = {"initctl", "-q", "emit", signal, "DISPLAY_MANAGER=lightdm", NULL}; if (getuid () != 0) return; - gchar *cmd = g_strdup_printf ("initctl -q emit %s DISPLAY_MANAGER=lightdm", signal); - g_spawn_command_line_async (cmd, NULL); /* OK if it fails, probably not installed */ - g_free (cmd); + /* OK if it fails, probably not installed or not running upstart */ + g_spawn_async (NULL, argv, NULL, + G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, + NULL, NULL, NULL, NULL); } static void diff --git a/src/session-child.c b/src/session-child.c index 535aab9a..e85f57da 100644 --- a/src/session-child.c +++ b/src/session-child.c @@ -768,7 +768,7 @@ session_child_run (int argc, char **argv) pam_close_session (pam_handle, 0); /* Remove credentials */ - result = pam_setcred (pam_handle, PAM_DELETE_CRED); + pam_setcred (pam_handle, PAM_DELETE_CRED); pam_end (pam_handle, 0); pam_handle = NULL; diff --git a/src/session.c b/src/session.c index 26d0ce97..e25a69a5 100644 --- a/src/session.c +++ b/src/session.c @@ -910,6 +910,8 @@ session_init (Session *session) { session->priv = G_TYPE_INSTANCE_GET_PRIVATE (session, SESSION_TYPE, SessionPrivate); session->priv->log_filename = g_strdup (".xsession-errors"); + session->priv->to_child_input = -1; + session->priv->from_child_output = -1; } static void diff --git a/src/unity-system-compositor.c b/src/unity-system-compositor.c index 03824284..f4b74eb1 100644 --- a/src/unity-system-compositor.c +++ b/src/unity-system-compositor.c @@ -147,7 +147,8 @@ write_message (UnitySystemCompositor *compositor, guint16 id, const guint8 *payl data[1] = id & 0xFF; data[2] = payload_length >> 8; data[3] = payload_length & 0xFF; - memcpy (data + 4, payload, payload_length); + if (payload) + memcpy (data + 4, payload, payload_length); errno = 0; if (write (compositor->priv->to_compositor_pipe[1], data, data_length) != data_length) |