diff options
author | Ray Strode <rstrode@redhat.com> | 2023-03-15 10:44:05 -0400 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2023-03-15 11:09:35 -0400 |
commit | 15e6a4c3a2982bdc6619258af34f13ba0f71046f (patch) | |
tree | 58f4f9a9731add436310ada7ef44048d2da17006 /src/user.c | |
parent | 78794fafaf1d3228a4b0b70c9eea53dba37c9497 (diff) | |
download | accountsservice-15e6a4c3a2982bdc6619258af34f13ba0f71046f.tar.gz |
user: Support new LocalAccount property in cache file23.11.69
At the moment an admin can decide whether or not a user is a system
account by setting SystemAccount= to true or false in the users
cache file, but there's no way to to do the same sort of configuration
for deciding whether or not a user is a local account.
This commit adds support for a new LocalAccount= key in the cache file.
Note, by default this key won't get written into the cache file and
instead accountsservice will continue to rely on it's "user is in
/etc/shadow" heuristic.
The key only gets rewritten into the file during cache file
serialization if an admin added it there first.
Closes: https://gitlab.freedesktop.org/accountsservice/accountsservice/-/issues/110
Diffstat (limited to 'src/user.c')
-rw-r--r-- | src/user.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -73,6 +73,7 @@ struct User gboolean account_expiration_policy_known; gboolean cached; gboolean template_loaded; + gboolean local_account_overridden; guint *extension_ids; guint n_extension_ids; @@ -585,6 +586,15 @@ user_update_from_keyfile (User *user, g_clear_pointer (&s, g_free); } + if (g_key_file_has_key (keyfile, "User", "LocalAccount", NULL)) { + gboolean local_account; + + user->local_account_overridden = TRUE; + + local_account = g_key_file_get_boolean (keyfile, "User", "LocalAccount", NULL); + accounts_user_set_local_account (ACCOUNTS_USER (user), local_account); + } + if (g_key_file_has_key (keyfile, "User", "SystemAccount", NULL)) { gboolean system_account; @@ -669,6 +679,9 @@ user_save_to_keyfile (User *user, if (accounts_user_get_icon_file (ACCOUNTS_USER (user))) g_key_file_set_string (keyfile, "User", "Icon", accounts_user_get_icon_file (ACCOUNTS_USER (user))); + if (user->local_account_overridden) + g_key_file_set_boolean (keyfile, "User", "LocalAccount", accounts_user_get_local_account (ACCOUNTS_USER (user))); + g_key_file_set_boolean (keyfile, "User", "SystemAccount", accounts_user_get_system_account (ACCOUNTS_USER (user))); user_set_cached (user, TRUE); @@ -1077,6 +1090,12 @@ user_get_system_account (User *user) } gboolean +user_get_local_account_overridden (User *user) +{ + return user->local_account_overridden; +} + +gboolean user_get_local_account (User *user) { return accounts_user_get_local_account (ACCOUNTS_USER (user)); |