diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2013-11-07 11:54:44 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2013-11-07 11:54:44 +1300 |
commit | dfa6b21e1cc1f0826bdf04560ed36b210bc96a36 (patch) | |
tree | 0d28f47f96d691cfc2706660e708d070f9e12302 | |
parent | d157516a8ad187b036ec25e83ba241445360369d (diff) | |
download | lightdm-dfa6b21e1cc1f0826bdf04560ed36b210bc96a36.tar.gz |
Ignore system user accounts in AccountsService
-rw-r--r-- | liblightdm-gobject/user.c | 26 | ||||
-rw-r--r-- | tests/scripts/users.conf | 4 | ||||
-rw-r--r-- | tests/src/test-runner.c | 5 |
3 files changed, 25 insertions, 10 deletions
diff --git a/liblightdm-gobject/user.c b/liblightdm-gobject/user.c index aaed5855..d20f2ad8 100644 --- a/liblightdm-gobject/user.c +++ b/liblightdm-gobject/user.c @@ -436,8 +436,8 @@ accounts_user_changed_cb (GDBusConnection *connection, LightDMUserPrivate *priv = GET_USER_PRIVATE (user); g_debug ("User %s changed", priv->path); - load_accounts_user (user); - g_signal_emit (user, user_signals[CHANGED], 0); + if (load_accounts_user (user)) + g_signal_emit (user, user_signals[CHANGED], 0); } static gboolean @@ -447,6 +447,7 @@ load_accounts_user (LightDMUser *user) GVariant *result, *value; GVariantIter *iter; gchar *name; + gboolean system_account = FALSE; GError *error = NULL; /* Get the properties for this user */ @@ -497,6 +498,8 @@ load_accounts_user (LightDMUser *user) g_free (priv->home_directory); priv->home_directory = g_variant_dup_string (value, NULL); } + else if (strcmp (name, "SystemAccount") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) + system_account = g_variant_get_boolean (value); else if (strcmp (name, "Language") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) { if (priv->language) @@ -545,7 +548,9 @@ load_accounts_user (LightDMUser *user) g_variant_unref (result); - return TRUE; + priv->loaded_values = TRUE; + + return !system_account; } static void @@ -561,10 +566,15 @@ add_accounts_user (LightDMUserList *user_list, const gchar *path, gboolean emit_ g_debug ("User %s added", path); priv->user_list = user_list; priv->path = g_strdup (path); - list_priv->users = g_list_insert_sorted (list_priv->users, user, compare_user); g_signal_connect (user, "changed", G_CALLBACK (user_changed_cb), NULL); - if (emit_signal) - g_signal_emit (user_list, list_signals[USER_ADDED], 0, user); + if (load_accounts_user (user)) + { + list_priv->users = g_list_insert_sorted (list_priv->users, user, compare_user); + if (emit_signal) + g_signal_emit (user_list, list_signals[USER_ADDED], 0, user); + } + else + g_object_unref (user); } static void @@ -1111,9 +1121,7 @@ load_user_values (LightDMUser *user) return; priv->loaded_values = TRUE; - if (priv->path) - load_accounts_user (user); - else + if (!priv->path) load_dmrc (user); } diff --git a/tests/scripts/users.conf b/tests/scripts/users.conf index af0e57e1..fa6d46f0 100644 --- a/tests/scripts/users.conf +++ b/tests/scripts/users.conf @@ -43,6 +43,10 @@ log-user-changes=true #?GREETER-X-0 LOG-USER USERNAME=have-password2 #?GREETER-X-0 LOG-USER USERNAME=have-password3 +# Add a system user (ignored) +#?*ADD-USER USERNAME=lightdm +#?RUNNER ADD-USER USERNAME=lightdm + # Remove a user #?*DELETE-USER USERNAME=have-password3 #?RUNNER DELETE-USER USERNAME=have-password3 diff --git a/tests/src/test-runner.c b/tests/src/test-runner.c index 3297676e..002f6d20 100644 --- a/tests/src/test-runner.c +++ b/tests/src/test-runner.c @@ -1665,7 +1665,7 @@ handle_accounts_call (GDBusConnection *connection, for (link = accounts_users; link; link = link->next) { AccountsUser *user = link->data; - if (!user->hidden) + if (!user->hidden && user->uid >= 1000) g_variant_builder_add_value (&builder, g_variant_new_object_path (user->path)); } @@ -1733,6 +1733,8 @@ handle_user_get_property (GDBusConnection *connection, return g_variant_new_string (user->real_name); else if (strcmp (property_name, "HomeDirectory") == 0) return g_variant_new_string (user->home_directory); + else if (strcmp (property_name, "SystemAccount") == 0) + return g_variant_new_boolean (user->uid < 1000); else if (strcmp (property_name, "BackgroundFile") == 0) return g_variant_new_string (user->background ? user->background : ""); else if (strcmp (property_name, "Language") == 0) @@ -1790,6 +1792,7 @@ accounts_name_acquired_cb (GDBusConnection *connection, " <property name='UserName' type='s' access='read'/>" " <property name='RealName' type='s' access='read'/>" " <property name='HomeDirectory' type='s' access='read'/>" + " <property name='SystemAccount' type='b' access='read'/>" " <property name='BackgroundFile' type='s' access='read'/>" " <property name='Language' type='s' access='read'/>" " <property name='IconFile' type='s' access='read'/>" |