Blame SOURCES/0002-user-export-new-Saved-property.patch

7dfda4
From 14bb1237f71e38749558c74963032a0387eecec0 Mon Sep 17 00:00:00 2001
7dfda4
From: Ray Strode <rstrode@redhat.com>
7dfda4
Date: Wed, 15 Aug 2018 16:04:42 -0400
7dfda4
Subject: [PATCH 2/2] user: export new Saved property
7dfda4
7dfda4
accountsservice maintains a state file for some users, if those users
7dfda4
have selected a specific session or language.
7dfda4
7dfda4
There's no good way, at the moment, for an application to check if a
7dfda4
specific user has saved state.
7dfda4
7dfda4
This commit exports the Saved property on the User object.
7dfda4
---
7dfda4
 data/org.freedesktop.Accounts.User.xml | 10 ++++++++++
7dfda4
 src/daemon.c                           |  3 +++
7dfda4
 src/libaccountsservice/act-user.c      | 19 +++++++++++++++++++
7dfda4
 src/libaccountsservice/act-user.h      |  1 +
7dfda4
 src/user.c                             | 10 ++++++++++
7dfda4
 src/user.h                             |  2 ++
7dfda4
 6 files changed, 45 insertions(+)
7dfda4
7dfda4
diff --git a/data/org.freedesktop.Accounts.User.xml b/data/org.freedesktop.Accounts.User.xml
7dfda4
index 7fc3c61..8d3fe1c 100644
7dfda4
--- a/data/org.freedesktop.Accounts.User.xml
7dfda4
+++ b/data/org.freedesktop.Accounts.User.xml
7dfda4
@@ -811,60 +811,70 @@
7dfda4
     </doc:doc>
7dfda4
   </property>
7dfda4
 
7dfda4
   <property name="LoginHistory" type="a(xxa{sv})" access="read">
7dfda4
     <doc:doc>
7dfda4
       <doc:description>
7dfda4
         <doc:para>
7dfda4
           The login history for this user.
7dfda4
           Each entry in the array represents a login session. The first two
7dfda4
           members are the login time and logout time, as timestamps (seconds since the epoch). If the session is still running, the logout time
7dfda4
           is 0.
7dfda4
         </doc:para>
7dfda4
         <doc:para>
7dfda4
           The a{sv} member is a dictionary containing additional information
7dfda4
           about the session. Possible members include 'type' (with values like ':0', 'tty0', 'pts/0' etc).
7dfda4
         </doc:para>
7dfda4
       </doc:description>
7dfda4
     </doc:doc>
7dfda4
   </property>
7dfda4
 
7dfda4
   <property name="IconFile" type="s" access="read">
7dfda4
     <doc:doc>
7dfda4
       <doc:description>
7dfda4
         <doc:para>
7dfda4
            The filename of a png file containing the users icon.
7dfda4
         </doc:para>
7dfda4
       </doc:description>
7dfda4
     </doc:doc>
7dfda4
   </property>
7dfda4
 
7dfda4
+  <property name="Saved" type="b" access="read">
7dfda4
+    <doc:doc>
7dfda4
+      <doc:description>
7dfda4
+        <doc:para>
7dfda4
+           Whether the users account has retained state
7dfda4
+        </doc:para>
7dfda4
+      </doc:description>
7dfda4
+    </doc:doc>
7dfda4
+  </property>
7dfda4
+
7dfda4
   <property name="Locked" type="b" access="read">
7dfda4
     <doc:doc>
7dfda4
       <doc:description>
7dfda4
         <doc:para>
7dfda4
            Whether the users account is locked.
7dfda4
         </doc:para>
7dfda4
       </doc:description>
7dfda4
     </doc:doc>
7dfda4
   </property>
7dfda4
 
7dfda4
   <property name="PasswordMode" type="i" access="read">
7dfda4
     <doc:doc>
7dfda4
       <doc:description>
7dfda4
         <doc:para>
7dfda4
           The password mode for the user account, encoded as an integer:
7dfda4
           <doc:list>
7dfda4
             <doc:item>
7dfda4
               <doc:term>0</doc:term>
7dfda4
               <doc:definition>Regular password</doc:definition>
7dfda4
             </doc:item>
7dfda4
             <doc:item>
7dfda4
               <doc:term>1</doc:term>
7dfda4
               <doc:definition>Password must be set at next login</doc:definition>
7dfda4
             </doc:item>
7dfda4
             <doc:item>
7dfda4
               <doc:term>2</doc:term>
7dfda4
               <doc:definition>No password</doc:definition>
7dfda4
             </doc:item>
7dfda4
           </doc:list>
7dfda4
         </doc:para>
7dfda4
diff --git a/src/daemon.c b/src/daemon.c
7dfda4
index 2851ed6..2587b8a 100644
7dfda4
--- a/src/daemon.c
7dfda4
+++ b/src/daemon.c
7dfda4
@@ -1187,60 +1187,61 @@ daemon_cache_user (AccountsAccounts      *accounts,
7dfda4
                                  context,
7dfda4
                                  g_strdup (user_name),
7dfda4
                                  g_free);
7dfda4
 
7dfda4
         return TRUE;
7dfda4
 }
7dfda4
 
7dfda4
 static void
7dfda4
 daemon_uncache_user_authorized_cb (Daemon                *daemon,
7dfda4
                                    User                  *dummy,
7dfda4
                                    GDBusMethodInvocation *context,
7dfda4
                                    gpointer               data)
7dfda4
 {
7dfda4
         const gchar *user_name = data;
7dfda4
         User        *user;
7dfda4
 
7dfda4
         sys_log (context, "uncache user '%s'", user_name);
7dfda4
 
7dfda4
         user = daemon_local_find_user_by_name (daemon, user_name);
7dfda4
         if (user == NULL) {
7dfda4
                 throw_error (context, ERROR_USER_DOES_NOT_EXIST,
7dfda4
                              "No user with the name %s found", user_name);
7dfda4
                 return;
7dfda4
         }
7dfda4
 
7dfda4
         /* Always use the canonical user name looked up */
7dfda4
         user_name = user_get_user_name (user);
7dfda4
 
7dfda4
         remove_cache_files (user_name);
7dfda4
 
7dfda4
+        user_set_saved (user, FALSE);
7dfda4
         user_set_cached (user, FALSE);
7dfda4
 
7dfda4
         accounts_accounts_complete_uncache_user (NULL, context);
7dfda4
 
7dfda4
         queue_reload_users (daemon);
7dfda4
 }
7dfda4
 
7dfda4
 static gboolean
7dfda4
 daemon_uncache_user (AccountsAccounts      *accounts,
7dfda4
                      GDBusMethodInvocation *context,
7dfda4
                      const gchar           *user_name)
7dfda4
 {
7dfda4
         Daemon *daemon = (Daemon*)accounts;
7dfda4
 
7dfda4
         daemon_local_check_auth (daemon,
7dfda4
                                  NULL,
7dfda4
                                  "org.freedesktop.accounts.user-administration",
7dfda4
                                  TRUE,
7dfda4
                                  daemon_uncache_user_authorized_cb,
7dfda4
                                  context,
7dfda4
                                  g_strdup (user_name),
7dfda4
                                  g_free);
7dfda4
 
7dfda4
         return TRUE;
7dfda4
 }
7dfda4
 
7dfda4
 typedef struct {
7dfda4
         uid_t uid;
7dfda4
         gboolean remove_files;
7dfda4
 } DeleteUserData;
7dfda4
@@ -1252,60 +1253,62 @@ daemon_delete_user_authorized_cb (Daemon                *daemon,
7dfda4
                                   gpointer               data)
7dfda4
 
7dfda4
 {
7dfda4
         DeleteUserData *ud = data;
7dfda4
         g_autoptr(GError) error = NULL;
7dfda4
         struct passwd *pwent;
7dfda4
         const gchar *argv[6];
7dfda4
         User *user;
7dfda4
 
7dfda4
         pwent = getpwuid (ud->uid);
7dfda4
 
7dfda4
         if (pwent == NULL) {
7dfda4
                 throw_error (context, ERROR_USER_DOES_NOT_EXIST, "No user with uid %d found", ud->uid);
7dfda4
                 return;
7dfda4
         }
7dfda4
 
7dfda4
         sys_log (context, "delete user '%s' (%d)", pwent->pw_name, ud->uid);
7dfda4
 
7dfda4
         user = daemon_local_find_user_by_id (daemon, ud->uid);
7dfda4
 
7dfda4
         if (user != NULL) {
7dfda4
                 user_set_cached (user, FALSE);
7dfda4
 
7dfda4
                 if (daemon->priv->autologin == user) {
7dfda4
                         daemon_local_set_automatic_login (daemon, user, FALSE, NULL);
7dfda4
                 }
7dfda4
         }
7dfda4
 
7dfda4
         remove_cache_files (pwent->pw_name);
7dfda4
 
7dfda4
+        user_set_saved (user, FALSE);
7dfda4
+
7dfda4
         argv[0] = "/usr/sbin/userdel";
7dfda4
         if (ud->remove_files) {
7dfda4
                 argv[1] = "-f";
7dfda4
                 argv[2] = "-r";
7dfda4
                 argv[3] = "--";
7dfda4
                 argv[4] = pwent->pw_name;
7dfda4
                 argv[5] = NULL;
7dfda4
         }
7dfda4
         else {
7dfda4
                 argv[1] = "-f";
7dfda4
                 argv[2] = "--";
7dfda4
                 argv[3] = pwent->pw_name;
7dfda4
                 argv[4] = NULL;
7dfda4
         }
7dfda4
 
7dfda4
         if (!spawn_with_login_uid (context, argv, &error)) {
7dfda4
                 throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message);
7dfda4
                 return;
7dfda4
         }
7dfda4
 
7dfda4
         accounts_accounts_complete_delete_user (NULL, context);
7dfda4
 }
7dfda4
 
7dfda4
 
7dfda4
 static gboolean
7dfda4
 daemon_delete_user (AccountsAccounts      *accounts,
7dfda4
                     GDBusMethodInvocation *context,
7dfda4
                     gint64                 uid,
7dfda4
                     gboolean               remove_files)
7dfda4
 {
7dfda4
diff --git a/src/libaccountsservice/act-user.c b/src/libaccountsservice/act-user.c
7dfda4
index dd8f81b..540ffe7 100644
7dfda4
--- a/src/libaccountsservice/act-user.c
7dfda4
+++ b/src/libaccountsservice/act-user.c
7dfda4
@@ -849,60 +849,79 @@ act_user_collate (ActUser *user1,
7dfda4
  *
7dfda4
  * Returns whether or not #ActUser is currently graphically logged in
7dfda4
  * on the same seat as the seat of the session of the calling process.
7dfda4
  *
7dfda4
  * Returns: %TRUE or %FALSE
7dfda4
  */
7dfda4
 gboolean
7dfda4
 act_user_is_logged_in (ActUser *user)
7dfda4
 {
7dfda4
         return user->our_sessions != NULL;
7dfda4
 }
7dfda4
 
7dfda4
 /**
7dfda4
  * act_user_is_logged_in_anywhere:
7dfda4
  * @user: a #ActUser
7dfda4
  *
7dfda4
  * Returns whether or not #ActUser is currently logged in in any way
7dfda4
  * whatsoever.  See also act_user_is_logged_in().
7dfda4
  *
7dfda4
  * (Currently, this function is only implemented for systemd-logind.
7dfda4
  * For ConsoleKit, it is equivalent to act_user_is_logged_in.)
7dfda4
  *
7dfda4
  * Returns: %TRUE or %FALSE
7dfda4
  */
7dfda4
 gboolean
7dfda4
 act_user_is_logged_in_anywhere (ActUser *user)
7dfda4
 {
7dfda4
         return user->our_sessions != NULL || user->other_sessions != NULL;
7dfda4
 }
7dfda4
 
7dfda4
+/**
7dfda4
+ * act_user_get_saved:
7dfda4
+ * @user: a #ActUser
7dfda4
+ *
7dfda4
+ * Returns whether or not the #ActUser account has retained state in accountsservice.
7dfda4
+ *
7dfda4
+ * Returns: %TRUE or %FALSE
7dfda4
+ */
7dfda4
+gboolean
7dfda4
+act_user_get_saved (ActUser *user)
7dfda4
+{
7dfda4
+        g_return_val_if_fail (ACT_IS_USER (user), TRUE);
7dfda4
+
7dfda4
+        if (user->accounts_proxy == NULL)
7dfda4
+                return FALSE;
7dfda4
+
7dfda4
+        return accounts_user_get_saved (user->accounts_proxy);
7dfda4
+}
7dfda4
+
7dfda4
 /**
7dfda4
  * act_user_get_locked:
7dfda4
  * @user: a #ActUser
7dfda4
  *
7dfda4
  * Returns whether or not the #ActUser account is locked.
7dfda4
  *
7dfda4
  * Returns: %TRUE or %FALSE
7dfda4
  */
7dfda4
 gboolean
7dfda4
 act_user_get_locked (ActUser *user)
7dfda4
 {
7dfda4
         g_return_val_if_fail (ACT_IS_USER (user), TRUE);
7dfda4
 
7dfda4
         if (user->accounts_proxy == NULL)
7dfda4
                 return TRUE;
7dfda4
 
7dfda4
         return accounts_user_get_locked (user->accounts_proxy);
7dfda4
 }
7dfda4
 
7dfda4
 /**
7dfda4
  * act_user_get_automatic_login:
7dfda4
  * @user: a #ActUser
7dfda4
  *
7dfda4
  * Returns whether or not #ActUser is automatically logged in at boot time.
7dfda4
  *
7dfda4
  * Returns: %TRUE or %FALSE
7dfda4
  */
7dfda4
 gboolean
7dfda4
 act_user_get_automatic_login (ActUser *user)
7dfda4
 {
7dfda4
diff --git a/src/libaccountsservice/act-user.h b/src/libaccountsservice/act-user.h
7dfda4
index 2ef13b1..34d7fe3 100644
7dfda4
--- a/src/libaccountsservice/act-user.h
7dfda4
+++ b/src/libaccountsservice/act-user.h
7dfda4
@@ -43,60 +43,61 @@ typedef enum {
7dfda4
 typedef enum {
7dfda4
         ACT_USER_PASSWORD_MODE_REGULAR,
7dfda4
         ACT_USER_PASSWORD_MODE_SET_AT_LOGIN,
7dfda4
         ACT_USER_PASSWORD_MODE_NONE,
7dfda4
 } ActUserPasswordMode;
7dfda4
 
7dfda4
 typedef struct _ActUser ActUser;
7dfda4
 typedef struct _ActUserClass ActUserClass;
7dfda4
 
7dfda4
 GType          act_user_get_type                  (void) G_GNUC_CONST;
7dfda4
 
7dfda4
 const char    *act_user_get_object_path           (ActUser *user);
7dfda4
 
7dfda4
 uid_t          act_user_get_uid                   (ActUser   *user);
7dfda4
 const char    *act_user_get_user_name             (ActUser   *user);
7dfda4
 const char    *act_user_get_real_name             (ActUser   *user);
7dfda4
 ActUserAccountType act_user_get_account_type      (ActUser   *user);
7dfda4
 ActUserPasswordMode act_user_get_password_mode    (ActUser   *user);
7dfda4
 const char    *act_user_get_password_hint         (ActUser   *user);
7dfda4
 const char    *act_user_get_home_dir              (ActUser   *user);
7dfda4
 const char    *act_user_get_shell                 (ActUser   *user);
7dfda4
 const char    *act_user_get_email                 (ActUser   *user);
7dfda4
 const char    *act_user_get_location              (ActUser   *user);
7dfda4
 guint          act_user_get_num_sessions          (ActUser   *user);
7dfda4
 guint          act_user_get_num_sessions_anywhere (ActUser   *user);
7dfda4
 gboolean       act_user_is_logged_in              (ActUser   *user);
7dfda4
 gboolean       act_user_is_logged_in_anywhere     (ActUser   *user);
7dfda4
 int            act_user_get_login_frequency       (ActUser   *user);
7dfda4
 gint64         act_user_get_login_time            (ActUser   *user);
7dfda4
 const GVariant*act_user_get_login_history         (ActUser   *user);
7dfda4
+gboolean       act_user_get_saved                 (ActUser   *user);
7dfda4
 gboolean       act_user_get_locked                (ActUser   *user);
7dfda4
 gboolean       act_user_get_automatic_login       (ActUser   *user);
7dfda4
 gboolean       act_user_is_system_account         (ActUser   *user);
7dfda4
 gboolean       act_user_is_local_account          (ActUser   *user);
7dfda4
 gboolean       act_user_is_nonexistent            (ActUser   *user);
7dfda4
 const char    *act_user_get_icon_file             (ActUser   *user);
7dfda4
 const char    *act_user_get_language              (ActUser   *user);
7dfda4
 const char    *act_user_get_x_session             (ActUser   *user);
7dfda4
 const char    *act_user_get_session               (ActUser   *user);
7dfda4
 const char    *act_user_get_session_type          (ActUser   *user);
7dfda4
 const char    *act_user_get_primary_session_id    (ActUser   *user);
7dfda4
 
7dfda4
 gint           act_user_collate                   (ActUser   *user1,
7dfda4
                                                    ActUser   *user2);
7dfda4
 gboolean       act_user_is_loaded                 (ActUser   *user);
7dfda4
 
7dfda4
 void           act_user_get_password_expiration_policy (ActUser   *user,
7dfda4
                                                         gint64    *expiration_time,
7dfda4
                                                         gint64    *last_change_time,
7dfda4
                                                         gint64    *min_days_between_changes,
7dfda4
                                                         gint64    *max_days_between_changes,
7dfda4
                                                         gint64    *days_to_warn,
7dfda4
                                                         gint64    *days_after_expiration_until_lock);
7dfda4
 
7dfda4
 void           act_user_set_email                 (ActUser    *user,
7dfda4
                                                    const char *email);
7dfda4
 void           act_user_set_language              (ActUser    *user,
7dfda4
                                                    const char *language);
7dfda4
 void           act_user_set_x_session             (ActUser    *user,
7dfda4
                                                    const char *x_session);
7dfda4
diff --git a/src/user.c b/src/user.c
7dfda4
index 94c0244..93afadc 100644
7dfda4
--- a/src/user.c
7dfda4
+++ b/src/user.c
7dfda4
@@ -284,60 +284,61 @@ user_update_from_keyfile (User     *user,
7dfda4
         }
7dfda4
 
7dfda4
         s = g_key_file_get_string (keyfile, "User", "Location", NULL);
7dfda4
         if (s != NULL) {
7dfda4
                 accounts_user_set_location (ACCOUNTS_USER (user), s);
7dfda4
                 g_clear_pointer (&s, g_free);
7dfda4
         }
7dfda4
 
7dfda4
         s = g_key_file_get_string (keyfile, "User", "PasswordHint", NULL);
7dfda4
         if (s != NULL) {
7dfda4
                 accounts_user_set_password_hint (ACCOUNTS_USER (user), s);
7dfda4
                 g_clear_pointer (&s, g_free);
7dfda4
         }
7dfda4
 
7dfda4
         s = g_key_file_get_string (keyfile, "User", "Icon", NULL);
7dfda4
         if (s != NULL) {
7dfda4
                 accounts_user_set_icon_file (ACCOUNTS_USER (user), s);
7dfda4
                 g_clear_pointer (&s, g_free);
7dfda4
         }
7dfda4
 
7dfda4
         if (g_key_file_has_key (keyfile, "User", "SystemAccount", NULL)) {
7dfda4
             gboolean system_account;
7dfda4
 
7dfda4
             system_account = g_key_file_get_boolean (keyfile, "User", "SystemAccount", NULL);
7dfda4
             accounts_user_set_system_account (ACCOUNTS_USER (user), system_account);
7dfda4
         }
7dfda4
 
7dfda4
         g_clear_pointer (&user->keyfile, g_key_file_unref);
7dfda4
         user->keyfile = g_key_file_ref (keyfile);
7dfda4
         user_set_cached (user, TRUE);
7dfda4
+        user_set_saved (user, TRUE);
7dfda4
 
7dfda4
         g_object_thaw_notify (G_OBJECT (user));
7dfda4
 }
7dfda4
 
7dfda4
 void
7dfda4
 user_update_local_account_property (User          *user,
7dfda4
                                     gboolean       local)
7dfda4
 {
7dfda4
         accounts_user_set_local_account (ACCOUNTS_USER (user), local);
7dfda4
 }
7dfda4
 
7dfda4
 void
7dfda4
 user_update_system_account_property (User          *user,
7dfda4
                                      gboolean       system)
7dfda4
 {
7dfda4
         accounts_user_set_system_account (ACCOUNTS_USER (user), system);
7dfda4
 }
7dfda4
 
7dfda4
 static void
7dfda4
 user_save_to_keyfile (User     *user,
7dfda4
                       GKeyFile *keyfile)
7dfda4
 {
7dfda4
         g_key_file_remove_group (keyfile, "User", NULL);
7dfda4
 
7dfda4
         if (accounts_user_get_email (ACCOUNTS_USER (user)))
7dfda4
                 g_key_file_set_string (keyfile, "User", "Email", accounts_user_get_email (ACCOUNTS_USER (user)));
7dfda4
 
7dfda4
         if (accounts_user_get_language (ACCOUNTS_USER (user)))
7dfda4
                 g_key_file_set_string (keyfile, "User", "Language", accounts_user_get_language (ACCOUNTS_USER (user)));
7dfda4
 
7dfda4
@@ -357,60 +358,62 @@ user_save_to_keyfile (User     *user,
7dfda4
                 g_key_file_set_string (keyfile, "User", "PasswordHint", accounts_user_get_password_hint (ACCOUNTS_USER (user)));
7dfda4
 
7dfda4
         if (accounts_user_get_icon_file (ACCOUNTS_USER (user)))
7dfda4
                 g_key_file_set_string (keyfile, "User", "Icon", accounts_user_get_icon_file (ACCOUNTS_USER (user)));
7dfda4
 
7dfda4
         g_key_file_set_boolean (keyfile, "User", "SystemAccount", accounts_user_get_system_account (ACCOUNTS_USER (user)));
7dfda4
 
7dfda4
         user_set_cached (user, TRUE);
7dfda4
 }
7dfda4
 
7dfda4
 static void
7dfda4
 save_extra_data (User *user)
7dfda4
 {
7dfda4
         g_autofree gchar *data = NULL;
7dfda4
         g_autofree gchar *filename = NULL;
7dfda4
         g_autoptr(GError) error = NULL;
7dfda4
 
7dfda4
         user_save_to_keyfile (user, user->keyfile);
7dfda4
 
7dfda4
         data = g_key_file_to_data (user->keyfile, NULL, &error);
7dfda4
         if (data == NULL) {
7dfda4
                 g_warning ("Saving data for user %s failed: %s",
7dfda4
                            accounts_user_get_user_name (ACCOUNTS_USER (user)), error->message);
7dfda4
                 return;
7dfda4
         }
7dfda4
 
7dfda4
         filename = g_build_filename (USERDIR,
7dfda4
                                      accounts_user_get_user_name (ACCOUNTS_USER (user)),
7dfda4
                                      NULL);
7dfda4
         g_file_set_contents (filename, data, -1, &error);
7dfda4
+
7dfda4
+        user_set_saved (user, TRUE);
7dfda4
 }
7dfda4
 
7dfda4
 static void
7dfda4
 move_extra_data (const gchar *old_name,
7dfda4
                  const gchar *new_name)
7dfda4
 {
7dfda4
         g_autofree gchar *old_filename = NULL;
7dfda4
         g_autofree gchar *new_filename = NULL;
7dfda4
 
7dfda4
         old_filename = g_build_filename (USERDIR,
7dfda4
                                          old_name, NULL);
7dfda4
         new_filename = g_build_filename (USERDIR,
7dfda4
                                          new_name, NULL);
7dfda4
 
7dfda4
         g_rename (old_filename, new_filename);
7dfda4
 }
7dfda4
 
7dfda4
 static GVariant *
7dfda4
 user_extension_get_value (User                    *user,
7dfda4
                           GDBusInterfaceInfo      *interface,
7dfda4
                           const GDBusPropertyInfo *property)
7dfda4
 {
7dfda4
         const GVariantType *type = G_VARIANT_TYPE (property->signature);
7dfda4
         GVariant *value;
7dfda4
         g_autofree gchar *printed = NULL;
7dfda4
         gint i;
7dfda4
 
7dfda4
         /* First, try to get the value from the keyfile */
7dfda4
         printed = g_key_file_get_value (user->keyfile, interface->name, property->name, NULL);
7dfda4
         if (printed) {
7dfda4
@@ -773,60 +776,67 @@ const gchar *
7dfda4
 user_get_object_path (User *user)
7dfda4
 {
7dfda4
         return g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (user));
7dfda4
 }
7dfda4
 
7dfda4
 uid_t
7dfda4
 user_get_uid (User *user)
7dfda4
 {
7dfda4
         return accounts_user_get_uid (ACCOUNTS_USER (user));
7dfda4
 }
7dfda4
 
7dfda4
 const gchar *
7dfda4
 user_get_shell(User *user)
7dfda4
 {
7dfda4
 	return accounts_user_get_shell (ACCOUNTS_USER (user));
7dfda4
 }
7dfda4
 
7dfda4
 gboolean
7dfda4
 user_get_cached (User *user)
7dfda4
 {
7dfda4
         return user->cached;
7dfda4
 }
7dfda4
 
7dfda4
 void
7dfda4
 user_set_cached (User     *user,
7dfda4
                  gboolean  cached)
7dfda4
 {
7dfda4
         user->cached = cached;
7dfda4
 }
7dfda4
 
7dfda4
+void
7dfda4
+user_set_saved (User     *user,
7dfda4
+                gboolean  saved)
7dfda4
+{
7dfda4
+        accounts_user_set_saved (ACCOUNTS_USER (user), saved);
7dfda4
+}
7dfda4
+
7dfda4
 static void
7dfda4
 throw_error (GDBusMethodInvocation *context,
7dfda4
              gint                   error_code,
7dfda4
              const gchar           *format,
7dfda4
              ...)
7dfda4
 {
7dfda4
         va_list args;
7dfda4
         g_autofree gchar *message = NULL;
7dfda4
 
7dfda4
         va_start (args, format);
7dfda4
         message = g_strdup_vprintf (format, args);
7dfda4
         va_end (args);
7dfda4
 
7dfda4
         g_dbus_method_invocation_return_error (context, ERROR, error_code, "%s", message);
7dfda4
 }
7dfda4
 
7dfda4
 static void
7dfda4
 user_change_real_name_authorized_cb (Daemon                *daemon,
7dfda4
                                      User                  *user,
7dfda4
                                      GDBusMethodInvocation *context,
7dfda4
                                      gpointer               data)
7dfda4
 
7dfda4
 {
7dfda4
         gchar *name = data;
7dfda4
         g_autoptr(GError) error = NULL;
7dfda4
         const gchar *argv[6];
7dfda4
 
7dfda4
         if (g_strcmp0 (accounts_user_get_real_name (ACCOUNTS_USER (user)), name) != 0) {
7dfda4
                 sys_log (context,
7dfda4
                          "change real name of user '%s' (%d) to '%s'",
7dfda4
diff --git a/src/user.h b/src/user.h
7dfda4
index 39c6f13..b3b3380 100644
7dfda4
--- a/src/user.h
7dfda4
+++ b/src/user.h
7dfda4
@@ -39,47 +39,49 @@ typedef enum {
7dfda4
         ACCOUNT_TYPE_STANDARD,
7dfda4
         ACCOUNT_TYPE_ADMINISTRATOR,
7dfda4
 #define ACCOUNT_TYPE_LAST ACCOUNT_TYPE_ADMINISTRATOR
7dfda4
 } AccountType;
7dfda4
 
7dfda4
 typedef enum {
7dfda4
         PASSWORD_MODE_REGULAR,
7dfda4
         PASSWORD_MODE_SET_AT_LOGIN,
7dfda4
         PASSWORD_MODE_NONE,
7dfda4
 #define PASSWORD_MODE_LAST PASSWORD_MODE_NONE
7dfda4
 } PasswordMode;
7dfda4
 
7dfda4
 /* local methods */
7dfda4
 
7dfda4
 GType          user_get_type                (void) G_GNUC_CONST;
7dfda4
 User *         user_new                     (Daemon        *daemon,
7dfda4
                                              uid_t          uid);
7dfda4
 
7dfda4
 void           user_update_from_pwent       (User          *user,
7dfda4
                                              struct passwd *pwent,
7dfda4
                                              struct spwd   *spent);
7dfda4
 void           user_update_from_keyfile     (User          *user,
7dfda4
                                              GKeyFile      *keyfile);
7dfda4
 void           user_update_local_account_property (User          *user,
7dfda4
                                                    gboolean       local);
7dfda4
 void           user_update_system_account_property (User          *user,
7dfda4
                                                     gboolean       system);
7dfda4
 gboolean       user_get_cached              (User          *user);
7dfda4
 void           user_set_cached              (User          *user,
7dfda4
                                              gboolean       cached);
7dfda4
+void           user_set_saved               (User          *user,
7dfda4
+                                             gboolean       saved);
7dfda4
 
7dfda4
 void           user_register                (User          *user);
7dfda4
 void           user_unregister              (User          *user);
7dfda4
 void           user_changed                 (User          *user);
7dfda4
 
7dfda4
 void           user_save                    (User          *user);
7dfda4
 
7dfda4
 const gchar *  user_get_user_name           (User          *user);
7dfda4
 gboolean       user_get_system_account      (User          *user);
7dfda4
 gboolean       user_get_local_account       (User          *user);
7dfda4
 const gchar *  user_get_object_path         (User          *user);
7dfda4
 uid_t          user_get_uid                 (User          *user);
7dfda4
 const gchar *  user_get_shell               (User          *user);
7dfda4
 
7dfda4
 G_END_DECLS
7dfda4
 
7dfda4
 #endif
7dfda4
-- 
7dfda4
2.17.1
7dfda4