diff options
author | Lionel Landwerlin <llandwerlin@gmail.com> | 2013-06-28 14:52:26 +0100 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2013-07-01 09:47:40 -0400 |
commit | 254e959f71c44c95c932f9dd04ad809c32aaee4e (patch) | |
tree | 1d62c8bf46b2bc2c2c22b8f7f3a53d9320ee9017 | |
parent | 8fc6d65c79a484ef556bb8abad93599e12d93678 (diff) | |
download | accountsservice-254e959f71c44c95c932f9dd04ad809c32aaee4e.tar.gz |
ActUserManager: handle nonexistent users
Right now if a nonexistent user is requested from the accounts service,
we don't give the caller any sort of notication that the user doesn't
exist. This cascades into d-bus timeouts and ultimately a broken login
screen.
This commit adds a new "nonexistent" user property to the user object
and sets it to TRUE when a requested user fails to load. It also
makes sure the user objects is-loaded property gets set.
Based on a patch by Lionel Landwerlin <llandwerlin@gmail.com>
https://bugs.freedesktop.org/show_bug.cgi?id=66325
-rw-r--r-- | src/libaccountsservice/act-user-manager.c | 3 | ||||
-rw-r--r-- | src/libaccountsservice/act-user-private.h | 1 | ||||
-rw-r--r-- | src/libaccountsservice/act-user.c | 51 | ||||
-rw-r--r-- | src/libaccountsservice/act-user.h | 1 |
4 files changed, 56 insertions, 0 deletions
diff --git a/src/libaccountsservice/act-user-manager.c b/src/libaccountsservice/act-user-manager.c index 8e2d349..32a7893 100644 --- a/src/libaccountsservice/act-user-manager.c +++ b/src/libaccountsservice/act-user-manager.c @@ -2148,6 +2148,9 @@ give_up (ActUserManager *manager, g_debug ("ActUserManager: account service unavailable, " "giving up"); request->state = ACT_USER_MANAGER_GET_USER_STATE_UNFETCHED; + + if (request->user) + _act_user_update_as_nonexistent (request->user); } static void diff --git a/src/libaccountsservice/act-user-private.h b/src/libaccountsservice/act-user-private.h index 69156a2..582ccfb 100644 --- a/src/libaccountsservice/act-user-private.h +++ b/src/libaccountsservice/act-user-private.h @@ -32,6 +32,7 @@ G_BEGIN_DECLS void _act_user_update_from_object_path (ActUser *user, const char *object_path); +void _act_user_update_as_nonexistent (ActUser *user); void _act_user_update_login_frequency (ActUser *user, int login_frequency); void _act_user_load_from_user (ActUser *user, diff --git a/src/libaccountsservice/act-user.c b/src/libaccountsservice/act-user.c index ca860e3..9de689e 100644 --- a/src/libaccountsservice/act-user.c +++ b/src/libaccountsservice/act-user.c @@ -86,6 +86,7 @@ enum { PROP_LOCKED, PROP_AUTOMATIC_LOGIN, PROP_SYSTEM_ACCOUNT, + PROP_NONEXISTENT, PROP_LOCAL_ACCOUNT, PROP_LOGIN_FREQUENCY, PROP_LOGIN_TIME, @@ -138,6 +139,7 @@ struct _ActUser { guint automatic_login : 1; guint system_account : 1; guint local_account : 1; + guint nonexistent : 1; }; struct _ActUserClass @@ -321,6 +323,9 @@ act_user_get_property (GObject *object, case PROP_LOCAL_ACCOUNT: g_value_set_boolean (value, user->local_account); break; + case PROP_NONEXISTENT: + g_value_set_boolean (value, user->nonexistent); + break; case PROP_IS_LOADED: g_value_set_boolean (value, user->is_loaded); break; @@ -473,6 +478,13 @@ act_user_class_init (ActUserClass *class) FALSE, G_PARAM_READABLE)); g_object_class_install_property (gobject_class, + PROP_NONEXISTENT, + g_param_spec_boolean ("nonexistent", + "Doesn't exist", + "Determines whether or not the user object represents a valid user account.", + FALSE, + G_PARAM_READABLE)); + g_object_class_install_property (gobject_class, PROP_LOCKED, g_param_spec_boolean ("locked", "Locked", @@ -992,6 +1004,22 @@ act_user_is_local_account (ActUser *user) } /** + * act_user_is_nonexistent: + * @user: the user object to examine. + * + * Retrieves whether the user is nonexistent or not. + * + * Returns: (transfer none): %TRUE if the user is nonexistent + **/ +gboolean +act_user_is_nonexistent (ActUser *user) +{ + g_return_val_if_fail (ACT_IS_USER (user), FALSE); + + return user->nonexistent; +} + +/** * act_user_get_icon_file: * @user: a #ActUser * @@ -1349,6 +1377,26 @@ changed_handler (AccountsUser *object, } /** + * _act_user_update_as_nonexistent: + * @user: the user object to update. + * + * Set's the 'non-existent' property of @user to #TRUE + * Can only be called before the user is loaded. + **/ +void +_act_user_update_as_nonexistent (ActUser *user) +{ + g_return_if_fail (ACT_IS_USER (user)); + g_return_if_fail (!act_user_is_loaded (user)); + g_return_if_fail (user->object_path == NULL); + + user->nonexistent = TRUE; + g_object_notify (G_OBJECT (user), "nonexistent"); + + set_is_loaded (user, TRUE); +} + +/** * _act_user_update_from_object_path: * @user: the user object to update. * @object_path: the object path of the user to use. @@ -1506,6 +1554,9 @@ _act_user_load_from_user (ActUser *user, user->password_mode = user_to_copy->password_mode; g_object_notify (G_OBJECT (user), "password-mode"); + user->nonexistent = user_to_copy->nonexistent; + g_object_notify (G_OBJECT (user), "nonexistent"); + set_is_loaded (user, TRUE); } diff --git a/src/libaccountsservice/act-user.h b/src/libaccountsservice/act-user.h index e2966f4..d188db4 100644 --- a/src/libaccountsservice/act-user.h +++ b/src/libaccountsservice/act-user.h @@ -74,6 +74,7 @@ gboolean act_user_get_locked (ActUser *user); gboolean act_user_get_automatic_login (ActUser *user); gboolean act_user_is_system_account (ActUser *user); gboolean act_user_is_local_account (ActUser *user); +gboolean act_user_is_nonexistent (ActUser *user); const char *act_user_get_icon_file (ActUser *user); const char *act_user_get_language (ActUser *user); const char *act_user_get_x_session (ActUser *user); |