summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2013-06-11 11:42:43 -0400
committerRay Strode <rstrode@redhat.com>2013-06-11 11:50:37 -0400
commitc8ac5bcaeda49bdb8fb129019ef82a292e7b54d2 (patch)
tree4bd1015c9d0cf4ee89aa3aad9121c4a815c3f45d
parent54a1c5efa5e209fa522e8c0acfaf9868257e95cf (diff)
downloadaccountsservice-c8ac5bcaeda49bdb8fb129019ef82a292e7b54d2.tar.gz
daemon: turn off autologin for disabled users
This is like the previous commit, but for disabled users instead of deleted users.
-rw-r--r--src/daemon.c6
-rw-r--r--src/daemon.h1
-rw-r--r--src/user.c22
3 files changed, 29 insertions, 0 deletions
diff --git a/src/daemon.c b/src/daemon.c
index 2448dce..ec5cc82 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -993,6 +993,12 @@ daemon_local_find_user_by_name (Daemon *daemon,
return user;
}
+User *
+daemon_local_get_automatic_login_user (Daemon *daemon)
+{
+ return daemon->priv->autologin;
+}
+
static gboolean
daemon_find_user_by_id (AccountsAccounts *accounts,
GDBusMethodInvocation *context,
diff --git a/src/daemon.h b/src/daemon.h
index 2ef4d0b..7d89ef5 100644
--- a/src/daemon.h
+++ b/src/daemon.h
@@ -75,6 +75,7 @@ User *daemon_local_find_user_by_id (Daemon *daemon,
uid_t uid);
User *daemon_local_find_user_by_name (Daemon *daemon,
const gchar *name);
+User *daemon_local_get_automatic_login_user (Daemon *daemon);
gboolean daemon_local_user_is_excluded (Daemon *daemon,
const gchar *name,
const gchar *shell,
diff --git a/src/user.c b/src/user.c
index cf1dbff..5359412 100644
--- a/src/user.c
+++ b/src/user.c
@@ -1287,6 +1287,28 @@ user_change_locked_authorized_cb (Daemon *daemon,
user->locked = locked;
+ if (user->automatic_login) {
+ User *automatic_login_user;
+
+ automatic_login_user = daemon_local_get_automatic_login_user (daemon);
+ if (user->locked) {
+ /* If automatic login is enabled for the user then
+ * disable it in the config file, but keep the state
+ * attached to the user unharmed so it can be restored
+ * later in the session
+ */
+ if (user == automatic_login_user) {
+ daemon_local_set_automatic_login (daemon, user, FALSE, NULL);
+ user->automatic_login = TRUE;
+ }
+ } else {
+ if (automatic_login_user == NULL) {
+ user->automatic_login = FALSE;
+ daemon_local_set_automatic_login (daemon, user, TRUE, NULL);
+ }
+ }
+ }
+
accounts_user_emit_changed (ACCOUNTS_USER (user));
g_object_notify (G_OBJECT (user), "locked");