summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2012-09-20 17:33:28 +1200
committerRobert Ancell <robert.ancell@canonical.com>2012-09-20 17:33:28 +1200
commitb900bbb740dde9cace885200744586cd6365ba8e (patch)
tree6e3007a8765395789d699874950dc57ec1f08398 /src
parentbc7675aba3224119ec1d7be10428800bb3b72577 (diff)
downloadlightdm-b900bbb740dde9cace885200744586cd6365ba8e.tar.gz
Correctly implement and test autologin timeouts
Diffstat (limited to 'src')
-rw-r--r--src/display.c6
-rw-r--r--src/greeter.c23
-rw-r--r--src/greeter.h2
-rw-r--r--src/seat.c20
4 files changed, 36 insertions, 15 deletions
diff --git a/src/display.c b/src/display.c
index ec001530..75f8a069 100644
--- a/src/display.c
+++ b/src/display.c
@@ -395,7 +395,7 @@ start_greeter (Display *display)
g_signal_connect (display->priv->session, "authentication-complete", G_CALLBACK (greeter_authentication_complete_cb), display);
/* Make communication link to greeter that will run on this session */
- display->priv->greeter = greeter_new (display->priv->session, USER_SERVICE);
+ display->priv->greeter = greeter_new (display->priv->session, USER_SERVICE, AUTOLOGIN_SERVICE);
g_signal_connect (G_OBJECT (display->priv->greeter), "connected", G_CALLBACK (greeter_connected_cb), display);
g_signal_connect (G_OBJECT (display->priv->greeter), "start-authentication", G_CALLBACK (greeter_start_authentication_cb), display);
g_signal_connect (G_OBJECT (display->priv->greeter), "start-session", G_CALLBACK (greeter_start_session_cb), display);
@@ -767,12 +767,12 @@ display_server_ready_cb (DisplayServer *display_server, Display *display)
/* Automatically start requested user session */
result = FALSE;
- if (display->priv->autologin_guest)
+ if (display->priv->autologin_timeout == 0 && display->priv->autologin_guest)
{
g_debug ("Automatically logging in as guest");
result = autologin_guest (display, AUTOLOGIN_SERVICE, TRUE);
}
- else if (display->priv->autologin_user)
+ else if (display->priv->autologin_timeout == 0 && display->priv->autologin_user)
{
g_debug ("Automatically logging in user %s", display->priv->autologin_user);
result = autologin (display, display->priv->autologin_user, AUTOLOGIN_SERVICE, TRUE, FALSE);
diff --git a/src/greeter.c b/src/greeter.c
index 5180fc82..b936168a 100644
--- a/src/greeter.c
+++ b/src/greeter.c
@@ -35,6 +35,7 @@ struct GreeterPrivate
/* PAM service to authenticate with */
gchar *pam_service;
+ gchar *autologin_pam_service;
/* Buffer for data read from greeter */
guint8 *read_buffer;
@@ -96,13 +97,14 @@ typedef enum
static gboolean read_cb (GIOChannel *source, GIOCondition condition, gpointer data);
Greeter *
-greeter_new (Session *session, const gchar *pam_service)
+greeter_new (Session *session, const gchar *pam_service, const gchar *autologin_pam_service)
{
Greeter *greeter;
greeter = g_object_new (GREETER_TYPE, NULL);
greeter->priv->session = g_object_ref (session);
greeter->priv->pam_service = g_strdup (pam_service);
+ greeter->priv->autologin_pam_service = g_strdup (autologin_pam_service);
return greeter;
}
@@ -314,6 +316,9 @@ reset_session (Greeter *greeter)
static void
handle_login (Greeter *greeter, guint32 sequence_number, const gchar *username)
{
+ const gchar *autologin_username, *service;
+ gboolean is_interactive;
+
if (username[0] == '\0')
{
g_debug ("Greeter start authentication");
@@ -335,8 +340,21 @@ handle_login (Greeter *greeter, guint32 sequence_number, const gchar *username)
g_signal_connect (G_OBJECT (greeter->priv->authentication_session), "got-messages", G_CALLBACK (pam_messages_cb), greeter);
g_signal_connect (G_OBJECT (greeter->priv->authentication_session), "authentication-complete", G_CALLBACK (authentication_complete_cb), greeter);
+ /* Use non-interactive service for autologin user */
+ autologin_username = g_hash_table_lookup (greeter->priv->hints, "autologin-user");
+ if (autologin_username != NULL && g_strcmp0 (username, autologin_username) == 0)
+ {
+ service = greeter->priv->autologin_pam_service;
+ is_interactive = FALSE;
+ }
+ else
+ {
+ service = greeter->priv->pam_service;
+ is_interactive = TRUE;
+ }
+
/* Run the session process */
- session_start (greeter->priv->authentication_session, greeter->priv->pam_service, username, TRUE, TRUE, FALSE);
+ session_start (greeter->priv->authentication_session, service, username, TRUE, is_interactive, FALSE);
}
static void
@@ -792,6 +810,7 @@ greeter_finalize (GObject *object)
g_signal_handlers_disconnect_matched (self->priv->session, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, self);
g_object_unref (self->priv->session);
g_free (self->priv->pam_service);
+ g_free (self->priv->autologin_pam_service);
g_free (self->priv->read_buffer);
g_hash_table_unref (self->priv->hints);
g_free (self->priv->remote_session);
diff --git a/src/greeter.h b/src/greeter.h
index 27801952..54803922 100644
--- a/src/greeter.h
+++ b/src/greeter.h
@@ -37,7 +37,7 @@ typedef struct
GType greeter_get_type (void);
-Greeter *greeter_new (Session *session, const gchar *pam_service);
+Greeter *greeter_new (Session *session, const gchar *pam_service, const gchar *autologin_pam_service);
void greeter_set_allow_guest (Greeter *greeter, gboolean allow_guest);
diff --git a/src/seat.c b/src/seat.c
index f055f389..c6db4c73 100644
--- a/src/seat.c
+++ b/src/seat.c
@@ -436,7 +436,7 @@ display_stopped_cb (Display *display, Seat *seat)
}
static gboolean
-switch_to_user_or_start_greeter (Seat *seat, const gchar *username, gboolean use_existing, gboolean is_guest, const gchar *session_name, gboolean is_lock, gboolean autologin)
+switch_to_user_or_start_greeter (Seat *seat, const gchar *username, gboolean use_existing, gboolean is_guest, const gchar *session_name, gboolean is_lock, gboolean autologin, int autologin_timeout)
{
Display *display;
DisplayServer *display_server;
@@ -490,7 +490,7 @@ switch_to_user_or_start_greeter (Seat *seat, const gchar *username, gboolean use
display_set_allow_guest (display, seat_get_allow_guest (seat));
display_set_greeter_allow_guest (display, seat_get_greeter_allow_guest (seat));
if (autologin)
- display_set_autologin_user (display, username, is_guest, 0);
+ display_set_autologin_user (display, username, is_guest, autologin_timeout);
else
display_set_select_user_hint (display, username, is_guest);
if (!session_name)
@@ -516,7 +516,7 @@ seat_switch_to_greeter (Seat *seat)
return FALSE;
g_debug ("Switching to greeter");
- return switch_to_user_or_start_greeter (seat, NULL, TRUE, FALSE, NULL, FALSE, FALSE);
+ return switch_to_user_or_start_greeter (seat, NULL, TRUE, FALSE, NULL, FALSE, FALSE, 0);
}
gboolean
@@ -529,7 +529,7 @@ seat_switch_to_user (Seat *seat, const gchar *username, const gchar *session_nam
return FALSE;
g_debug ("Switching to user %s", username);
- return switch_to_user_or_start_greeter (seat, username, TRUE, FALSE, session_name, FALSE, FALSE);
+ return switch_to_user_or_start_greeter (seat, username, TRUE, FALSE, session_name, FALSE, FALSE, 0);
}
gboolean
@@ -544,7 +544,7 @@ seat_switch_to_guest (Seat *seat, const gchar *session_name)
g_debug ("Switching to existing guest account %s", seat->priv->guest_username);
else
g_debug ("Switching to new guest account");
- return switch_to_user_or_start_greeter (seat, seat->priv->guest_username, TRUE, TRUE, session_name, FALSE, TRUE);
+ return switch_to_user_or_start_greeter (seat, seat->priv->guest_username, TRUE, TRUE, session_name, FALSE, TRUE, 0);
}
gboolean
@@ -556,7 +556,7 @@ seat_lock (Seat *seat, const gchar *username)
return FALSE;
g_debug ("Locking seat");
- return switch_to_user_or_start_greeter (seat, username, FALSE, FALSE, NULL, TRUE, FALSE);
+ return switch_to_user_or_start_greeter (seat, username, FALSE, FALSE, NULL, TRUE, FALSE, 0);
}
void
@@ -588,6 +588,7 @@ static gboolean
seat_real_start (Seat *seat)
{
const gchar *autologin_username;
+ int autologin_timeout;
g_debug ("Starting seat");
@@ -595,13 +596,14 @@ seat_real_start (Seat *seat)
autologin_username = seat_get_string_property (seat, "autologin-user");
if (g_strcmp0 (autologin_username, "") == 0)
autologin_username = NULL;
+ autologin_timeout = seat_get_integer_property (seat, "autologin-user-timeout");
if (autologin_username)
- return switch_to_user_or_start_greeter (seat, autologin_username, TRUE, FALSE, NULL, FALSE, TRUE);
+ return switch_to_user_or_start_greeter (seat, autologin_username, TRUE, FALSE, NULL, FALSE, TRUE, autologin_timeout);
else if (seat_get_boolean_property (seat, "autologin-guest"))
- return switch_to_user_or_start_greeter (seat, NULL, TRUE, TRUE, NULL, FALSE, TRUE);
+ return switch_to_user_or_start_greeter (seat, NULL, TRUE, TRUE, NULL, FALSE, TRUE, autologin_timeout);
else
- return switch_to_user_or_start_greeter (seat, NULL, TRUE, FALSE, NULL, FALSE, FALSE);
+ return switch_to_user_or_start_greeter (seat, NULL, TRUE, FALSE, NULL, FALSE, FALSE, 0);
}
static void