Blame SOURCES/0001-lib-save-os-when-creating-user.patch

181da6
From 5124220f12a157ff285072a4f786db2c94c3ca8a Mon Sep 17 00:00:00 2001
ece282
From: Ray Strode <rstrode@redhat.com>
181da6
Date: Thu, 14 Jan 2021 15:07:34 -0500
ece282
Subject: [PATCH] lib: save os when creating user
ece282
ece282
In order to identify that a user has upgraded from rhel 7 to
ece282
rhel 8, we need to know what os they were using when created.
ece282
ece282
This commit saves that information using a red hat specific
ece282
extension to accountsservice.
ece282
---
ece282
 .../com.redhat.AccountsServiceUser.System.xml |  10 ++
181da6
 data/meson.build                              |   1 +
181da6
 meson.build                                   |   1 +
181da6
 meson_post_install.py                         |  15 +++
ece282
 src/libaccountsservice/act-user-manager.c     | 123 ++++++++++++++++++
181da6
 src/libaccountsservice/meson.build            |   7 +
181da6
 6 files changed, 157 insertions(+)
ece282
 create mode 100644 data/com.redhat.AccountsServiceUser.System.xml
ece282
ece282
diff --git a/data/com.redhat.AccountsServiceUser.System.xml b/data/com.redhat.AccountsServiceUser.System.xml
ece282
new file mode 100644
ece282
index 0000000..67f5f30
ece282
--- /dev/null
ece282
+++ b/data/com.redhat.AccountsServiceUser.System.xml
ece282
@@ -0,0 +1,10 @@
ece282
+<node>
ece282
+  <interface name="com.redhat.AccountsServiceUser.System">
ece282
+
ece282
+    <annotation name="org.freedesktop.Accounts.VendorExtension" value="true"/>
ece282
+
ece282
+    <property name="id" type="s" access="readwrite"/>
ece282
+    <property name="version-id" type="s" access="readwrite"/>
ece282
+
ece282
+  </interface>
ece282
+</node>
181da6
diff --git a/data/meson.build b/data/meson.build
181da6
index 4987937..2dc57c2 100644
181da6
--- a/data/meson.build
181da6
+++ b/data/meson.build
181da6
@@ -1,33 +1,34 @@
181da6
 ifaces = files(
181da6
   act_namespace + '.xml',
181da6
   act_namespace + '.User.xml',
181da6
+  'com.redhat.AccountsServiceUser.System.xml',
181da6
 )
181da6
 
181da6
 install_data(
181da6
   ifaces,
181da6
   install_dir: dbus_ifaces_dir,
181da6
 )
181da6
 
181da6
 install_data(
181da6
   act_namespace + '.conf',
181da6
   install_dir: dbus_conf_dir,
181da6
 )
181da6
 
181da6
 service_conf = configuration_data()
181da6
 service_conf.set('libexecdir', act_libexecdir)
181da6
 
181da6
 service = act_namespace + '.service'
181da6
 
181da6
 configure_file(
181da6
   input: service + '.in',
181da6
   output: service,
181da6
   configuration: service_conf,
181da6
   install: true,
181da6
   install_dir: dbus_sys_dir,
181da6
 )
181da6
 
181da6
 policy = act_namespace.to_lower() + '.policy'
181da6
 
181da6
 i18n.merge_file(
181da6
   policy,
181da6
   input: policy + '.in',
181da6
diff --git a/meson.build b/meson.build
181da6
index 4465a26..e37c451 100644
181da6
--- a/meson.build
181da6
+++ b/meson.build
181da6
@@ -174,38 +174,39 @@ assert(not enable_systemd or not enable_elogind, 'systemd and elogind support re
181da6
 if enable_systemd
181da6
   logind_dep = dependency('libsystemd', version: '>= 186')
181da6
 endif
181da6
 
181da6
 if enable_elogind
181da6
   logind_dep = dependency('libelogind', version: '>= 229.4')
181da6
 endif
181da6
 config_h.set('WITH_SYSTEMD', enable_systemd or enable_elogind)
181da6
 
181da6
 subdir('data')
181da6
 subdir('src')
181da6
 subdir('po')
181da6
 
181da6
 enable_docbook = get_option('docbook')
181da6
 if enable_docbook
181da6
   subdir('doc/dbus')
181da6
 endif
181da6
 
181da6
 if get_option('gtk_doc')
181da6
   subdir('doc/libaccountsservice')
181da6
 endif
181da6
 
181da6
 configure_file(
181da6
   output: 'config.h',
181da6
   configuration: config_h,
181da6
 )
181da6
 
181da6
 meson.add_install_script(
181da6
   'meson_post_install.py',
181da6
   act_localstatedir,
181da6
+  act_datadir,
181da6
 )
181da6
 
181da6
 output = '\n' + meson.project_name() + ' was configured with the following options:\n'
181da6
 output += '** DocBook documentation build: ' + enable_docbook.to_string() + '\n'
181da6
 output += '** Administrator group: ' + admin_group + '\n'
181da6
 output += '** Extra administrator groups: ' + extra_admin_groups + '\n'
181da6
 output += '** GDM configuration: ' + gdm_conf_file
181da6
 message(output)
181da6
diff --git a/meson_post_install.py b/meson_post_install.py
181da6
index 5cc2dc4..e1d5a71 100644
181da6
--- a/meson_post_install.py
181da6
+++ b/meson_post_install.py
181da6
@@ -1,18 +1,33 @@
181da6
 #!/usr/bin/env python3
181da6
 
181da6
 import os
181da6
 import sys
181da6
 
181da6
 destdir = os.environ.get('DESTDIR', '')
181da6
 localstatedir = os.path.normpath(destdir + os.sep + sys.argv[1])
181da6
+datadir = os.path.normpath(destdir + os.sep + sys.argv[2])
181da6
+interfacedir = os.path.join(datadir, 'accountsservice', 'interfaces')
181da6
 
181da6
 # FIXME: meson will not track the creation of these directories
181da6
 #        https://github.com/mesonbuild/meson/blob/master/mesonbuild/scripts/uninstall.py#L39
181da6
 dst_dirs = [
181da6
   (os.path.join(localstatedir, 'lib', 'AccountsService', 'icons'), 0o775),
181da6
   (os.path.join(localstatedir, 'lib', 'AccountsService', 'users'), 0o700),
181da6
+  (interfacedir, 0o775),
181da6
 ]
181da6
 
181da6
 for (dst_dir, dst_dir_mode) in dst_dirs:
181da6
   if not os.path.exists(dst_dir):
181da6
     os.makedirs(dst_dir, mode=dst_dir_mode)
181da6
+
181da6
+interface_files = [
181da6
+  'com.redhat.AccountsServiceUser.System.xml',
181da6
+]
181da6
+
181da6
+for interface_file in interface_files:
181da6
+    src_path = os.path.join('../../dbus-1/interfaces', interface_file)
181da6
+    dst_path = os.path.join(interfacedir, interface_file)
181da6
+    if not os.path.exists(dst_path):
181da6
+        os.symlink(src_path, dst_path)
181da6
+
181da6
+
ece282
diff --git a/src/libaccountsservice/act-user-manager.c b/src/libaccountsservice/act-user-manager.c
181da6
index 1b5298d..f4598c4 100644
ece282
--- a/src/libaccountsservice/act-user-manager.c
ece282
+++ b/src/libaccountsservice/act-user-manager.c
ece282
@@ -27,60 +27,61 @@
ece282
 #include <string.h>
ece282
 #include <signal.h>
ece282
 #include <errno.h>
ece282
 #include <sys stat.h="">
ece282
 #include <sys types.h="">
ece282
 
ece282
 #ifdef HAVE_PATHS_H
ece282
 #include <paths.h>
ece282
 #endif /* HAVE_PATHS_H */
ece282
 
ece282
 #include <glib.h>
ece282
 #include <glib gi18n-lib.h="">
ece282
 #include <glib gstdio.h="">
ece282
 #include <glib-object.h>
ece282
 #include <gio gio.h="">
ece282
 #include <gio gunixinputstream.h="">
ece282
 
ece282
 #ifdef WITH_SYSTEMD
ece282
 #include <systemd sd-login.h="">
ece282
 
ece282
 /* check if logind is running */
ece282
 #define LOGIND_RUNNING() (access("/run/systemd/seats/", F_OK) >= 0)
ece282
 #endif
ece282
 
ece282
 #include "act-user-manager.h"
ece282
 #include "act-user-private.h"
ece282
 #include "accounts-generated.h"
ece282
 #include "ck-manager-generated.h"
ece282
 #include "ck-seat-generated.h"
ece282
 #include "ck-session-generated.h"
ece282
+#include "com.redhat.AccountsServiceUser.System.h"
ece282
 
ece282
 /**
ece282
  * SECTION:act-user-manager
ece282
  * @title: ActUserManager
ece282
  * @short_description: manages ActUser objects
ece282
  *
ece282
  * ActUserManager is a manager object that gives access to user
ece282
  * creation, deletion, enumeration, etc.
ece282
  *
ece282
  * There is typically a singleton ActUserManager object, which
ece282
  * can be obtained by act_user_manager_get_default().
ece282
  */
ece282
 
ece282
 /**
ece282
  * ActUserManager:
ece282
  *
ece282
  * A user manager object.
ece282
  */
ece282
 
ece282
 /**
ece282
  * ACT_USER_MANAGER_ERROR:
ece282
  *
ece282
  * The GError domain for #ActUserManagerError errors
ece282
  */
ece282
 
ece282
 /**
ece282
  * ActUserManagerError:
ece282
  * @ACT_USER_MANAGER_ERROR_FAILED: Generic failure
ece282
  * @ACT_USER_MANAGER_ERROR_USER_EXISTS: The user already exists
ece282
  * @ACT_USER_MANAGER_ERROR_USER_DOES_NOT_EXIST: The user does not exist
181da6
@@ -165,60 +166,63 @@ typedef struct
ece282
         ActUser                    *user;
ece282
         ActUserManagerFetchUserRequestType type;
ece282
         union {
ece282
                 char               *username;
ece282
                 uid_t               uid;
ece282
         };
ece282
         char                       *object_path;
ece282
         char                       *description;
ece282
 } ActUserManagerFetchUserRequest;
ece282
 
181da6
 typedef struct
ece282
 {
ece282
         GHashTable            *normal_users_by_name;
ece282
         GHashTable            *system_users_by_name;
ece282
         GHashTable            *users_by_object_path;
ece282
         GHashTable            *sessions;
ece282
         GDBusConnection       *connection;
ece282
         AccountsAccounts      *accounts_proxy;
ece282
         ConsoleKitManager     *ck_manager_proxy;
ece282
 
ece282
         ActUserManagerSeat     seat;
ece282
 
ece282
         GSList                *new_sessions;
ece282
         GSList                *new_users;
ece282
         GSList                *new_users_inhibiting_load;
ece282
         GSList                *fetch_user_requests;
ece282
 
ece282
         GSList                *exclude_usernames;
ece282
         GSList                *include_usernames;
ece282
 
ece282
+        char                  *os_id;
ece282
+        char                  *os_version_id;
ece282
+
ece282
         guint                  load_id;
ece282
 
ece282
         gboolean               is_loaded;
ece282
         gboolean               has_multiple_users;
ece282
         gboolean               getting_sessions;
ece282
         gboolean               list_cached_users_done;
181da6
 } ActUserManagerPrivate;
ece282
 
ece282
 enum {
ece282
         PROP_0,
ece282
         PROP_INCLUDE_USERNAMES_LIST,
ece282
         PROP_EXCLUDE_USERNAMES_LIST,
ece282
         PROP_IS_LOADED,
ece282
         PROP_HAS_MULTIPLE_USERS
ece282
 };
ece282
 
ece282
 enum {
ece282
         USER_ADDED,
ece282
         USER_REMOVED,
ece282
         USER_IS_LOGGED_IN_CHANGED,
ece282
         USER_CHANGED,
ece282
         LAST_SIGNAL
ece282
 };
ece282
 
ece282
 static guint signals [LAST_SIGNAL] = { 0, };
ece282
 
ece282
 static void     act_user_manager_class_init (ActUserManagerClass *klass);
ece282
 static void     act_user_manager_init       (ActUserManager      *user_manager);
ece282
 static void     act_user_manager_finalize   (GObject             *object);
ece282
 
181da6
@@ -2942,100 +2946,173 @@ ensure_accounts_proxy (ActUserManager *manager)
181da6
                                                                  G_DBUS_PROXY_FLAGS_NONE,
181da6
                                                                  ACCOUNTS_NAME,
181da6
                                                                  ACCOUNTS_PATH,
181da6
                                                                  NULL,
181da6
                                                                  &error);
ece282
         if (error != NULL) {
ece282
                 g_debug ("ActUserManager: getting account proxy failed: %s", error->message);
ece282
                 return FALSE;
ece282
         }
ece282
 
181da6
         g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (priv->accounts_proxy), G_MAXINT);
ece282
 
181da6
         g_object_bind_property (G_OBJECT (priv->accounts_proxy),
ece282
                                 "has-multiple-users",
ece282
                                 G_OBJECT (manager),
ece282
                                 "has-multiple-users",
ece282
                                 G_BINDING_SYNC_CREATE);
ece282
 
181da6
         g_signal_connect (priv->accounts_proxy,
ece282
                           "user-added",
ece282
                           G_CALLBACK (on_new_user_in_accounts_service),
ece282
                           manager);
181da6
         g_signal_connect (priv->accounts_proxy,
ece282
                           "user-deleted",
ece282
                           G_CALLBACK (on_user_removed_in_accounts_service),
ece282
                           manager);
ece282
 
ece282
         return TRUE;
ece282
 }
ece282
 
ece282
+static inline gboolean
ece282
+is_valid_char (gchar    c,
ece282
+               gboolean first)
ece282
+{
ece282
+        return (!first && g_ascii_isdigit (c)) ||
ece282
+                c == '_' ||
ece282
+                g_ascii_isalpha (c);
ece282
+}
ece282
+
ece282
+static void
ece282
+load_os_release (ActUserManager *manager)
ece282
+{
181da6
+        ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
ece282
+        g_autoptr(GFile) file = NULL;
ece282
+        g_autoptr(GError) error = NULL;
ece282
+        g_autofree char *contents = NULL;
ece282
+        g_auto(GStrv) lines = NULL;
ece282
+        size_t i;
ece282
+
ece282
+        file = g_file_new_for_path ("/etc/os-release");
ece282
+
ece282
+        if (!g_file_load_contents (file, NULL, &contents, NULL, NULL, &error)) {
ece282
+                g_debug ("ActUserManager: couldn't load /etc/os-release: %s", error->message);
ece282
+                return;
ece282
+        }
ece282
+
ece282
+        lines = g_strsplit (contents, "\n", -1);
ece282
+        for (i = 0; lines[i] != NULL; i++) {
ece282
+                char *p, *name, *name_end, *value, *value_end;
ece282
+
ece282
+                p = lines[i];
ece282
+
ece282
+                while (g_ascii_isspace (*p))
ece282
+                        p++;
ece282
+
ece282
+                if (*p == '#' || *p == '\0')
ece282
+                        continue;
ece282
+                name = p;
ece282
+                while (is_valid_char (*p, p == name))
ece282
+                        p++;
ece282
+                name_end = p;
ece282
+                while (g_ascii_isspace (*p))
ece282
+                        p++;
ece282
+                if (name == name_end || *p != '=') {
ece282
+                        continue;
ece282
+                }
ece282
+                *name_end = '\0';
ece282
+
ece282
+                p++;
ece282
+
ece282
+                while (g_ascii_isspace (*p))
ece282
+                        p++;
ece282
+
ece282
+                value = p;
ece282
+                value_end = value + strlen (value) - 1;
ece282
+
ece282
+                if (value != value_end && *value == '"' && *value_end == '"') {
ece282
+                        value++;
ece282
+                        *value_end = '\0';
ece282
+                }
ece282
+
ece282
+                if (strcmp (name, "ID") == 0) {
ece282
+                        g_debug ("ActUserManager: system OS is '%s'", value);
ece282
+                        priv->os_id = g_strdup (value);
ece282
+                } else if (strcmp (name, "VERSION_ID") == 0) {
ece282
+                        g_debug ("ActUserManager: system OS version is '%s'", value);
ece282
+                        priv->os_version_id = g_strdup (value);
ece282
+                }
ece282
+        }
ece282
+}
ece282
+
ece282
 static void
ece282
 act_user_manager_init (ActUserManager *manager)
ece282
 {
181da6
         ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
ece282
         g_autoptr(GError) error = NULL;
ece282
 
ece282
         act_user_manager_error_quark (); /* register dbus errors */
ece282
 
ece282
         /* sessions */
181da6
         priv->sessions = g_hash_table_new_full (g_str_hash,
181da6
                                                 g_str_equal,
181da6
                                                 g_free,
181da6
                                                 g_object_unref);
ece282
 
ece282
         /* users */
181da6
         priv->normal_users_by_name = g_hash_table_new_full (g_str_hash,
181da6
                                                             g_str_equal,
181da6
                                                             g_free,
181da6
                                                             g_object_unref);
181da6
         priv->system_users_by_name = g_hash_table_new_full (g_str_hash,
181da6
                                                             g_str_equal,
181da6
                                                             g_free,
181da6
                                                             g_object_unref);
181da6
         priv->users_by_object_path = g_hash_table_new_full (g_str_hash,
181da6
                                                             g_str_equal,
181da6
                                                             NULL,
181da6
                                                             g_object_unref);
181da6
 
181da6
         priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
181da6
         if (priv->connection == NULL) {
ece282
                 if (error != NULL) {
ece282
                         g_warning ("Failed to connect to the D-Bus daemon: %s", error->message);
ece282
                 } else {
ece282
                         g_warning ("Failed to connect to the D-Bus daemon");
ece282
                 }
ece282
                 return;
ece282
         }
ece282
 
ece282
         ensure_accounts_proxy (manager);
ece282
 
ece282
+        load_os_release (manager);
ece282
+
181da6
         priv->seat.state = ACT_USER_MANAGER_SEAT_STATE_UNLOADED;
ece282
 }
ece282
 
ece282
 static void
ece282
 act_user_manager_finalize (GObject *object)
ece282
 {
181da6
         ActUserManager *manager = ACT_USER_MANAGER (object);
181da6
         ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
ece282
         GSList         *node;
ece282
 
ece282
         g_debug ("ActUserManager: finalizing user manager");
ece282
 
181da6
         g_slist_foreach (priv->new_sessions,
ece282
                          (GFunc) unload_new_session, NULL);
181da6
         g_slist_free (priv->new_sessions);
ece282
 
181da6
         g_slist_foreach (priv->fetch_user_requests,
ece282
                          (GFunc) free_fetch_user_request, NULL);
181da6
         g_slist_free (priv->fetch_user_requests);
ece282
 
181da6
         g_slist_free (priv->new_users_inhibiting_load);
ece282
 
181da6
         node = priv->new_users;
ece282
         while (node != NULL) {
181da6
                 ActUser *user;
181da6
                 GSList  *next_node;
181da6
 
181da6
                 user = ACT_USER (node->data);
181da6
                 next_node = node->next;
181da6
 
181da6
@@ -3071,143 +3148,181 @@ act_user_manager_finalize (GObject *object)
ece282
 
ece282
 #ifdef WITH_SYSTEMD
181da6
         if (priv->seat.session_monitor != NULL) {
181da6
                 sd_login_monitor_unref (priv->seat.session_monitor);
ece282
         }
ece282
 
181da6
         if (priv->seat.session_monitor_stream != NULL) {
181da6
                 g_object_unref (priv->seat.session_monitor_stream);
ece282
         }
ece282
 
181da6
         if (priv->seat.session_monitor_source_id != 0) {
181da6
                 g_source_remove (priv->seat.session_monitor_source_id);
ece282
         }
ece282
 #endif
ece282
 
181da6
         if (priv->accounts_proxy != NULL) {
181da6
                 g_object_unref (priv->accounts_proxy);
ece282
         }
ece282
 
181da6
         if (priv->load_id > 0) {
181da6
                 g_source_remove (priv->load_id);
181da6
                 priv->load_id = 0;
ece282
         }
ece282
 
181da6
         g_hash_table_destroy (priv->sessions);
ece282
 
181da6
         g_hash_table_destroy (priv->normal_users_by_name);
181da6
         g_hash_table_destroy (priv->system_users_by_name);
181da6
         g_hash_table_destroy (priv->users_by_object_path);
ece282
 
181da6
+        g_free (priv->os_id);
181da6
+        g_free (priv->os_version_id);
ece282
+
ece282
         G_OBJECT_CLASS (act_user_manager_parent_class)->finalize (object);
ece282
 }
ece282
 
ece282
 /**
ece282
  * act_user_manager_get_default:
ece282
  *
ece282
  * Returns the user manager singleton instance.  Calling this function will
ece282
  * automatically being loading the user list if it isn't loaded already.
ece282
  * The #ActUserManager:is-loaded property will be set to %TRUE when the users
ece282
  * are finished loading and then act_user_manager_list_users() can be called.
ece282
  *
ece282
  * Returns: (transfer none): user manager object
ece282
  */
ece282
 ActUserManager *
ece282
 act_user_manager_get_default (void)
ece282
 {
ece282
         if (user_manager_object == NULL) {
ece282
                 user_manager_object = g_object_new (ACT_TYPE_USER_MANAGER, NULL);
ece282
                 g_object_add_weak_pointer (user_manager_object,
ece282
                                            (gpointer *) &user_manager_object);
ece282
                 act_user_manager_queue_load (user_manager_object);
ece282
         }
ece282
 
ece282
         return ACT_USER_MANAGER (user_manager_object);
ece282
 }
ece282
 
ece282
 /**
ece282
  * act_user_manager_no_service:
ece282
  * @manager: a #ActUserManager
ece282
  *
ece282
  * Check whether or not the accounts service is running.
ece282
  *
ece282
  * Returns: whether or not accounts service is running
ece282
  */
ece282
 gboolean
ece282
 act_user_manager_no_service (ActUserManager *manager)
ece282
 {
181da6
         ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
181da6
         return priv->accounts_proxy == NULL;
ece282
 }
ece282
 
ece282
+static void
ece282
+save_system_info (ActUserManager *manager,
ece282
+                  const char     *user_path)
ece282
+{
181da6
+        ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
ece282
+        ActUserSystem *user_system_proxy = NULL;
ece282
+        g_autoptr(GError) error = NULL;
ece282
+
ece282
+        if (priv->os_id == NULL && priv->os_version_id == NULL)
ece282
+                return;
ece282
+
ece282
+        user_system_proxy = act_user_system_proxy_new_sync (priv->connection,
ece282
+                                                            G_DBUS_PROXY_FLAGS_NONE,
ece282
+                                                            ACCOUNTS_NAME,
ece282
+                                                            user_path,
ece282
+                                                            NULL,
ece282
+                                                            &error);
ece282
+        if (user_system_proxy != NULL) {
ece282
+                if (priv->os_id != NULL)
ece282
+                        act_user_system_set_id (user_system_proxy, priv->os_id);
ece282
+
ece282
+                if (priv->os_version_id != NULL)
ece282
+                        act_user_system_set_version_id (user_system_proxy, priv->os_version_id);
ece282
+        } else {
ece282
+                /* probably means accountsservice and lib are out of sync */
ece282
+                g_debug ("ActUserManager: failed to create user system proxy: %s",
ece282
+                         error? error->message: "");
ece282
+                g_clear_error (&error);
ece282
+        }
ece282
+
ece282
+        g_clear_object (&user_system_proxy);
ece282
+}
ece282
+
ece282
 /**
ece282
  * act_user_manager_create_user:
ece282
  * @manager: a #ActUserManager
ece282
  * @username: a unix user name
ece282
  * @fullname: a unix GECOS value
ece282
  * @accounttype: a #ActUserAccountType
ece282
  * @error: a #GError
ece282
  *
ece282
  * Creates a user account on the system.
ece282
  *
ece282
  * Returns: (transfer full): user object
ece282
  */
ece282
 ActUser *
ece282
 act_user_manager_create_user (ActUserManager      *manager,
ece282
                               const char          *username,
ece282
                               const char          *fullname,
ece282
                               ActUserAccountType   accounttype,
ece282
                               GError             **error)
ece282
 {
181da6
         ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
ece282
         GError *local_error = NULL;
ece282
         gboolean res;
ece282
         g_autofree gchar *path = NULL;
ece282
         ActUser *user;
ece282
 
ece282
         g_debug ("ActUserManager: Creating user '%s', '%s', %d",
ece282
                  username, fullname, accounttype);
ece282
 
181da6
         g_assert (priv->accounts_proxy != NULL);
ece282
 
181da6
         res = accounts_accounts_call_create_user_sync (priv->accounts_proxy,
ece282
                                                        username,
ece282
                                                        fullname,
ece282
                                                        accounttype,
ece282
                                                        &path,
ece282
                                                        NULL,
ece282
                                                        &local_error);
ece282
         if (!res) {
ece282
                 g_propagate_error (error, local_error);
ece282
                 return NULL;
ece282
         }
ece282
 
ece282
+        save_system_info (manager, path);
ece282
+
ece282
         user = add_new_user_for_object_path (path, manager);
ece282
 
ece282
         return user;
ece282
 }
ece282
 
ece282
 static void
ece282
 act_user_manager_async_complete_handler (GObject      *source,
ece282
                                          GAsyncResult *result,
ece282
                                          gpointer      user_data)
ece282
 {
ece282
         GTask *task = user_data;
ece282
 
ece282
         g_task_return_pointer (task, g_object_ref (result), g_object_unref);
ece282
         g_object_unref (task);
ece282
 }
ece282
 
ece282
 /**
ece282
  * act_user_manager_create_user_async:
ece282
  * @manager: a #ActUserManager
ece282
  * @username: a unix user name
ece282
  * @fullname: a unix GECOS value
ece282
  * @accounttype: a #ActUserAccountType
ece282
  * @cancellable: (allow-none): optional #GCancellable object,
ece282
  *     %NULL to ignore
ece282
  * @callback: (scope async): a #GAsyncReadyCallback to call
ece282
  *     when the request is satisfied
ece282
  * @user_data: (closure): the data to pass to @callback
ece282
  *
ece282
  * Asynchronously creates a user account on the system.
ece282
  *
181da6
@@ -3253,106 +3368,111 @@ act_user_manager_create_user_async (ActUserManager      *manager,
ece282
  * @manager: a #ActUserManager
ece282
  * @result: a #GAsyncResult
ece282
  * @error: a #GError
ece282
  *
ece282
  * Finishes an asynchronous user creation.
ece282
  *
ece282
  * See act_user_manager_create_user_async().
ece282
  *
ece282
  * Returns: (transfer full): user object
ece282
  *
ece282
  * Since: 0.6.27
ece282
  */
ece282
 ActUser *
ece282
 act_user_manager_create_user_finish (ActUserManager  *manager,
ece282
                                      GAsyncResult    *result,
ece282
                                      GError         **error)
ece282
 {
181da6
         ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
ece282
         GAsyncResult *inner_result;
ece282
         ActUser *user = NULL;
ece282
         g_autofree gchar *path = NULL;
ece282
         GError *remote_error = NULL;
ece282
 
ece282
         inner_result = g_task_propagate_pointer (G_TASK (result), error);
ece282
         if (inner_result == NULL) {
ece282
                 return FALSE;
ece282
         }
ece282
 
181da6
         if (accounts_accounts_call_create_user_finish (priv->accounts_proxy,
ece282
                                                        &path, inner_result, &remote_error)) {
ece282
+
ece282
+                save_system_info (manager, path);
ece282
+
ece282
                 user = add_new_user_for_object_path (path, manager);
ece282
         }
ece282
 
ece282
         if (remote_error) {
ece282
                 g_dbus_error_strip_remote_error (remote_error);
ece282
                 g_propagate_error (error, remote_error);
ece282
         }
ece282
 
ece282
         return user;
ece282
 }
ece282
 
ece282
 /**
ece282
  * act_user_manager_cache_user:
ece282
  * @manager: a #ActUserManager
ece282
  * @username: a user name
ece282
  * @error: a #GError
ece282
  *
ece282
  * Caches a user account so it shows up via act_user_manager_list_users().
ece282
  *
ece282
  * Returns: (transfer full): user object
ece282
  */
ece282
 ActUser *
ece282
 act_user_manager_cache_user (ActUserManager     *manager,
ece282
                              const char         *username,
ece282
                              GError            **error)
ece282
 {
181da6
         ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
ece282
         GError *local_error = NULL;
ece282
         gboolean res;
ece282
         g_autofree gchar *path = NULL;
ece282
 
ece282
         g_debug ("ActUserManager: Caching user '%s'",
ece282
                  username);
ece282
 
181da6
         g_assert (priv->accounts_proxy != NULL);
ece282
 
181da6
         res = accounts_accounts_call_cache_user_sync (priv->accounts_proxy,
ece282
                                                       username,
ece282
                                                       &path,
ece282
                                                       NULL,
ece282
                                                       &local_error);
ece282
         if (!res) {
ece282
                 g_propagate_error (error, local_error);
ece282
                 return NULL;
ece282
         }
ece282
 
ece282
+        save_system_info (manager, path);
ece282
+
ece282
         return add_new_user_for_object_path (path, manager);
ece282
 }
ece282
 
ece282
 
ece282
 /**
ece282
  * act_user_manager_cache_user_async:
ece282
  * @manager: a #ActUserManager
ece282
  * @username: a unix user name
ece282
  * @cancellable: (allow-none): optional #GCancellable object,
ece282
  *     %NULL to ignore
ece282
  * @callback: (scope async): a #GAsyncReadyCallback to call
ece282
  *     when the request is satisfied
ece282
  * @user_data: (closure): the data to pass to @callback
ece282
  *
ece282
  * Asynchronously caches a user account so it shows up via
ece282
  * act_user_manager_list_users().
ece282
  *
ece282
  * For more details, see act_user_manager_cache_user(), which
ece282
  * is the synchronous version of this call.
ece282
  *
ece282
  * Since: 0.6.27
ece282
  */
ece282
 void
ece282
 act_user_manager_cache_user_async (ActUserManager      *manager,
ece282
                                    const char          *username,
ece282
                                    GCancellable        *cancellable,
ece282
                                    GAsyncReadyCallback  callback,
ece282
                                    gpointer             user_data)
ece282
 {
181da6
         ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
181da6
@@ -3378,60 +3498,63 @@ act_user_manager_cache_user_async (ActUserManager      *manager,
ece282
  * @manager: a #ActUserManager
ece282
  * @result: a #GAsyncResult
ece282
  * @error: a #GError
ece282
  *
ece282
  * Finishes an asynchronous user caching.
ece282
  *
ece282
  * See act_user_manager_cache_user_async().
ece282
  *
ece282
  * Returns: (transfer full): user object
ece282
  *
ece282
  * Since: 0.6.27
ece282
  */
ece282
 ActUser *
ece282
 act_user_manager_cache_user_finish (ActUserManager  *manager,
ece282
                                     GAsyncResult    *result,
ece282
                                     GError         **error)
ece282
 {
181da6
         ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
ece282
         GAsyncResult *inner_result;
ece282
         ActUser *user = NULL;
ece282
         g_autofree gchar *path = NULL;
ece282
         GError *remote_error = NULL;
ece282
 
ece282
         inner_result = g_task_propagate_pointer (G_TASK (result), error);
ece282
         if (inner_result == NULL) {
ece282
                 return FALSE;
ece282
         }
ece282
 
181da6
         if (accounts_accounts_call_cache_user_finish (priv->accounts_proxy,
ece282
                                                       &path, inner_result, &remote_error)) {
ece282
+
ece282
+                save_system_info (manager, path);
ece282
+
ece282
                 user = add_new_user_for_object_path (path, manager);
ece282
         }
ece282
 
ece282
         if (remote_error) {
ece282
                 g_dbus_error_strip_remote_error (remote_error);
ece282
                 g_propagate_error (error, remote_error);
ece282
         }
ece282
 
ece282
         return user;
ece282
 }
ece282
 
ece282
 /**
ece282
  * act_user_manager_uncache_user:
ece282
  * @manager: a #ActUserManager
ece282
  * @username: a user name
ece282
  * @error: a #GError
ece282
  *
ece282
  * Releases all metadata about a user account, including icon,
ece282
  * language and session. If the user account is from a remote
ece282
  * server and the user has never logged in before, then that
ece282
  * account will no longer show up in ListCachedUsers() output.
ece282
  *
ece282
  * Returns: %TRUE if successful, otherwise %FALSE
ece282
  */
ece282
 gboolean
ece282
 act_user_manager_uncache_user (ActUserManager     *manager,
ece282
                                const char         *username,
ece282
                                GError            **error)
ece282
 {
181da6
         ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
181da6
diff --git a/src/libaccountsservice/meson.build b/src/libaccountsservice/meson.build
181da6
index 4e134db..9e85bba 100644
181da6
--- a/src/libaccountsservice/meson.build
181da6
+++ b/src/libaccountsservice/meson.build
181da6
@@ -21,60 +21,67 @@ enum_types = 'act-user-enum-types'
181da6
 
181da6
 enum_sources = gnome.mkenums(
181da6
   enum_types,
181da6
   sources: headers,
181da6
   c_template: enum_types + '.c.template',
181da6
   h_template: enum_types + '.h.template',
181da6
   install_header: true,
181da6
   install_dir: join_paths(act_pkgincludedir, subdir),
181da6
 )
181da6
 
181da6
 dbus_sources = []
181da6
 
181da6
 ifaces = [
181da6
   'Manager',
181da6
   'Seat',
181da6
   'Session',
181da6
 ]
181da6
 
181da6
 namespace = 'ConsoleKit'
181da6
 prefix = 'org.freedesktop.' + namespace
181da6
 
181da6
 foreach iface: ifaces
181da6
   dbus_sources += gnome.gdbus_codegen(
181da6
     'ck-@0@-generated'.format(iface.to_lower()),
181da6
     '@0@.@1@.xml'.format(prefix, iface),
181da6
     interface_prefix: prefix,
181da6
     namespace: namespace,
181da6
   )
181da6
 endforeach
181da6
 
181da6
+dbus_sources += gnome.gdbus_codegen(
181da6
+   'com.redhat.AccountsServiceUser.System',
181da6
+   join_paths(data_dir, 'com.redhat.AccountsServiceUser.System.xml'),
181da6
+   interface_prefix: 'com.redhat.AccountsService',
181da6
+   namespace: 'Act',
181da6
+)
181da6
+
181da6
 deps = [
181da6
   crypt_dep,
181da6
   gio_unix_dep,
181da6
   glib_dep,
181da6
   libaccounts_generated_dep,
181da6
 ]
181da6
 
181da6
 symbol_map = join_paths(meson.current_source_dir(), 'symbol.map')
181da6
 ldflags = cc.get_supported_link_arguments('-Wl,--version-script,@0@'.format(symbol_map))
181da6
 
181da6
 if enable_systemd or enable_elogind
181da6
   deps += logind_dep
181da6
 endif
181da6
 
181da6
 libaccountsservice = shared_library(
181da6
   act_name,
181da6
   sources: sources + enum_sources + dbus_sources,
181da6
   version: libversion,
181da6
   include_directories: top_inc,
181da6
   dependencies: deps,
181da6
   c_args: '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name()),
181da6
   link_args: ldflags,
181da6
   link_depends: symbol_map,
181da6
   install: true,
181da6
 )
181da6
 
181da6
 libaccountsservice_dep = declare_dependency(
181da6
   sources: enum_sources[1],
181da6
   include_directories: include_directories('.'),
181da6
   dependencies: [gio_dep, glib_dep],
ece282
-- 
181da6
2.27.0
ece282