summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2013-05-20 09:15:36 -0400
committerRay Strode <rstrode@redhat.com>2013-05-20 19:49:12 -0400
commitfb3273bbcda498663b74cb2fb9bbaa3f18130fd8 (patch)
tree7697d0776dfc06d3ba7d12d6ce8d04c36412f27f
parentc155a72d4da6afe5ed6846954e6f06086ea91912 (diff)
user: never treat cached users as system accounts
Right now the check for "is system user" is less than solid. It depends on checking things like whether or not a password is set, and whether or not a shell is set. Unfortunately, sometimes a password is not set for a non-system account, and sometimes a shell is set for a system account, so the heuristics aren't perfect. In one particular case, we currently get things wrong: right after a user is created before they have a password. This commit attempts to shore up the heuristics by never treating cached users as system users. https://bugs.freedesktop.org/show_bug.cgi?id=64769
-rw-r--r--src/daemon.c3
-rw-r--r--src/user.c13
-rw-r--r--src/user.h2
3 files changed, 18 insertions, 0 deletions
diff --git a/src/daemon.c b/src/daemon.c
index 872d9ef..d8abe64 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -1180,6 +1180,7 @@ daemon_create_user_authorized_cb (Daemon *daemon,
user = daemon_local_find_user_by_name (daemon, cd->user_name);
user_update_local_account_property (user, TRUE);
+ user_update_system_account_property (user, FALSE);
cache_user (daemon, user);
@@ -1231,6 +1232,8 @@ daemon_cache_user_authorized_cb (Daemon *daemon,
return;
}
+ user_update_system_account_property (user, FALSE);
+
cache_user (daemon, user);
accounts_accounts_complete_cache_user (NULL, context, user_get_object_path (user));
diff --git a/src/user.c b/src/user.c
index 726a9d6..e3f8e01 100644
--- a/src/user.c
+++ b/src/user.c
@@ -285,6 +285,9 @@ user_update_from_pwent (User *user,
g_object_notify (G_OBJECT (user), "password-mode");
}
+ /* FIXME: this relies on heuristics that don't always come out
+ * right.
+ */
user->system_account = daemon_local_user_is_excluded (user->daemon,
user->user_name,
pwent->pw_shell,
@@ -370,6 +373,16 @@ user_update_local_account_property (User *user,
g_object_notify (G_OBJECT (user), "local-account");
}
+void
+user_update_system_account_property (User *user,
+ gboolean system)
+{
+ if (system == user->system_account)
+ return;
+ user->system_account = system;
+ g_object_notify (G_OBJECT (user), "system-account");
+}
+
static void
user_save_to_keyfile (User *user,
GKeyFile *keyfile)
diff --git a/src/user.h b/src/user.h
index 937e1b9..5c3c719 100644
--- a/src/user.h
+++ b/src/user.h
@@ -59,6 +59,8 @@ void user_update_from_keyfile (User *user,
GKeyFile *keyfile);
void user_update_local_account_property (User *user,
gboolean local);
+void user_update_system_account_property (User *user,
+ gboolean system);
void user_register (User *user);
void user_unregister (User *user);