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

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