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

0c7e6b
From 5124220f12a157ff285072a4f786db2c94c3ca8a Mon Sep 17 00:00:00 2001
ece282
From: Ray Strode <rstrode@redhat.com>
0c7e6b
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 ++
0c7e6b
 data/meson.build                              |   1 +
0c7e6b
 meson.build                                   |   1 +
0c7e6b
 meson_post_install.py                         |  15 +++
ece282
 src/libaccountsservice/act-user-manager.c     | 123 ++++++++++++++++++
0c7e6b
 src/libaccountsservice/meson.build            |   7 +
0c7e6b
 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>
0c7e6b
diff --git a/data/meson.build b/data/meson.build
0c7e6b
index 4987937..2dc57c2 100644
0c7e6b
--- a/data/meson.build
0c7e6b
+++ b/data/meson.build
0c7e6b
@@ -1,33 +1,34 @@
0c7e6b
 ifaces = files(
0c7e6b
   act_namespace + '.xml',
0c7e6b
   act_namespace + '.User.xml',
0c7e6b
+  'com.redhat.AccountsServiceUser.System.xml',
0c7e6b
 )
0c7e6b
 
0c7e6b
 install_data(
0c7e6b
   ifaces,
0c7e6b
   install_dir: dbus_ifaces_dir,
0c7e6b
 )
0c7e6b
 
0c7e6b
 install_data(
0c7e6b
   act_namespace + '.conf',
0c7e6b
   install_dir: dbus_conf_dir,
0c7e6b
 )
0c7e6b
 
0c7e6b
 service_conf = configuration_data()
0c7e6b
 service_conf.set('libexecdir', act_libexecdir)
0c7e6b
 
0c7e6b
 service = act_namespace + '.service'
0c7e6b
 
0c7e6b
 configure_file(
0c7e6b
   input: service + '.in',
0c7e6b
   output: service,
0c7e6b
   configuration: service_conf,
0c7e6b
   install: true,
0c7e6b
   install_dir: dbus_sys_dir,
0c7e6b
 )
0c7e6b
 
0c7e6b
 policy = act_namespace.to_lower() + '.policy'
0c7e6b
 
0c7e6b
 i18n.merge_file(
0c7e6b
   policy,
0c7e6b
   input: policy + '.in',
0c7e6b
diff --git a/meson.build b/meson.build
0c7e6b
index 4465a26..e37c451 100644
0c7e6b
--- a/meson.build
0c7e6b
+++ b/meson.build
0c7e6b
@@ -174,38 +174,39 @@ assert(not enable_systemd or not enable_elogind, 'systemd and elogind support re
0c7e6b
 if enable_systemd
0c7e6b
   logind_dep = dependency('libsystemd', version: '>= 186')
0c7e6b
 endif
0c7e6b
 
0c7e6b
 if enable_elogind
0c7e6b
   logind_dep = dependency('libelogind', version: '>= 229.4')
0c7e6b
 endif
0c7e6b
 config_h.set('WITH_SYSTEMD', enable_systemd or enable_elogind)
0c7e6b
 
0c7e6b
 subdir('data')
0c7e6b
 subdir('src')
0c7e6b
 subdir('po')
0c7e6b
 
0c7e6b
 enable_docbook = get_option('docbook')
0c7e6b
 if enable_docbook
0c7e6b
   subdir('doc/dbus')
0c7e6b
 endif
0c7e6b
 
0c7e6b
 if get_option('gtk_doc')
0c7e6b
   subdir('doc/libaccountsservice')
0c7e6b
 endif
0c7e6b
 
0c7e6b
 configure_file(
0c7e6b
   output: 'config.h',
0c7e6b
   configuration: config_h,
0c7e6b
 )
0c7e6b
 
0c7e6b
 meson.add_install_script(
0c7e6b
   'meson_post_install.py',
0c7e6b
   act_localstatedir,
0c7e6b
+  act_datadir,
0c7e6b
 )
0c7e6b
 
0c7e6b
 output = '\n' + meson.project_name() + ' was configured with the following options:\n'
0c7e6b
 output += '** DocBook documentation build: ' + enable_docbook.to_string() + '\n'
0c7e6b
 output += '** Administrator group: ' + admin_group + '\n'
0c7e6b
 output += '** Extra administrator groups: ' + extra_admin_groups + '\n'
0c7e6b
 output += '** GDM configuration: ' + gdm_conf_file
0c7e6b
 message(output)
0c7e6b
diff --git a/meson_post_install.py b/meson_post_install.py
0c7e6b
index 5cc2dc4..e1d5a71 100644
0c7e6b
--- a/meson_post_install.py
0c7e6b
+++ b/meson_post_install.py
0c7e6b
@@ -1,18 +1,33 @@
0c7e6b
 #!/usr/bin/env python3
0c7e6b
 
0c7e6b
 import os
0c7e6b
 import sys
0c7e6b
 
0c7e6b
 destdir = os.environ.get('DESTDIR', '')
0c7e6b
 localstatedir = os.path.normpath(destdir + os.sep + sys.argv[1])
0c7e6b
+datadir = os.path.normpath(destdir + os.sep + sys.argv[2])
0c7e6b
+interfacedir = os.path.join(datadir, 'accountsservice', 'interfaces')
0c7e6b
 
0c7e6b
 # FIXME: meson will not track the creation of these directories
0c7e6b
 #        https://github.com/mesonbuild/meson/blob/master/mesonbuild/scripts/uninstall.py#L39
0c7e6b
 dst_dirs = [
0c7e6b
   (os.path.join(localstatedir, 'lib', 'AccountsService', 'icons'), 0o775),
0c7e6b
   (os.path.join(localstatedir, 'lib', 'AccountsService', 'users'), 0o700),
0c7e6b
+  (interfacedir, 0o775),
0c7e6b
 ]
0c7e6b
 
0c7e6b
 for (dst_dir, dst_dir_mode) in dst_dirs:
0c7e6b
   if not os.path.exists(dst_dir):
0c7e6b
     os.makedirs(dst_dir, mode=dst_dir_mode)
0c7e6b
+
0c7e6b
+interface_files = [
0c7e6b
+  'com.redhat.AccountsServiceUser.System.xml',
0c7e6b
+]
0c7e6b
+
0c7e6b
+for interface_file in interface_files:
0c7e6b
+    src_path = os.path.join('../../dbus-1/interfaces', interface_file)
0c7e6b
+    dst_path = os.path.join(interfacedir, interface_file)
0c7e6b
+    if not os.path.exists(dst_path):
0c7e6b
+        os.symlink(src_path, dst_path)
0c7e6b
+
0c7e6b
+
ece282
diff --git a/src/libaccountsservice/act-user-manager.c b/src/libaccountsservice/act-user-manager.c
0c7e6b
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
0c7e6b
@@ -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
 
0c7e6b
 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;
0c7e6b
 } 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
 
0c7e6b
@@ -2942,100 +2946,173 @@ ensure_accounts_proxy (ActUserManager *manager)
0c7e6b
                                                                  G_DBUS_PROXY_FLAGS_NONE,
0c7e6b
                                                                  ACCOUNTS_NAME,
0c7e6b
                                                                  ACCOUNTS_PATH,
0c7e6b
                                                                  NULL,
0c7e6b
                                                                  &error);
ece282
         if (error != NULL) {
ece282
                 g_debug ("ActUserManager: getting account proxy failed: %s", error->message);
ece282
                 return FALSE;
ece282
         }
ece282
 
0c7e6b
         g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (priv->accounts_proxy), G_MAXINT);
ece282
 
0c7e6b
         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
 
0c7e6b
         g_signal_connect (priv->accounts_proxy,
ece282
                           "user-added",
ece282
                           G_CALLBACK (on_new_user_in_accounts_service),
ece282
                           manager);
0c7e6b
         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
+{
0c7e6b
+        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
 {
0c7e6b
         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 */
0c7e6b
         priv->sessions = g_hash_table_new_full (g_str_hash,
0c7e6b
                                                 g_str_equal,
0c7e6b
                                                 g_free,
0c7e6b
                                                 g_object_unref);
ece282
 
ece282
         /* users */
0c7e6b
         priv->normal_users_by_name = g_hash_table_new_full (g_str_hash,
0c7e6b
                                                             g_str_equal,
0c7e6b
                                                             g_free,
0c7e6b
                                                             g_object_unref);
0c7e6b
         priv->system_users_by_name = g_hash_table_new_full (g_str_hash,
0c7e6b
                                                             g_str_equal,
0c7e6b
                                                             g_free,
0c7e6b
                                                             g_object_unref);
0c7e6b
         priv->users_by_object_path = g_hash_table_new_full (g_str_hash,
0c7e6b
                                                             g_str_equal,
0c7e6b
                                                             NULL,
0c7e6b
                                                             g_object_unref);
0c7e6b
 
0c7e6b
         priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
0c7e6b
         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
+
0c7e6b
         priv->seat.state = ACT_USER_MANAGER_SEAT_STATE_UNLOADED;
ece282
 }
ece282
 
ece282
 static void
ece282
 act_user_manager_finalize (GObject *object)
ece282
 {
0c7e6b
         ActUserManager *manager = ACT_USER_MANAGER (object);
0c7e6b
         ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
ece282
         GSList         *node;
ece282
 
ece282
         g_debug ("ActUserManager: finalizing user manager");
ece282
 
0c7e6b
         g_slist_foreach (priv->new_sessions,
ece282
                          (GFunc) unload_new_session, NULL);
0c7e6b
         g_slist_free (priv->new_sessions);
ece282
 
0c7e6b
         g_slist_foreach (priv->fetch_user_requests,
ece282
                          (GFunc) free_fetch_user_request, NULL);
0c7e6b
         g_slist_free (priv->fetch_user_requests);
ece282
 
0c7e6b
         g_slist_free (priv->new_users_inhibiting_load);
ece282
 
0c7e6b
         node = priv->new_users;
ece282
         while (node != NULL) {
0c7e6b
                 ActUser *user;
0c7e6b
                 GSList  *next_node;
0c7e6b
 
0c7e6b
                 user = ACT_USER (node->data);
0c7e6b
                 next_node = node->next;
0c7e6b
 
0c7e6b
@@ -3071,143 +3148,181 @@ act_user_manager_finalize (GObject *object)
ece282
 
ece282
 #ifdef WITH_SYSTEMD
0c7e6b
         if (priv->seat.session_monitor != NULL) {
0c7e6b
                 sd_login_monitor_unref (priv->seat.session_monitor);
ece282
         }
ece282
 
0c7e6b
         if (priv->seat.session_monitor_stream != NULL) {
0c7e6b
                 g_object_unref (priv->seat.session_monitor_stream);
ece282
         }
ece282
 
0c7e6b
         if (priv->seat.session_monitor_source_id != 0) {
0c7e6b
                 g_source_remove (priv->seat.session_monitor_source_id);
ece282
         }
ece282
 #endif
ece282
 
0c7e6b
         if (priv->accounts_proxy != NULL) {
0c7e6b
                 g_object_unref (priv->accounts_proxy);
ece282
         }
ece282
 
0c7e6b
         if (priv->load_id > 0) {
0c7e6b
                 g_source_remove (priv->load_id);
0c7e6b
                 priv->load_id = 0;
ece282
         }
ece282
 
0c7e6b
         g_hash_table_destroy (priv->sessions);
ece282
 
0c7e6b
         g_hash_table_destroy (priv->normal_users_by_name);
0c7e6b
         g_hash_table_destroy (priv->system_users_by_name);
0c7e6b
         g_hash_table_destroy (priv->users_by_object_path);
ece282
 
0c7e6b
+        g_free (priv->os_id);
0c7e6b
+        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
 {
0c7e6b
         ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
0c7e6b
         return priv->accounts_proxy == NULL;
ece282
 }
ece282
 
ece282
+static void
ece282
+save_system_info (ActUserManager *manager,
ece282
+                  const char     *user_path)
ece282
+{
0c7e6b
+        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
 {
0c7e6b
         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
 
0c7e6b
         g_assert (priv->accounts_proxy != NULL);
ece282
 
0c7e6b
         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
  *
0c7e6b
@@ -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
 {
0c7e6b
         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
 
0c7e6b
         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
 {
0c7e6b
         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
 
0c7e6b
         g_assert (priv->accounts_proxy != NULL);
ece282
 
0c7e6b
         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
 {
0c7e6b
         ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
0c7e6b
@@ -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
 {
0c7e6b
         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
 
0c7e6b
         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
 {
0c7e6b
         ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
0c7e6b
diff --git a/src/libaccountsservice/meson.build b/src/libaccountsservice/meson.build
0c7e6b
index 4e134db..9e85bba 100644
0c7e6b
--- a/src/libaccountsservice/meson.build
0c7e6b
+++ b/src/libaccountsservice/meson.build
0c7e6b
@@ -21,60 +21,67 @@ enum_types = 'act-user-enum-types'
0c7e6b
 
0c7e6b
 enum_sources = gnome.mkenums(
0c7e6b
   enum_types,
0c7e6b
   sources: headers,
0c7e6b
   c_template: enum_types + '.c.template',
0c7e6b
   h_template: enum_types + '.h.template',
0c7e6b
   install_header: true,
0c7e6b
   install_dir: join_paths(act_pkgincludedir, subdir),
0c7e6b
 )
0c7e6b
 
0c7e6b
 dbus_sources = []
0c7e6b
 
0c7e6b
 ifaces = [
0c7e6b
   'Manager',
0c7e6b
   'Seat',
0c7e6b
   'Session',
0c7e6b
 ]
0c7e6b
 
0c7e6b
 namespace = 'ConsoleKit'
0c7e6b
 prefix = 'org.freedesktop.' + namespace
0c7e6b
 
0c7e6b
 foreach iface: ifaces
0c7e6b
   dbus_sources += gnome.gdbus_codegen(
0c7e6b
     'ck-@0@-generated'.format(iface.to_lower()),
0c7e6b
     '@0@.@1@.xml'.format(prefix, iface),
0c7e6b
     interface_prefix: prefix,
0c7e6b
     namespace: namespace,
0c7e6b
   )
0c7e6b
 endforeach
0c7e6b
 
0c7e6b
+dbus_sources += gnome.gdbus_codegen(
0c7e6b
+   'com.redhat.AccountsServiceUser.System',
0c7e6b
+   join_paths(data_dir, 'com.redhat.AccountsServiceUser.System.xml'),
0c7e6b
+   interface_prefix: 'com.redhat.AccountsService',
0c7e6b
+   namespace: 'Act',
0c7e6b
+)
0c7e6b
+
0c7e6b
 deps = [
0c7e6b
   crypt_dep,
0c7e6b
   gio_unix_dep,
0c7e6b
   glib_dep,
0c7e6b
   libaccounts_generated_dep,
0c7e6b
 ]
0c7e6b
 
0c7e6b
 symbol_map = join_paths(meson.current_source_dir(), 'symbol.map')
0c7e6b
 ldflags = cc.get_supported_link_arguments('-Wl,--version-script,@0@'.format(symbol_map))
0c7e6b
 
0c7e6b
 if enable_systemd or enable_elogind
0c7e6b
   deps += logind_dep
0c7e6b
 endif
0c7e6b
 
0c7e6b
 libaccountsservice = shared_library(
0c7e6b
   act_name,
0c7e6b
   sources: sources + enum_sources + dbus_sources,
0c7e6b
   version: libversion,
0c7e6b
   include_directories: top_inc,
0c7e6b
   dependencies: deps,
0c7e6b
   c_args: '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name()),
0c7e6b
   link_args: ldflags,
0c7e6b
   link_depends: symbol_map,
0c7e6b
   install: true,
0c7e6b
 )
0c7e6b
 
0c7e6b
 libaccountsservice_dep = declare_dependency(
0c7e6b
   sources: enum_sources[1],
0c7e6b
   include_directories: include_directories('.'),
0c7e6b
   dependencies: [gio_dep, glib_dep],
ece282
-- 
0c7e6b
2.27.0
ece282