Blame SOURCES/0015-act-user-Prevent-segfault-if-accounts_proxy-is-not-c.patch

919a4e
From 919e8972a6635539499f153a28d92e0c4052b354 Mon Sep 17 00:00:00 2001
919a4e
From: Ondrej Holy <oholy@redhat.com>
919a4e
Date: Tue, 30 Jan 2018 08:58:20 +0100
919a4e
Subject: [PATCH 15/15] act-user: Prevent segfault if accounts_proxy is not
919a4e
 created
919a4e
919a4e
act_user_get_locked may segfault if accounts_proxy is not created (e.g.
919a4e
when run under root). All other functions which rely on accounts_proxy
919a4e
already contain checks for NULL and valid ActUser. Do the same also in
919a4e
act_user_get_locked in order to avoid segfaults in certain cases.
919a4e
919a4e
https://bugs.freedesktop.org/show_bug.cgi?id=104851
919a4e
---
919a4e
 src/libaccountsservice/act-user.c | 5 +++++
919a4e
 1 file changed, 5 insertions(+)
919a4e
919a4e
diff --git a/src/libaccountsservice/act-user.c b/src/libaccountsservice/act-user.c
919a4e
index a24f25a..e21c9db 100644
919a4e
--- a/src/libaccountsservice/act-user.c
919a4e
+++ b/src/libaccountsservice/act-user.c
919a4e
@@ -859,60 +859,65 @@ act_user_is_logged_in (ActUser *user)
919a4e
 
919a4e
 /**
919a4e
  * act_user_is_logged_in_anywhere:
919a4e
  * @user: a #ActUser
919a4e
  *
919a4e
  * Returns whether or not #ActUser is currently logged in in any way
919a4e
  * whatsoever.  See also act_user_is_logged_in().
919a4e
  *
919a4e
  * (Currently, this function is only implemented for systemd-logind.
919a4e
  * For ConsoleKit, it is equivalent to act_user_is_logged_in.)
919a4e
  *
919a4e
  * Returns: %TRUE or %FALSE
919a4e
  */
919a4e
 gboolean
919a4e
 act_user_is_logged_in_anywhere (ActUser *user)
919a4e
 {
919a4e
         return user->our_sessions != NULL || user->other_sessions != NULL;
919a4e
 }
919a4e
 
919a4e
 /**
919a4e
  * act_user_get_locked:
919a4e
  * @user: a #ActUser
919a4e
  *
919a4e
  * Returns whether or not the #ActUser account is locked.
919a4e
  *
919a4e
  * Returns: %TRUE or %FALSE
919a4e
  */
919a4e
 gboolean
919a4e
 act_user_get_locked (ActUser *user)
919a4e
 {
919a4e
+        g_return_val_if_fail (ACT_IS_USER (user), TRUE);
919a4e
+
919a4e
+        if (user->accounts_proxy == NULL)
919a4e
+                return TRUE;
919a4e
+
919a4e
         return accounts_user_get_locked (user->accounts_proxy);
919a4e
 }
919a4e
 
919a4e
 /**
919a4e
  * act_user_get_automatic_login:
919a4e
  * @user: a #ActUser
919a4e
  *
919a4e
  * Returns whether or not #ActUser is automatically logged in at boot time.
919a4e
  *
919a4e
  * Returns: %TRUE or %FALSE
919a4e
  */
919a4e
 gboolean
919a4e
 act_user_get_automatic_login (ActUser *user)
919a4e
 {
919a4e
         g_return_val_if_fail (ACT_IS_USER (user), FALSE);
919a4e
 
919a4e
         if (user->accounts_proxy == NULL)
919a4e
                 return FALSE;
919a4e
 
919a4e
        return accounts_user_get_automatic_login (user->accounts_proxy);
919a4e
 }
919a4e
 
919a4e
 /**
919a4e
  * act_user_is_system_account:
919a4e
  * @user: a #ActUser
919a4e
  *
919a4e
  * Returns whether or not #ActUser represents a 'system account' like
919a4e
  * 'root' or 'nobody'.
919a4e
  *
919a4e
  * Returns: %TRUE or %FALSE
919a4e
-- 
919a4e
2.14.3
919a4e