import accountsservice-0.6.55-1.el8

This commit is contained in:
CentOS Sources 2021-05-18 02:38:42 -04:00 committed by Andrew Lukoshko
parent 01272aa841
commit 1ac0e10c54
10 changed files with 380 additions and 2381 deletions

View File

@ -1 +1 @@
8d59b9cdc4121b34748442ee653b92d60607f2cb SOURCES/accountsservice-0.6.50.tar.xz bab4f37144196d8ba06195bc72b4a9937c62b9fd SOURCES/accountsservice-0.6.55.tar.xz

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/accountsservice-0.6.50.tar.xz SOURCES/accountsservice-0.6.55.tar.xz

View File

@ -1,349 +0,0 @@
From dee5f443807fee3b5b279d0488df617eeed52230 Mon Sep 17 00:00:00 2001
From: Robert Ancell <robert.ancell@canonical.com>
Date: Thu, 6 Sep 2018 14:37:39 +1200
Subject: [PATCH] daemon: Fix warnings about type-punning
---
src/daemon.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/src/daemon.c b/src/daemon.c
index 2587b8a..00dff51 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -232,117 +232,118 @@ entry_generator_fgetpwent (Daemon *daemon,
pwent = fgetpwent (generator_state->fp);
if (pwent != NULL) {
shadow_entry_buffers = g_hash_table_lookup (generator_state->users, pwent->pw_name);
if (shadow_entry_buffers != NULL) {
*spent = &shadow_entry_buffers->spbuf;
}
return pwent;
}
}
/* Last iteration */
fclose (generator_state->fp);
g_hash_table_unref (generator_state->users);
g_free (generator_state);
*state = NULL;
return NULL;
}
static struct passwd *
entry_generator_cachedir (Daemon *daemon,
GHashTable *users,
gpointer *state,
struct spwd **shadow_entry)
{
struct passwd *pwent;
g_autoptr(GError) error = NULL;
gboolean regular;
GHashTableIter iter;
- const gchar *name;
- User *user;
+ gpointer key, value;
GDir *dir;
/* First iteration */
if (*state == NULL) {
*state = g_dir_open (USERDIR, 0, &error);
if (error != NULL) {
if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
g_warning ("couldn't list user cache directory: %s", USERDIR);
return NULL;
}
}
/* Every iteration */
/*
* Use names of files of regular type to lookup information
* about each user. Loop until we find something valid.
*/
dir = *state;
while (TRUE) {
const gchar *name;
g_autofree gchar *filename = NULL;
name = g_dir_read_name (dir);
if (name == NULL)
break;
/* Only load files in this directory */
filename = g_build_filename (USERDIR, name, NULL);
regular = g_file_test (filename, G_FILE_TEST_IS_REGULAR);
if (regular) {
errno = 0;
pwent = getpwnam (name);
if (pwent != NULL) {
*shadow_entry = getspnam (pwent->pw_name);
return pwent;
} else if (errno == 0) {
g_debug ("user '%s' in cache dir but not present on system, removing", name);
remove_cache_files (name);
}
else {
g_warning ("failed to check if user '%s' in cache dir is present on system: %s",
name, g_strerror (errno));
}
}
}
/* Last iteration */
g_dir_close (dir);
/* Update all the users from the files in the cache dir */
g_hash_table_iter_init (&iter, users);
- while (g_hash_table_iter_next (&iter, (gpointer *)&name, (gpointer *)&user)) {
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ const gchar *name = key;
+ User *user = value;
g_autofree gchar *filename = NULL;
g_autoptr(GKeyFile) key_file = NULL;
filename = g_build_filename (USERDIR, name, NULL);
key_file = g_key_file_new ();
if (g_key_file_load_from_file (key_file, filename, 0, NULL))
user_update_from_keyfile (user, key_file);
}
*state = NULL;
return NULL;
}
static struct passwd *
entry_generator_requested_users (Daemon *daemon,
GHashTable *users,
gpointer *state,
struct spwd **shadow_entry)
{
struct passwd *pwent;
GList *node;
/* First iteration */
if (*state == NULL) {
*state = daemon->priv->explicitly_requested_users;
}
/* Every iteration */
if (g_hash_table_size (users) < MAX_LOCAL_USERS) {
@@ -423,129 +424,131 @@ load_entries (Daemon *daemon,
}
if (!explicitly_requested) {
user_set_cached (user, TRUE);
}
}
/* Generator should have cleaned up */
g_assert (generator_state == NULL);
}
static GHashTable *
create_users_hash_table (void)
{
return g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
g_object_unref);
}
static void
reload_users (Daemon *daemon)
{
AccountsAccounts *accounts = ACCOUNTS_ACCOUNTS (daemon);
gboolean had_no_users, has_no_users, had_multiple_users, has_multiple_users;
GHashTable *users;
GHashTable *old_users;
GHashTable *local;
GHashTableIter iter;
gsize number_of_normal_users = 0;
- gpointer name;
- User *user;
+ gpointer name, value;
/* Track the users that we saw during our (re)load */
users = create_users_hash_table ();
/*
* NOTE: As we load data from all the sources, notifies are
* frozen in load_entries() and then thawed as we process
* them below.
*/
/* Load the local users into our hash table */
load_entries (daemon, users, FALSE, entry_generator_fgetpwent);
local = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_iter_init (&iter, users);
while (g_hash_table_iter_next (&iter, &name, NULL))
g_hash_table_add (local, name);
/* and add users to hash table that were explicitly requested */
load_entries (daemon, users, TRUE, entry_generator_requested_users);
/* Now add/update users from other sources, possibly non-local */
load_entries (daemon, users, FALSE, entry_generator_cachedir);
wtmp_helper_update_login_frequencies (users);
/* Count the non-system users. Mark which users are local, which are not. */
g_hash_table_iter_init (&iter, users);
- while (g_hash_table_iter_next (&iter, &name, (gpointer *)&user)) {
+ while (g_hash_table_iter_next (&iter, &name, &value)) {
+ User *user = value;
if (!user_get_system_account (user))
number_of_normal_users++;
user_update_local_account_property (user, g_hash_table_lookup (local, name) != NULL);
}
g_hash_table_destroy (local);
had_no_users = accounts_accounts_get_has_no_users (accounts);
has_no_users = number_of_normal_users == 0;
if (had_no_users != has_no_users)
accounts_accounts_set_has_no_users (accounts, has_no_users);
had_multiple_users = accounts_accounts_get_has_multiple_users (accounts);
has_multiple_users = number_of_normal_users > 1;
if (had_multiple_users != has_multiple_users)
accounts_accounts_set_has_multiple_users (accounts, has_multiple_users);
/* Swap out the users */
old_users = daemon->priv->users;
daemon->priv->users = users;
/* Remove all the old users */
g_hash_table_iter_init (&iter, old_users);
- while (g_hash_table_iter_next (&iter, &name, (gpointer *)&user)) {
+ while (g_hash_table_iter_next (&iter, &name, &value)) {
+ User *user = value;
User *refreshed_user;
refreshed_user = g_hash_table_lookup (users, name);
if (!refreshed_user || (user_get_cached (user) && !user_get_cached (refreshed_user))) {
accounts_accounts_emit_user_deleted (ACCOUNTS_ACCOUNTS (daemon),
user_get_object_path (user));
user_unregister (user);
}
}
/* Register all the new users */
g_hash_table_iter_init (&iter, users);
- while (g_hash_table_iter_next (&iter, &name, (gpointer *)&user)) {
+ while (g_hash_table_iter_next (&iter, &name, &value)) {
+ User *user = value;
User *stale_user;
stale_user = g_hash_table_lookup (old_users, name);
if (!stale_user || (!user_get_cached (stale_user) && user_get_cached (user))) {
user_register (user);
accounts_accounts_emit_user_added (ACCOUNTS_ACCOUNTS (daemon),
user_get_object_path (user));
}
g_object_thaw_notify (G_OBJECT (user));
}
g_hash_table_destroy (old_users);
}
static gboolean
reload_users_timeout (Daemon *daemon)
{
reload_users (daemon);
daemon->priv->reload_id = 0;
return FALSE;
}
static gboolean load_autologin (Daemon *daemon,
gchar **name,
gboolean *enabled,
GError **error);
static gboolean
@@ -932,69 +935,70 @@ typedef struct {
} ListUserData;
static ListUserData *
list_user_data_new (Daemon *daemon,
GDBusMethodInvocation *context)
{
ListUserData *data;
data = g_new0 (ListUserData, 1);
data->daemon = g_object_ref (daemon);
data->context = context;
return data;
}
static void
list_user_data_free (ListUserData *data)
{
g_object_unref (data->daemon);
g_free (data);
}
static gboolean
finish_list_cached_users (gpointer user_data)
{
ListUserData *data = user_data;
g_autoptr(GPtrArray) object_paths = NULL;
GHashTableIter iter;
- const gchar *name;
- User *user;
+ gpointer key, value;
uid_t uid;
const gchar *shell;
object_paths = g_ptr_array_new ();
g_hash_table_iter_init (&iter, data->daemon->priv->users);
- while (g_hash_table_iter_next (&iter, (gpointer *)&name, (gpointer *)&user)) {
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ const gchar *name = key;
+ User *user = value;
uid = user_get_uid (user);
shell = user_get_shell (user);
if (!user_classify_is_human (uid, name, shell, NULL)) {
g_debug ("user %s %ld excluded", name, (long) uid);
continue;
}
if (!user_get_cached (user)) {
g_debug ("user %s %ld not cached", name, (long) uid);
continue;
}
g_debug ("user %s %ld not excluded", name, (long) uid);
g_ptr_array_add (object_paths, (gpointer) user_get_object_path (user));
}
g_ptr_array_add (object_paths, NULL);
accounts_accounts_complete_list_cached_users (NULL, data->context, (const gchar * const *) object_paths->pdata);
list_user_data_free (data);
return FALSE;
}
static gboolean
daemon_list_cached_users (AccountsAccounts *accounts,
GDBusMethodInvocation *context)
{
Daemon *daemon = (Daemon*)accounts;
--
2.17.1

View File

@ -1,4 +1,4 @@
From 967603c6823180b055c6f1b5e76b05c377076eda Mon Sep 17 00:00:00 2001 From 54b207649979475ea7f1fa5eaaea94be31d20935 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com> From: Ray Strode <rstrode@redhat.com>
Date: Fri, 13 Dec 2019 15:16:06 -0500 Date: Fri, 13 Dec 2019 15:16:06 -0500
Subject: [PATCH] daemon: if no local users, check if machine is enrolled in Subject: [PATCH] daemon: if no local users, check if machine is enrolled in
@ -11,59 +11,14 @@ and shouldn't have a local user.
This commit detects that case, and avoids setting the HasNoUsers This commit detects that case, and avoids setting the HasNoUsers
property. property.
--- ---
data/Makefile.am | 1 +
data/org.freedesktop.realmd.xml | 730 ++++++++++++++++++++++++++++++++ data/org.freedesktop.realmd.xml | 730 ++++++++++++++++++++++++++++++++
src/Makefile.am | 5 + src/daemon.c | 63 ++-
src/daemon.c | 61 ++- src/meson.build | 1 +
src/org.freedesktop.realmd.xml | 730 ++++++++++++++++++++++++++++++++ src/org.freedesktop.realmd.xml | 730 ++++++++++++++++++++++++++++++++
5 files changed, 1523 insertions(+), 4 deletions(-) 4 files changed, 1520 insertions(+), 4 deletions(-)
create mode 100644 data/org.freedesktop.realmd.xml create mode 100644 data/org.freedesktop.realmd.xml
create mode 100644 src/org.freedesktop.realmd.xml create mode 100644 src/org.freedesktop.realmd.xml
diff --git a/data/Makefile.am b/data/Makefile.am
index 521c6c2..6cf5e30 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -7,38 +7,39 @@ dbusif_DATA = \
dbusconfdir = $(sysconfdir)/dbus-1/system.d
dbusconf_DATA = org.freedesktop.Accounts.conf
servicedir = $(datadir)/dbus-1/system-services
service_in_files = org.freedesktop.Accounts.service.in
service_DATA = $(service_in_files:.service.in=.service)
$(service_DATA): $(service_in_files) Makefile
@sed -e "s|\@libexecdir\@|$(libexecdir)|" $< >$@
policydir = $(datadir)/polkit-1/actions
policy_in_files = org.freedesktop.accounts.policy.in
policy_DATA = $(policy_in_files:.policy.in=.policy)
@INTLTOOL_POLICY_RULE@
if HAVE_SYSTEMD
systemdsystemunit_DATA = \
accounts-daemon.service
accounts-daemon.service: accounts-daemon.service.in
@sed -e "s|\@libexecdir\@|$(libexecdir)|" $< >$@
endif
EXTRA_DIST = \
$(dbusif_DATA) \
$(dbusconf_DATA) \
$(service_in_files) \
$(policy_in_files) \
+ org.freedesktop.realmd.xml \
accounts-daemon.service.in
DISTCLEANFILES = \
$(service_DATA) \
$(policy_DATA)
CLEANFILES = \
accounts-daemon.service
diff --git a/data/org.freedesktop.realmd.xml b/data/org.freedesktop.realmd.xml diff --git a/data/org.freedesktop.realmd.xml b/data/org.freedesktop.realmd.xml
new file mode 100644 new file mode 100644
index 0000000..c34a47a index 0000000..c34a47a
@ -800,77 +755,8 @@ index 0000000..c34a47a
+ </interface> + </interface>
+ +
+</node> +</node>
diff --git a/src/Makefile.am b/src/Makefile.am
index f53e3e1..7a5b382 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,59 +1,64 @@
NULL =
BUILT_SOURCES =
SUBDIRS = . libaccountsservice
INCLUDES = \
-DLOCALSTATEDIR=\""$(localstatedir)"\" \
-DDATADIR=\""$(datadir)"\" \
-DICONDIR=\"$(localstatedir)/lib/AccountsService/icons\" \
-DUSERDIR=\"$(localstatedir)/lib/AccountsService/users\" \
-I$(srcdir) \
-I$(builddir) \
$(ACCOUNTS_DAEMON_CFLAGS) \
$(WARN_CFLAGS)
noinst_LTLIBRARIES = libaccounts-generated.la
libaccounts_generated_la_SOURCES = \
accounts-generated.c \
accounts-generated.h \
accounts-user-generated.c \
accounts-user-generated.h \
+ realmd-generated.c \
+ realmd-generated.h \
$(NULL)
BUILT_SOURCES += $(libaccounts_generated_la_SOURCES)
accounts-generated.c accounts-generated.h: $(top_srcdir)/data/org.freedesktop.Accounts.xml Makefile
gdbus-codegen --generate-c-code accounts-generated --c-namespace Accounts --interface-prefix=org.freedesktop. $(top_srcdir)/data/org.freedesktop.Accounts.xml
accounts-user-generated.c accounts-user-generated.h: $(top_srcdir)/data/org.freedesktop.Accounts.User.xml Makefile
gdbus-codegen --generate-c-code accounts-user-generated --c-namespace Accounts --interface-prefix=org.freedesktop.Accounts. $(top_srcdir)/data/org.freedesktop.Accounts.User.xml
+realmd-generated.c realmd-generated.h: $(top_srcdir)/data/org.freedesktop.realmd.xml Makefile
+ gdbus-codegen --c-generate-autocleanup all --c-generate-object-manager --generate-c-code realmd-generated --c-namespace Accounts --interface-prefix=org.freedesktop. $(top_srcdir)/data/org.freedesktop.realmd.xml
+
libexec_PROGRAMS = accounts-daemon
accounts_daemon_SOURCES = \
$(enums_h_sources) \
types.h \
daemon.h \
daemon.c \
extensions.c \
user-classify.h \
user-classify.c \
user.h \
user.c \
util.h \
util.c \
wtmp-helper.h \
wtmp-helper.c \
main.c
accounts_daemon_LDADD = \
libaccounts-generated.la \
$(ACCOUNTS_DAEMON_LIBS)
EXTRA_DIST = \
fgetpwent.c \
$(NULL)
CLEANFILES = \
$(BUILT_SOURCES) \
*.gcda \
*.gcno \
diff --git a/src/daemon.c b/src/daemon.c diff --git a/src/daemon.c b/src/daemon.c
index 00dff51..23e60ce 100644 index c52bda3..5ce0216 100644
--- a/src/daemon.c --- a/src/daemon.c
+++ b/src/daemon.c +++ b/src/daemon.c
@@ -20,60 +20,61 @@ @@ -20,60 +20,61 @@
@ -915,7 +801,7 @@ index 00dff51..23e60ce 100644
PROP_DAEMON_VERSION PROP_DAEMON_VERSION
}; };
struct DaemonPrivate { typedef struct {
GDBusConnection *bus_connection; GDBusConnection *bus_connection;
GHashTable *users; GHashTable *users;
@ -930,12 +816,12 @@ index 00dff51..23e60ce 100644
GFileMonitor *gdm_monitor; GFileMonitor *gdm_monitor;
GFileMonitor *wtmp_monitor; GFileMonitor *wtmp_monitor;
GQueue *pending_list_cached_users;
guint reload_id; guint reload_id;
guint autologin_id; guint autologin_id;
PolkitAuthority *authority; @@ -425,110 +426,167 @@ load_entries (Daemon *daemon,
GHashTable *extension_ifaces;
@@ -414,109 +415,164 @@ load_entries (Daemon *daemon,
} else { } else {
g_object_ref (user); g_object_ref (user);
} }
@ -969,13 +855,14 @@ index 00dff51..23e60ce 100644
+static gboolean +static gboolean
+ensure_bus_connection (Daemon *daemon) +ensure_bus_connection (Daemon *daemon)
+{ +{
+ DaemonPrivate *priv = daemon_get_instance_private (daemon);
+ g_autoptr (GError) error = NULL; + g_autoptr (GError) error = NULL;
+ +
+ if (daemon->priv->bus_connection != NULL) + if (priv->bus_connection != NULL)
+ return TRUE; + return TRUE;
+ +
+ daemon->priv->bus_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); + priv->bus_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (daemon->priv->bus_connection == NULL) { + if (priv->bus_connection == NULL) {
+ if (error != NULL) + if (error != NULL)
+ g_critical ("error getting system bus: %s", error->message); + g_critical ("error getting system bus: %s", error->message);
+ return FALSE; + return FALSE;
@ -987,6 +874,7 @@ index 00dff51..23e60ce 100644
+static gboolean +static gboolean
+has_network_realms (Daemon *daemon) +has_network_realms (Daemon *daemon)
+{ +{
+ DaemonPrivate *priv = daemon_get_instance_private (daemon);
+ g_autoptr (AccountsRealmdProvider) realmd_provider = NULL; + g_autoptr (AccountsRealmdProvider) realmd_provider = NULL;
+ g_autoptr (GError) error = NULL; + g_autoptr (GError) error = NULL;
+ const char *const *realms = NULL; + const char *const *realms = NULL;
@ -995,7 +883,7 @@ index 00dff51..23e60ce 100644
+ return FALSE; + return FALSE;
+ } + }
+ +
+ realmd_provider = accounts_realmd_provider_proxy_new_sync (daemon->priv->bus_connection, + realmd_provider = accounts_realmd_provider_proxy_new_sync (priv->bus_connection,
+ G_DBUS_PROXY_FLAGS_NONE, + G_DBUS_PROXY_FLAGS_NONE,
+ "org.freedesktop.realmd", + "org.freedesktop.realmd",
+ "/org/freedesktop/realmd", + "/org/freedesktop/realmd",
@ -1019,6 +907,7 @@ index 00dff51..23e60ce 100644
static void static void
reload_users (Daemon *daemon) reload_users (Daemon *daemon)
{ {
DaemonPrivate *priv = daemon_get_instance_private (daemon);
AccountsAccounts *accounts = ACCOUNTS_ACCOUNTS (daemon); AccountsAccounts *accounts = ACCOUNTS_ACCOUNTS (daemon);
gboolean had_no_users, has_no_users, had_multiple_users, has_multiple_users; gboolean had_no_users, has_no_users, had_multiple_users, has_multiple_users;
GHashTable *users; GHashTable *users;
@ -1080,8 +969,8 @@ index 00dff51..23e60ce 100644
accounts_accounts_set_has_multiple_users (accounts, has_multiple_users); accounts_accounts_set_has_multiple_users (accounts, has_multiple_users);
/* Swap out the users */ /* Swap out the users */
old_users = daemon->priv->users; old_users = priv->users;
daemon->priv->users = users; priv->users = users;
/* Remove all the old users */ /* Remove all the old users */
g_hash_table_iter_init (&iter, old_users); g_hash_table_iter_init (&iter, old_users);
@ -1100,21 +989,20 @@ index 00dff51..23e60ce 100644
/* Register all the new users */ /* Register all the new users */
g_hash_table_iter_init (&iter, users); g_hash_table_iter_init (&iter, users);
@@ -733,64 +789,61 @@ daemon_finalize (GObject *object) @@ -766,64 +824,61 @@ daemon_finalize (GObject *object)
Daemon *daemon; priv = daemon_get_instance_private (daemon);
g_return_if_fail (IS_DAEMON (object)); if (priv->bus_connection != NULL)
g_object_unref (priv->bus_connection);
daemon = DAEMON (object); g_queue_free_full (priv->pending_list_cached_users,
(GDestroyNotify) list_user_data_free);
if (daemon->priv->bus_connection != NULL) g_list_free_full (priv->explicitly_requested_users, g_free);
g_object_unref (daemon->priv->bus_connection);
g_list_free_full (daemon->priv->explicitly_requested_users, g_free); g_hash_table_destroy (priv->users);
g_hash_table_destroy (daemon->priv->users); g_hash_table_unref (priv->extension_ifaces);
g_hash_table_unref (daemon->priv->extension_ifaces);
G_OBJECT_CLASS (daemon_parent_class)->finalize (object); G_OBJECT_CLASS (daemon_parent_class)->finalize (object);
} }
@ -1122,17 +1010,18 @@ index 00dff51..23e60ce 100644
static gboolean static gboolean
register_accounts_daemon (Daemon *daemon) register_accounts_daemon (Daemon *daemon)
{ {
DaemonPrivate *priv = daemon_get_instance_private (daemon);
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
daemon->priv->authority = polkit_authority_get_sync (NULL, &error); priv->authority = polkit_authority_get_sync (NULL, &error);
if (daemon->priv->authority == NULL) { if (priv->authority == NULL) {
if (error != NULL) if (error != NULL)
g_critical ("error getting polkit authority: %s", error->message); g_critical ("error getting polkit authority: %s", error->message);
return FALSE; return FALSE;
} }
- daemon->priv->bus_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); - priv->bus_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
- if (daemon->priv->bus_connection == NULL) { - if (priv->bus_connection == NULL) {
- if (error != NULL) - if (error != NULL)
- g_critical ("error getting system bus: %s", error->message); - g_critical ("error getting system bus: %s", error->message);
+ if (!ensure_bus_connection (daemon)) { + if (!ensure_bus_connection (daemon)) {
@ -1140,7 +1029,7 @@ index 00dff51..23e60ce 100644
} }
if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (daemon), if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (daemon),
daemon->priv->bus_connection, priv->bus_connection,
"/org/freedesktop/Accounts", "/org/freedesktop/Accounts",
&error)) { &error)) {
if (error != NULL) if (error != NULL)
@ -1166,6 +1055,49 @@ index 00dff51..23e60ce 100644
} }
static void static void
diff --git a/src/meson.build b/src/meson.build
index 20d5276..3970749 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,37 +1,38 @@
sources = []
gdbus_headers = []
ifaces = [
['accounts-generated', 'org.freedesktop.', 'Accounts'],
['accounts-user-generated', act_namespace + '.', 'User'],
+ ['realmd-generated', 'org.freedesktop.', 'realmd'],
]
foreach iface: ifaces
gdbus_sources = gnome.gdbus_codegen(
iface[0],
join_paths(data_dir, iface[1] + iface[2] + '.xml'),
interface_prefix: iface[1],
namespace: 'Accounts',
)
sources += gdbus_sources
gdbus_headers += gdbus_sources[1]
endforeach
deps = [
gio_dep,
gio_unix_dep,
]
cflags = [
'-DLOCALSTATEDIR="@0@"'.format(act_localstatedir),
'-DDATADIR="@0@"'.format(act_datadir),
'-DICONDIR="@0@"'.format(join_paths(act_localstatedir, 'lib', 'AccountsService', 'icons')),
'-DUSERDIR="@0@"'.format(join_paths(act_localstatedir, 'lib', 'AccountsService', 'users')),
]
libaccounts_generated = static_library(
'accounts-generated',
sources: sources,
include_directories: top_inc,
dependencies: deps,
diff --git a/src/org.freedesktop.realmd.xml b/src/org.freedesktop.realmd.xml diff --git a/src/org.freedesktop.realmd.xml b/src/org.freedesktop.realmd.xml
new file mode 100644 new file mode 100644
index 0000000..c34a47a index 0000000..c34a47a
@ -1903,5 +1835,5 @@ index 0000000..c34a47a
+ +
+</node> +</node>
-- --
2.21.0 2.27.0

View File

@ -1,4 +1,4 @@
From b4f85d66280affcb52e998661f782c2ab4f806a7 Mon Sep 17 00:00:00 2001 From 50edc5e45bb984576506e7b2bfb4c267ac566099 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com> From: Ray Strode <rstrode@redhat.com>
Date: Thu, 9 May 2019 14:58:34 -0400 Date: Thu, 9 May 2019 14:58:34 -0400
Subject: [PATCH] data: don't send change updates for login-history Subject: [PATCH] data: don't send change updates for login-history
@ -84,5 +84,5 @@ index 8d3fe1c..3b839a3 100644
<doc:description> <doc:description>
<doc:para> <doc:para>
-- --
2.21.0 2.27.0

View File

@ -1,90 +0,0 @@
From c7fa612023a163e8b2352e1170c6df3fceb19b27 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Thu, 19 Jul 2018 13:14:09 -0400
Subject: [PATCH] lib: don't set loaded state until seat is fetched
At the moment we set is-loaded on the user-manager
object as soon as we start fetching the seat, but
we should waiting until the seat is fetched, so
that can_switch() will return the correct value
if the caller waited until the loaded signal
to use it.
This commit changes the >= to > which I believe
was the original intention anyway.
https://bugs.freedesktop.org/show_bug.cgi?id=107298
---
src/libaccountsservice/act-user-manager.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libaccountsservice/act-user-manager.c b/src/libaccountsservice/act-user-manager.c
index 325421b..e7e26b1 100644
--- a/src/libaccountsservice/act-user-manager.c
+++ b/src/libaccountsservice/act-user-manager.c
@@ -2355,61 +2355,61 @@ act_user_manager_list_users (ActUserManager *manager)
queue_load_seat_incrementally (manager);
}
retval = NULL;
g_hash_table_foreach (manager->priv->normal_users_by_name, listify_hash_values_hfunc, &retval);
return g_slist_sort (retval, (GCompareFunc) act_user_collate);
}
static void
maybe_set_is_loaded (ActUserManager *manager)
{
if (manager->priv->is_loaded) {
g_debug ("ActUserManager: already loaded, so not setting loaded property");
return;
}
if (manager->priv->getting_sessions) {
g_debug ("ActUserManager: GetSessions call pending, so not setting loaded property");
return;
}
if (manager->priv->new_users_inhibiting_load != NULL) {
g_debug ("ActUserManager: Loading new users, so not setting loaded property");
return;
}
/* Don't set is_loaded yet unless the seat is already loaded enough
* or failed to load.
*/
- if (manager->priv->seat.state >= ACT_USER_MANAGER_SEAT_STATE_GET_ID) {
+ if (manager->priv->seat.state > ACT_USER_MANAGER_SEAT_STATE_GET_ID) {
g_debug ("ActUserManager: Seat loaded, so now setting loaded property");
} else if (manager->priv->seat.state == ACT_USER_MANAGER_SEAT_STATE_UNLOADED) {
g_debug ("ActUserManager: Seat wouldn't load, so giving up on it and setting loaded property");
} else {
g_debug ("ActUserManager: Seat still actively loading, so not setting loaded property");
return;
}
set_is_loaded (manager, TRUE);
}
static GSList *
slist_deep_copy (const GSList *list)
{
GSList *retval;
GSList *l;
if (list == NULL)
return NULL;
retval = g_slist_copy ((GSList *) list);
for (l = retval; l != NULL; l = l->next) {
l->data = g_strdup (l->data);
}
return retval;
}
static void
--
2.17.1

View File

@ -1,6 +1,6 @@
From 51d5c9e9baec33aa74a60a4ac11f1de8f71acb2a Mon Sep 17 00:00:00 2001 From 5124220f12a157ff285072a4f786db2c94c3ca8a Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com> From: Ray Strode <rstrode@redhat.com>
Date: Fri, 12 Oct 2018 15:53:52 -0400 Date: Thu, 14 Jan 2021 15:07:34 -0500
Subject: [PATCH] lib: save os when creating user Subject: [PATCH] lib: save os when creating user
In order to identify that a user has upgraded from rhel 7 to In order to identify that a user has upgraded from rhel 7 to
@ -9,76 +9,15 @@ rhel 8, we need to know what os they were using when created.
This commit saves that information using a red hat specific This commit saves that information using a red hat specific
extension to accountsservice. extension to accountsservice.
--- ---
data/Makefile.am | 14 +-
.../com.redhat.AccountsServiceUser.System.xml | 10 ++ .../com.redhat.AccountsServiceUser.System.xml | 10 ++
src/libaccountsservice/Makefile.am | 12 +- data/meson.build | 1 +
meson.build | 1 +
meson_post_install.py | 15 +++
src/libaccountsservice/act-user-manager.c | 123 ++++++++++++++++++ src/libaccountsservice/act-user-manager.c | 123 ++++++++++++++++++
4 files changed, 157 insertions(+), 2 deletions(-) src/libaccountsservice/meson.build | 7 +
6 files changed, 157 insertions(+)
create mode 100644 data/com.redhat.AccountsServiceUser.System.xml create mode 100644 data/com.redhat.AccountsServiceUser.System.xml
diff --git a/data/Makefile.am b/data/Makefile.am
index 6cf5e30..648774c 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,45 +1,57 @@
dbusifdir = $(datadir)/dbus-1/interfaces
dbusif_DATA = \
org.freedesktop.Accounts.xml \
- org.freedesktop.Accounts.User.xml
+ org.freedesktop.Accounts.User.xml \
+ com.redhat.AccountsServiceUser.System.xml
dbusconfdir = $(sysconfdir)/dbus-1/system.d
dbusconf_DATA = org.freedesktop.Accounts.conf
+accountsserviceifdir = $(datadir)/accountsservice/interfaces
+
servicedir = $(datadir)/dbus-1/system-services
service_in_files = org.freedesktop.Accounts.service.in
service_DATA = $(service_in_files:.service.in=.service)
$(service_DATA): $(service_in_files) Makefile
@sed -e "s|\@libexecdir\@|$(libexecdir)|" $< >$@
policydir = $(datadir)/polkit-1/actions
policy_in_files = org.freedesktop.accounts.policy.in
policy_DATA = $(policy_in_files:.policy.in=.policy)
@INTLTOOL_POLICY_RULE@
if HAVE_SYSTEMD
systemdsystemunit_DATA = \
accounts-daemon.service
accounts-daemon.service: accounts-daemon.service.in
@sed -e "s|\@libexecdir\@|$(libexecdir)|" $< >$@
endif
EXTRA_DIST = \
$(dbusif_DATA) \
$(dbusconf_DATA) \
$(service_in_files) \
$(policy_in_files) \
org.freedesktop.realmd.xml \
accounts-daemon.service.in
DISTCLEANFILES = \
$(service_DATA) \
$(policy_DATA)
CLEANFILES = \
accounts-daemon.service
+
+install-data-hook: com.redhat.AccountsServiceUser.System.xml
+ if test '!' -d $(DESTDIR)$(accountsserviceifdir); then \
+ $(mkinstalldirs) $(DESTDIR)$(accountsserviceifdir); \
+ chmod 755 $(DESTDIR)$(accountsserviceifdir); \
+ fi
+ if test '!' -L $(DESTDIR)$(accountsserviceifdir)/com.redhat.AccountsServiceUser.System.xml; then \
+ (cd $(DESTDIR)$(accountsserviceifdir); $(LN_S) ../../dbus-1/interfaces/com.redhat.AccountsServiceUser.System.xml) \
+ fi
diff --git a/data/com.redhat.AccountsServiceUser.System.xml b/data/com.redhat.AccountsServiceUser.System.xml diff --git a/data/com.redhat.AccountsServiceUser.System.xml b/data/com.redhat.AccountsServiceUser.System.xml
new file mode 100644 new file mode 100644
index 0000000..67f5f30 index 0000000..67f5f30
@ -95,93 +34,129 @@ index 0000000..67f5f30
+ +
+ </interface> + </interface>
+</node> +</node>
diff --git a/src/libaccountsservice/Makefile.am b/src/libaccountsservice/Makefile.am diff --git a/data/meson.build b/data/meson.build
index 408d91f..d711d65 100644 index 4987937..2dc57c2 100644
--- a/src/libaccountsservice/Makefile.am --- a/data/meson.build
+++ b/src/libaccountsservice/Makefile.am +++ b/data/meson.build
@@ -20,69 +20,79 @@ act-user-enum-types.h: act-user.h act-user-manager.h @@ -1,33 +1,34 @@
$(AM_V_GEN) (cd $(srcdir) && \ ifaces = files(
glib-mkenums \ act_namespace + '.xml',
--fhead "#ifndef __ACT_USER_ENUM_TYPES_H__\n#define __ACT_USER_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \ act_namespace + '.User.xml',
--fprod "/* enumerations from \"@filename@\" */\n" \ + 'com.redhat.AccountsServiceUser.System.xml',
--vhead "GType @enum_name@_get_type (void);\n#define ACT_USER_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \ )
--ftail "G_END_DECLS\n\n#endif /* __ACT_USER_ENUM_TYPES_H__ */" \
$(^F) ) > $@
act-user-enum-types.c: act-user.h act-user-manager.h act-user-enum-types.h install_data(
$(AM_V_GEN) (cd $(srcdir) && \ ifaces,
glib-mkenums \ install_dir: dbus_ifaces_dir,
--fhead "#include \"act-user.h\"\n" \ )
--fhead "#include \"act-user-manager.h\"\n" \
--fhead "#include \"act-user-enum-types.h\"\n" \
--fhead "#include <glib-object.h>" \
--fprod "\n/* enumerations from \"@filename@\" */" \
--vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \
--vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
--vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \
$(^F) ) > $@
ck-manager-generated.c ck-manager-generated.h: org.freedesktop.ConsoleKit.Manager.xml Makefile install_data(
$(AM_V_GEN) gdbus-codegen --generate-c-code ck-manager-generated --c-namespace ConsoleKit --interface-prefix=org.freedesktop.ConsoleKit $(srcdir)/org.freedesktop.ConsoleKit.Manager.xml act_namespace + '.conf',
install_dir: dbus_conf_dir,
)
ck-seat-generated.c ck-seat-generated.h: org.freedesktop.ConsoleKit.Seat.xml Makefile service_conf = configuration_data()
$(AM_V_GEN) gdbus-codegen --generate-c-code ck-seat-generated --c-namespace ConsoleKit --interface-prefix=org.freedesktop.ConsoleKit $(srcdir)/org.freedesktop.ConsoleKit.Seat.xml service_conf.set('libexecdir', act_libexecdir)
ck-session-generated.c ck-session-generated.h: org.freedesktop.ConsoleKit.Session.xml Makefile service = act_namespace + '.service'
$(AM_V_GEN) gdbus-codegen --generate-c-code ck-session-generated --c-namespace ConsoleKit --interface-prefix=org.freedesktop.ConsoleKit $(srcdir)/org.freedesktop.ConsoleKit.Session.xml
+com.redhat.AccountsServiceUser.System.c com.redhat.AccountsServiceUser.System.h: $(top_srcdir)/data/com.redhat.AccountsServiceUser.System.xml Makefile configure_file(
+ $(AM_V_GEN)gdbus-codegen \ input: service + '.in',
+ --c-namespace=Act \ output: service,
+ --interface-prefix=com.redhat.AccountsService \ configuration: service_conf,
+ --generate-c-code=com.redhat.AccountsServiceUser.System \ install: true,
+ $(top_srcdir)/data/com.redhat.AccountsServiceUser.System.xml install_dir: dbus_sys_dir,
)
policy = act_namespace.to_lower() + '.policy'
i18n.merge_file(
policy,
input: policy + '.in',
diff --git a/meson.build b/meson.build
index 4465a26..e37c451 100644
--- a/meson.build
+++ b/meson.build
@@ -174,38 +174,39 @@ assert(not enable_systemd or not enable_elogind, 'systemd and elogind support re
if enable_systemd
logind_dep = dependency('libsystemd', version: '>= 186')
endif
if enable_elogind
logind_dep = dependency('libelogind', version: '>= 229.4')
endif
config_h.set('WITH_SYSTEMD', enable_systemd or enable_elogind)
subdir('data')
subdir('src')
subdir('po')
enable_docbook = get_option('docbook')
if enable_docbook
subdir('doc/dbus')
endif
if get_option('gtk_doc')
subdir('doc/libaccountsservice')
endif
configure_file(
output: 'config.h',
configuration: config_h,
)
meson.add_install_script(
'meson_post_install.py',
act_localstatedir,
+ act_datadir,
)
output = '\n' + meson.project_name() + ' was configured with the following options:\n'
output += '** DocBook documentation build: ' + enable_docbook.to_string() + '\n'
output += '** Administrator group: ' + admin_group + '\n'
output += '** Extra administrator groups: ' + extra_admin_groups + '\n'
output += '** GDM configuration: ' + gdm_conf_file
message(output)
diff --git a/meson_post_install.py b/meson_post_install.py
index 5cc2dc4..e1d5a71 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -1,18 +1,33 @@
#!/usr/bin/env python3
import os
import sys
destdir = os.environ.get('DESTDIR', '')
localstatedir = os.path.normpath(destdir + os.sep + sys.argv[1])
+datadir = os.path.normpath(destdir + os.sep + sys.argv[2])
+interfacedir = os.path.join(datadir, 'accountsservice', 'interfaces')
# FIXME: meson will not track the creation of these directories
# https://github.com/mesonbuild/meson/blob/master/mesonbuild/scripts/uninstall.py#L39
dst_dirs = [
(os.path.join(localstatedir, 'lib', 'AccountsService', 'icons'), 0o775),
(os.path.join(localstatedir, 'lib', 'AccountsService', 'users'), 0o700),
+ (interfacedir, 0o775),
]
for (dst_dir, dst_dir_mode) in dst_dirs:
if not os.path.exists(dst_dir):
os.makedirs(dst_dir, mode=dst_dir_mode)
+
+interface_files = [
+ 'com.redhat.AccountsServiceUser.System.xml',
+]
+
+for interface_file in interface_files:
+ src_path = os.path.join('../../dbus-1/interfaces', interface_file)
+ dst_path = os.path.join(interfacedir, interface_file)
+ if not os.path.exists(dst_path):
+ os.symlink(src_path, dst_path)
+ +
+ +
BUILT_SOURCES += \
act-user-enum-types.c \
act-user-enum-types.h \
ck-manager-generated.c \
ck-manager-generated.h \
ck-seat-generated.c \
ck-seat-generated.h \
ck-session-generated.c \
- ck-session-generated.h
+ ck-session-generated.h \
+ com.redhat.AccountsServiceUser.System.h \
+ com.redhat.AccountsServiceUser.System.c
CLEANFILES += $(BUILT_SOURCES)
libaccountsservicedir = $(includedir)/accountsservice-1.0/act
libaccountsservice_headers = \
act-user.h \
act-user-manager.h \
act-user-enum-types.h \
$(END_OF_LIST)
libaccountsservice_HEADERS = \
act.h \
$(libaccountsservice_headers) \
$(END_OF_LIST)
libaccountsservice_la_CFLAGS = $(LIBACCOUNTSSERVICE_CFLAGS)
libaccountsservice_la_LDFLAGS = \
-export-symbols-regex '^[^_].*' \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
-no-undefined \
$(END_OF_LIST)
libaccountsservice_la_LIBADD = \
../libaccounts-generated.la \
$(LIBACCOUNTSSERVICE_LIBS) \
-lcrypt \
$(END_OF_LIST)
libaccountsservice_la_sources = \
diff --git a/src/libaccountsservice/act-user-manager.c b/src/libaccountsservice/act-user-manager.c diff --git a/src/libaccountsservice/act-user-manager.c b/src/libaccountsservice/act-user-manager.c
index e7e26b1..9f3d6e5 100644 index 1b5298d..f4598c4 100644
--- a/src/libaccountsservice/act-user-manager.c --- a/src/libaccountsservice/act-user-manager.c
+++ b/src/libaccountsservice/act-user-manager.c +++ b/src/libaccountsservice/act-user-manager.c
@@ -27,60 +27,61 @@ @@ -27,60 +27,61 @@
@ -246,7 +221,7 @@ index e7e26b1..9f3d6e5 100644
* @ACT_USER_MANAGER_ERROR_FAILED: Generic failure * @ACT_USER_MANAGER_ERROR_FAILED: Generic failure
* @ACT_USER_MANAGER_ERROR_USER_EXISTS: The user already exists * @ACT_USER_MANAGER_ERROR_USER_EXISTS: The user already exists
* @ACT_USER_MANAGER_ERROR_USER_DOES_NOT_EXIST: The user does not exist * @ACT_USER_MANAGER_ERROR_USER_DOES_NOT_EXIST: The user does not exist
@@ -167,60 +168,63 @@ typedef struct @@ -165,60 +166,63 @@ typedef struct
ActUser *user; ActUser *user;
ActUserManagerFetchUserRequestType type; ActUserManagerFetchUserRequestType type;
union { union {
@ -257,7 +232,7 @@ index e7e26b1..9f3d6e5 100644
char *description; char *description;
} ActUserManagerFetchUserRequest; } ActUserManagerFetchUserRequest;
struct ActUserManagerPrivate typedef struct
{ {
GHashTable *normal_users_by_name; GHashTable *normal_users_by_name;
GHashTable *system_users_by_name; GHashTable *system_users_by_name;
@ -286,7 +261,7 @@ index e7e26b1..9f3d6e5 100644
gboolean has_multiple_users; gboolean has_multiple_users;
gboolean getting_sessions; gboolean getting_sessions;
gboolean list_cached_users_done; gboolean list_cached_users_done;
}; } ActUserManagerPrivate;
enum { enum {
PROP_0, PROP_0,
@ -310,30 +285,30 @@ index e7e26b1..9f3d6e5 100644
static void act_user_manager_init (ActUserManager *user_manager); static void act_user_manager_init (ActUserManager *user_manager);
static void act_user_manager_finalize (GObject *object); static void act_user_manager_finalize (GObject *object);
@@ -2763,101 +2767,174 @@ ensure_accounts_proxy (ActUserManager *manager) @@ -2942,100 +2946,173 @@ ensure_accounts_proxy (ActUserManager *manager)
G_DBUS_PROXY_FLAGS_NONE, G_DBUS_PROXY_FLAGS_NONE,
ACCOUNTS_NAME, ACCOUNTS_NAME,
ACCOUNTS_PATH, ACCOUNTS_PATH,
NULL, NULL,
&error); &error);
if (error != NULL) { if (error != NULL) {
g_debug ("ActUserManager: getting account proxy failed: %s", error->message); g_debug ("ActUserManager: getting account proxy failed: %s", error->message);
return FALSE; return FALSE;
} }
g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (manager->priv->accounts_proxy), G_MAXINT); g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (priv->accounts_proxy), G_MAXINT);
g_object_bind_property (G_OBJECT (manager->priv->accounts_proxy), g_object_bind_property (G_OBJECT (priv->accounts_proxy),
"has-multiple-users", "has-multiple-users",
G_OBJECT (manager), G_OBJECT (manager),
"has-multiple-users", "has-multiple-users",
G_BINDING_SYNC_CREATE); G_BINDING_SYNC_CREATE);
g_signal_connect (manager->priv->accounts_proxy, g_signal_connect (priv->accounts_proxy,
"user-added", "user-added",
G_CALLBACK (on_new_user_in_accounts_service), G_CALLBACK (on_new_user_in_accounts_service),
manager); manager);
g_signal_connect (manager->priv->accounts_proxy, g_signal_connect (priv->accounts_proxy,
"user-deleted", "user-deleted",
G_CALLBACK (on_user_removed_in_accounts_service), G_CALLBACK (on_user_removed_in_accounts_service),
manager); manager);
@ -353,7 +328,7 @@ index e7e26b1..9f3d6e5 100644
+static void +static void
+load_os_release (ActUserManager *manager) +load_os_release (ActUserManager *manager)
+{ +{
+ ActUserManagerPrivate *priv = manager->priv; + ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
+ g_autoptr(GFile) file = NULL; + g_autoptr(GFile) file = NULL;
+ g_autoptr(GError) error = NULL; + g_autoptr(GError) error = NULL;
+ g_autofree char *contents = NULL; + g_autofree char *contents = NULL;
@ -415,34 +390,33 @@ index e7e26b1..9f3d6e5 100644
static void static void
act_user_manager_init (ActUserManager *manager) act_user_manager_init (ActUserManager *manager)
{ {
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
manager->priv = ACT_USER_MANAGER_GET_PRIVATE (manager);
act_user_manager_error_quark (); /* register dbus errors */ act_user_manager_error_quark (); /* register dbus errors */
/* sessions */ /* sessions */
manager->priv->sessions = g_hash_table_new_full (g_str_hash, priv->sessions = g_hash_table_new_full (g_str_hash,
g_str_equal, g_str_equal,
g_free, g_free,
g_object_unref); g_object_unref);
/* users */ /* users */
manager->priv->normal_users_by_name = g_hash_table_new_full (g_str_hash, priv->normal_users_by_name = g_hash_table_new_full (g_str_hash,
g_str_equal, g_str_equal,
g_free, g_free,
g_object_unref); g_object_unref);
manager->priv->system_users_by_name = g_hash_table_new_full (g_str_hash, priv->system_users_by_name = g_hash_table_new_full (g_str_hash,
g_str_equal, g_str_equal,
g_free, g_free,
g_object_unref); g_object_unref);
manager->priv->users_by_object_path = g_hash_table_new_full (g_str_hash, priv->users_by_object_path = g_hash_table_new_full (g_str_hash,
g_str_equal, g_str_equal,
NULL, NULL,
g_object_unref); g_object_unref);
manager->priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (manager->priv->connection == NULL) { if (priv->connection == NULL) {
if (error != NULL) { if (error != NULL) {
g_warning ("Failed to connect to the D-Bus daemon: %s", error->message); g_warning ("Failed to connect to the D-Bus daemon: %s", error->message);
} else { } else {
@ -455,69 +429,69 @@ index e7e26b1..9f3d6e5 100644
+ load_os_release (manager); + load_os_release (manager);
+ +
manager->priv->seat.state = ACT_USER_MANAGER_SEAT_STATE_UNLOADED; priv->seat.state = ACT_USER_MANAGER_SEAT_STATE_UNLOADED;
} }
static void static void
act_user_manager_finalize (GObject *object) act_user_manager_finalize (GObject *object)
{ {
ActUserManager *manager; ActUserManager *manager = ACT_USER_MANAGER (object);
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
GSList *node; GSList *node;
g_debug ("ActUserManager: finalizing user manager"); g_debug ("ActUserManager: finalizing user manager");
g_return_if_fail (object != NULL); g_slist_foreach (priv->new_sessions,
g_return_if_fail (ACT_IS_USER_MANAGER (object));
manager = ACT_USER_MANAGER (object);
g_return_if_fail (manager->priv != NULL);
g_slist_foreach (manager->priv->new_sessions,
(GFunc) unload_new_session, NULL); (GFunc) unload_new_session, NULL);
g_slist_free (manager->priv->new_sessions); g_slist_free (priv->new_sessions);
g_slist_foreach (manager->priv->fetch_user_requests, g_slist_foreach (priv->fetch_user_requests,
(GFunc) free_fetch_user_request, NULL); (GFunc) free_fetch_user_request, NULL);
g_slist_free (manager->priv->fetch_user_requests); g_slist_free (priv->fetch_user_requests);
g_slist_free (manager->priv->new_users_inhibiting_load); g_slist_free (priv->new_users_inhibiting_load);
node = manager->priv->new_users; node = priv->new_users;
while (node != NULL) { while (node != NULL) {
@@ -2899,141 +2976,179 @@ act_user_manager_finalize (GObject *object) ActUser *user;
GSList *next_node;
user = ACT_USER (node->data);
next_node = node->next;
@@ -3071,143 +3148,181 @@ act_user_manager_finalize (GObject *object)
#ifdef WITH_SYSTEMD #ifdef WITH_SYSTEMD
if (manager->priv->seat.session_monitor != NULL) { if (priv->seat.session_monitor != NULL) {
sd_login_monitor_unref (manager->priv->seat.session_monitor); sd_login_monitor_unref (priv->seat.session_monitor);
} }
if (manager->priv->seat.session_monitor_stream != NULL) { if (priv->seat.session_monitor_stream != NULL) {
g_object_unref (manager->priv->seat.session_monitor_stream); g_object_unref (priv->seat.session_monitor_stream);
} }
if (manager->priv->seat.session_monitor_source_id != 0) { if (priv->seat.session_monitor_source_id != 0) {
g_source_remove (manager->priv->seat.session_monitor_source_id); g_source_remove (priv->seat.session_monitor_source_id);
} }
#endif #endif
if (manager->priv->accounts_proxy != NULL) { if (priv->accounts_proxy != NULL) {
g_object_unref (manager->priv->accounts_proxy); g_object_unref (priv->accounts_proxy);
} }
if (manager->priv->load_id > 0) { if (priv->load_id > 0) {
g_source_remove (manager->priv->load_id); g_source_remove (priv->load_id);
manager->priv->load_id = 0; priv->load_id = 0;
} }
g_hash_table_destroy (manager->priv->sessions); g_hash_table_destroy (priv->sessions);
g_hash_table_destroy (manager->priv->normal_users_by_name); g_hash_table_destroy (priv->normal_users_by_name);
g_hash_table_destroy (manager->priv->system_users_by_name); g_hash_table_destroy (priv->system_users_by_name);
g_hash_table_destroy (manager->priv->users_by_object_path); g_hash_table_destroy (priv->users_by_object_path);
+ g_free (manager->priv->os_id); + g_free (priv->os_id);
+ g_free (manager->priv->os_version_id); + g_free (priv->os_version_id);
+ +
G_OBJECT_CLASS (act_user_manager_parent_class)->finalize (object); G_OBJECT_CLASS (act_user_manager_parent_class)->finalize (object);
} }
@ -556,14 +530,15 @@ index e7e26b1..9f3d6e5 100644
gboolean gboolean
act_user_manager_no_service (ActUserManager *manager) act_user_manager_no_service (ActUserManager *manager)
{ {
return manager->priv->accounts_proxy == NULL; ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
return priv->accounts_proxy == NULL;
} }
+static void +static void
+save_system_info (ActUserManager *manager, +save_system_info (ActUserManager *manager,
+ const char *user_path) + const char *user_path)
+{ +{
+ ActUserManagerPrivate *priv = manager->priv; + ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
+ ActUserSystem *user_system_proxy = NULL; + ActUserSystem *user_system_proxy = NULL;
+ g_autoptr(GError) error = NULL; + g_autoptr(GError) error = NULL;
+ +
@ -611,6 +586,7 @@ index e7e26b1..9f3d6e5 100644
ActUserAccountType accounttype, ActUserAccountType accounttype,
GError **error) GError **error)
{ {
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
GError *local_error = NULL; GError *local_error = NULL;
gboolean res; gboolean res;
g_autofree gchar *path = NULL; g_autofree gchar *path = NULL;
@ -619,9 +595,9 @@ index e7e26b1..9f3d6e5 100644
g_debug ("ActUserManager: Creating user '%s', '%s', %d", g_debug ("ActUserManager: Creating user '%s', '%s', %d",
username, fullname, accounttype); username, fullname, accounttype);
g_assert (manager->priv->accounts_proxy != NULL); g_assert (priv->accounts_proxy != NULL);
res = accounts_accounts_call_create_user_sync (manager->priv->accounts_proxy, res = accounts_accounts_call_create_user_sync (priv->accounts_proxy,
username, username,
fullname, fullname,
accounttype, accounttype,
@ -665,8 +641,7 @@ index e7e26b1..9f3d6e5 100644
* *
* Asynchronously creates a user account on the system. * Asynchronously creates a user account on the system.
* *
@@ -3077,105 +3192,110 @@ act_user_manager_create_user_async (ActUserManager *manager, @@ -3253,106 +3368,111 @@ act_user_manager_create_user_async (ActUserManager *manager,
* act_user_manager_create_user_finish:
* @manager: a #ActUserManager * @manager: a #ActUserManager
* @result: a #GAsyncResult * @result: a #GAsyncResult
* @error: a #GError * @error: a #GError
@ -684,6 +659,7 @@ index e7e26b1..9f3d6e5 100644
GAsyncResult *result, GAsyncResult *result,
GError **error) GError **error)
{ {
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
GAsyncResult *inner_result; GAsyncResult *inner_result;
ActUser *user = NULL; ActUser *user = NULL;
g_autofree gchar *path = NULL; g_autofree gchar *path = NULL;
@ -694,7 +670,7 @@ index e7e26b1..9f3d6e5 100644
return FALSE; return FALSE;
} }
if (accounts_accounts_call_create_user_finish (manager->priv->accounts_proxy, if (accounts_accounts_call_create_user_finish (priv->accounts_proxy,
&path, inner_result, &remote_error)) { &path, inner_result, &remote_error)) {
+ +
+ save_system_info (manager, path); + save_system_info (manager, path);
@ -725,6 +701,7 @@ index e7e26b1..9f3d6e5 100644
const char *username, const char *username,
GError **error) GError **error)
{ {
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
GError *local_error = NULL; GError *local_error = NULL;
gboolean res; gboolean res;
g_autofree gchar *path = NULL; g_autofree gchar *path = NULL;
@ -732,9 +709,9 @@ index e7e26b1..9f3d6e5 100644
g_debug ("ActUserManager: Caching user '%s'", g_debug ("ActUserManager: Caching user '%s'",
username); username);
g_assert (manager->priv->accounts_proxy != NULL); g_assert (priv->accounts_proxy != NULL);
res = accounts_accounts_call_cache_user_sync (manager->priv->accounts_proxy, res = accounts_accounts_call_cache_user_sync (priv->accounts_proxy,
username, username,
&path, &path,
NULL, NULL,
@ -775,9 +752,8 @@ index e7e26b1..9f3d6e5 100644
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GTask *task; ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
@@ -3199,60 +3319,63 @@ act_user_manager_cache_user_async (ActUserManager *manager, @@ -3378,60 +3498,63 @@ act_user_manager_cache_user_async (ActUserManager *manager,
* act_user_manager_cache_user_finish:
* @manager: a #ActUserManager * @manager: a #ActUserManager
* @result: a #GAsyncResult * @result: a #GAsyncResult
* @error: a #GError * @error: a #GError
@ -795,6 +771,7 @@ index e7e26b1..9f3d6e5 100644
GAsyncResult *result, GAsyncResult *result,
GError **error) GError **error)
{ {
ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
GAsyncResult *inner_result; GAsyncResult *inner_result;
ActUser *user = NULL; ActUser *user = NULL;
g_autofree gchar *path = NULL; g_autofree gchar *path = NULL;
@ -805,7 +782,7 @@ index e7e26b1..9f3d6e5 100644
return FALSE; return FALSE;
} }
if (accounts_accounts_call_cache_user_finish (manager->priv->accounts_proxy, if (accounts_accounts_call_cache_user_finish (priv->accounts_proxy,
&path, inner_result, &remote_error)) { &path, inner_result, &remote_error)) {
+ +
+ save_system_info (manager, path); + save_system_info (manager, path);
@ -839,7 +816,79 @@ index e7e26b1..9f3d6e5 100644
const char *username, const char *username,
GError **error) GError **error)
{ {
GError *local_error = NULL; ActUserManagerPrivate *priv = act_user_manager_get_instance_private (manager);
diff --git a/src/libaccountsservice/meson.build b/src/libaccountsservice/meson.build
index 4e134db..9e85bba 100644
--- a/src/libaccountsservice/meson.build
+++ b/src/libaccountsservice/meson.build
@@ -21,60 +21,67 @@ enum_types = 'act-user-enum-types'
enum_sources = gnome.mkenums(
enum_types,
sources: headers,
c_template: enum_types + '.c.template',
h_template: enum_types + '.h.template',
install_header: true,
install_dir: join_paths(act_pkgincludedir, subdir),
)
dbus_sources = []
ifaces = [
'Manager',
'Seat',
'Session',
]
namespace = 'ConsoleKit'
prefix = 'org.freedesktop.' + namespace
foreach iface: ifaces
dbus_sources += gnome.gdbus_codegen(
'ck-@0@-generated'.format(iface.to_lower()),
'@0@.@1@.xml'.format(prefix, iface),
interface_prefix: prefix,
namespace: namespace,
)
endforeach
+dbus_sources += gnome.gdbus_codegen(
+ 'com.redhat.AccountsServiceUser.System',
+ join_paths(data_dir, 'com.redhat.AccountsServiceUser.System.xml'),
+ interface_prefix: 'com.redhat.AccountsService',
+ namespace: 'Act',
+)
+
deps = [
crypt_dep,
gio_unix_dep,
glib_dep,
libaccounts_generated_dep,
]
symbol_map = join_paths(meson.current_source_dir(), 'symbol.map')
ldflags = cc.get_supported_link_arguments('-Wl,--version-script,@0@'.format(symbol_map))
if enable_systemd or enable_elogind
deps += logind_dep
endif
libaccountsservice = shared_library(
act_name,
sources: sources + enum_sources + dbus_sources,
version: libversion,
include_directories: top_inc,
dependencies: deps,
c_args: '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name()),
link_args: ldflags,
link_depends: symbol_map,
install: true,
)
libaccountsservice_dep = declare_dependency(
sources: enum_sources[1],
include_directories: include_directories('.'),
dependencies: [gio_dep, glib_dep],
-- --
2.21.0 2.27.0

View File

@ -1,910 +0,0 @@
From c66cee942242a731082f0fac649f3f9569ae99a3 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Wed, 8 Aug 2018 16:11:56 -0400
Subject: [PATCH 1/2] user: add new Session/SessionType properties to replace
XSession
Having a property called XSession in the API makes little
sense when wayland has taken the world by storm.
This commit adds new "Session" property without the "X" in the name,
and an additional property "SessionType" that can be either
"wayland" or "x11".
---
data/org.freedesktop.Accounts.User.xml | 103 +++++++++++++++++++++
src/libaccountsservice/act-user.c | 93 +++++++++++++++++++
src/libaccountsservice/act-user.h | 6 ++
src/user.c | 121 +++++++++++++++++++++++++
4 files changed, 323 insertions(+)
diff --git a/data/org.freedesktop.Accounts.User.xml b/data/org.freedesktop.Accounts.User.xml
index 4ab989a..7fc3c61 100644
--- a/data/org.freedesktop.Accounts.User.xml
+++ b/data/org.freedesktop.Accounts.User.xml
@@ -141,60 +141,143 @@
<doc:term>org.freedesktop.accounts.user-administration</doc:term>
<doc:definition>To change the language of another user</doc:definition>
</doc:item>
</doc:list>
</doc:permission>
<doc:errors>
<doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error>
<doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error>
</doc:errors>
</doc:doc>
</method>
<method name="SetXSession">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="user_set_x_session"/>
<arg name="x_session" direction="in" type="s">
<doc:doc>
<doc:summary>
The new xsession to start (e.g. "gnome")
</doc:summary>
</doc:doc>
</arg>
<doc:doc>
<doc:description>
<doc:para>
Sets the users x session.
</doc:para>
<doc:para>
The expectation is that display managers will log the user in to this
specified session, if available.
+
+ Note this call is deprecated and has been superceded by SetSession since
+ not all graphical sessions use X as the display server.
+ </doc:para>
+ </doc:description>
+ <doc:permission>
+ The caller needs one of the following PolicyKit authorizations:
+ <doc:list>
+ <doc:item>
+ <doc:term>org.freedesktop.accounts.change-own-user-data</doc:term>
+ <doc:definition>To change his own language</doc:definition>
+ </doc:item>
+ <doc:item>
+ <doc:term>org.freedesktop.accounts.user-administration</doc:term>
+ <doc:definition>To change the language of another user</doc:definition>
+ </doc:item>
+ </doc:list>
+ </doc:permission>
+ <doc:errors>
+ <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error>
+ <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error>
+ </doc:errors>
+ </doc:doc>
+ </method>
+
+ <method name="SetSession">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="user_set_session"/>
+ <arg name="session" direction="in" type="s">
+ <doc:doc>
+ <doc:summary>
+ The new session to start (e.g. "gnome-xorg")
+ </doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ Sets the users wayland or x session.
+ </doc:para>
+ <doc:para>
+ The expectation is that display managers will log the user in to this
+ specified session, if available.
+ </doc:para>
+ </doc:description>
+ <doc:permission>
+ The caller needs one of the following PolicyKit authorizations:
+ <doc:list>
+ <doc:item>
+ <doc:term>org.freedesktop.accounts.change-own-user-data</doc:term>
+ <doc:definition>To change his own language</doc:definition>
+ </doc:item>
+ <doc:item>
+ <doc:term>org.freedesktop.accounts.user-administration</doc:term>
+ <doc:definition>To change the language of another user</doc:definition>
+ </doc:item>
+ </doc:list>
+ </doc:permission>
+ <doc:errors>
+ <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error>
+ <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error>
+ </doc:errors>
+ </doc:doc>
+ </method>
+
+ <method name="SetSessionType">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="user_set_session_type"/>
+ <arg name="session_type" direction="in" type="s">
+ <doc:doc>
+ <doc:summary>
+ The type of the new session to start (e.g. "wayland" or "x11")
+ </doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ Sets the session type of the users session.
+ </doc:para>
+ <doc:para>
+ Display managers may use this property to decide what type of display server to use when
+ loading the session
</doc:para>
</doc:description>
<doc:permission>
The caller needs one of the following PolicyKit authorizations:
<doc:list>
<doc:item>
<doc:term>org.freedesktop.accounts.change-own-user-data</doc:term>
<doc:definition>To change his own language</doc:definition>
</doc:item>
<doc:item>
<doc:term>org.freedesktop.accounts.user-administration</doc:term>
<doc:definition>To change the language of another user</doc:definition>
</doc:item>
</doc:list>
</doc:permission>
<doc:errors>
<doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error>
<doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error>
</doc:errors>
</doc:doc>
</method>
<method name="SetLocation">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="location" direction="in" type="s">
<doc:doc>
<doc:summary>
The new location as a freeform string.
</doc:summary>
</doc:doc>
@@ -641,60 +724,80 @@
<property name="Shell" type="s" access="read">
<doc:doc>
<doc:description>
<doc:para>
The users shell.
</doc:para>
</doc:description>
</doc:doc>
</property>
<property name="Email" type="s" access="read">
<doc:doc>
<doc:description>
<doc:para>
The email address.
</doc:para>
</doc:description>
</doc:doc>
</property>
<property name="Language" type="s" access="read">
<doc:doc>
<doc:description>
<doc:para>
The users language, as a locale specification like "de_DE.UTF-8".
</doc:para>
</doc:description>
</doc:doc>
</property>
+ <property name="Session" type="s" access="read">
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ The users Wayland or X session.
+ </doc:para>
+ </doc:description>
+ </doc:doc>
+ </property>
+
+ <property name="SessionType" type="s" access="read">
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ The type of session the user should use (e.g. "wayland" or "x11")
+ </doc:para>
+ </doc:description>
+ </doc:doc>
+ </property>
+
<property name="XSession" type="s" access="read">
<doc:doc>
<doc:description>
<doc:para>
The users x session.
</doc:para>
</doc:description>
</doc:doc>
</property>
<property name="Location" type="s" access="read">
<doc:doc>
<doc:description>
<doc:para>
The users location.
</doc:para>
</doc:description>
</doc:doc>
</property>
<property name="LoginFrequency" type="t" access="read">
<doc:doc>
<doc:description>
<doc:para>
How often the user has logged in.
</doc:para>
</doc:description>
</doc:doc>
</property>
diff --git a/src/libaccountsservice/act-user.c b/src/libaccountsservice/act-user.c
index 7162221..dd8f81b 100644
--- a/src/libaccountsservice/act-user.c
+++ b/src/libaccountsservice/act-user.c
@@ -999,60 +999,98 @@ act_user_get_icon_file (ActUser *user)
const char *
act_user_get_language (ActUser *user)
{
g_return_val_if_fail (ACT_IS_USER (user), NULL);
if (user->accounts_proxy == NULL)
return NULL;
return accounts_user_get_language (user->accounts_proxy);
}
/**
* act_user_get_x_session:
* @user: a #ActUser
*
* Returns the path to the configured X session for @user.
*
* Returns: (transfer none): a path to an icon
*/
const char *
act_user_get_x_session (ActUser *user)
{
g_return_val_if_fail (ACT_IS_USER (user), NULL);
if (user->accounts_proxy == NULL)
return NULL;
return accounts_user_get_xsession (user->accounts_proxy);
}
+/**
+ * act_user_get_session:
+ * @user: a #ActUser
+ *
+ * Returns the path to the configured session for @user.
+ *
+ * Returns: (transfer none): a path to an icon
+ */
+const char *
+act_user_get_session (ActUser *user)
+{
+ g_return_val_if_fail (ACT_IS_USER (user), NULL);
+
+ if (user->accounts_proxy == NULL)
+ return NULL;
+
+ return accounts_user_get_session (user->accounts_proxy);
+}
+
+/**
+ * act_user_get_session_type:
+ * @user: a #ActUser
+ *
+ * Returns the type of the configured session for @user.
+ *
+ * Returns: (transfer none): a path to an icon
+ */
+const char *
+act_user_get_session_type (ActUser *user)
+{
+ g_return_val_if_fail (ACT_IS_USER (user), NULL);
+
+ if (user->accounts_proxy == NULL)
+ return NULL;
+
+ return accounts_user_get_session_type (user->accounts_proxy);
+}
+
/**
* act_user_get_object_path:
* @user: a #ActUser
*
* Returns the user accounts service object path of @user,
* or %NULL if @user doesn't have an object path associated
* with it.
*
* Returns: (transfer none): the object path of the user
*/
const char *
act_user_get_object_path (ActUser *user)
{
g_return_val_if_fail (ACT_IS_USER (user), NULL);
if (user->accounts_proxy == NULL)
return NULL;
return g_dbus_proxy_get_object_path (G_DBUS_PROXY (user->accounts_proxy));
}
/**
* act_user_get_primary_session_id:
* @user: a #ActUser
*
* Returns the id of the primary session of @user, or %NULL if @user
* has no primary session. The primary session will always be
* graphical and will be chosen from the sessions on the same seat as
* the seat of the session of the calling process.
*
@@ -1310,60 +1348,115 @@ act_user_set_language (ActUser *user,
}
/**
* act_user_set_x_session:
* @user: the user object to alter.
* @x_session: an x session (e.g. gnome)
*
* Assigns a new x session for @user.
*
* Note this function is synchronous and ignores errors.
**/
void
act_user_set_x_session (ActUser *user,
const char *x_session)
{
g_autoptr(GError) error = NULL;
g_return_if_fail (ACT_IS_USER (user));
g_return_if_fail (x_session != NULL);
g_return_if_fail (ACCOUNTS_IS_USER (user->accounts_proxy));
if (!accounts_user_call_set_xsession_sync (user->accounts_proxy,
x_session,
NULL,
&error)) {
g_warning ("SetXSession call failed: %s", error->message);
return;
}
}
+/**
+ * act_user_set_session:
+ * @user: the user object to alter.
+ * @session: a session (e.g. gnome)
+ *
+ * Assigns a new session for @user.
+ *
+ * Note this function is synchronous and ignores errors.
+ **/
+void
+act_user_set_session (ActUser *user,
+ const char *session)
+{
+ g_autoptr(GError) error = NULL;
+
+ g_return_if_fail (ACT_IS_USER (user));
+ g_return_if_fail (session != NULL);
+ g_return_if_fail (ACCOUNTS_IS_USER (user->accounts_proxy));
+
+ if (!accounts_user_call_set_session_sync (user->accounts_proxy,
+ session,
+ NULL,
+ &error)) {
+ g_warning ("SetSession call failed: %s", error->message);
+ return;
+ }
+}
+
+/**
+ * act_user_set_session_type:
+ * @user: the user object to alter.
+ * @session_type: a type of session (e.g. "wayland" or "x11")
+ *
+ * Assigns a type to the session for @user.
+ *
+ * Note this function is synchronous and ignores errors.
+ **/
+void
+act_user_set_session_type (ActUser *user,
+ const char *session_type)
+{
+ g_autoptr(GError) error = NULL;
+
+ g_return_if_fail (ACT_IS_USER (user));
+ g_return_if_fail (session_type != NULL);
+ g_return_if_fail (ACCOUNTS_IS_USER (user->accounts_proxy));
+
+ if (!accounts_user_call_set_session_type_sync (user->accounts_proxy,
+ session_type,
+ NULL,
+ &error)) {
+ g_warning ("SetSessionType call failed: %s", error->message);
+ return;
+ }
+}
/**
* act_user_set_location:
* @user: the user object to alter.
* @location: a location
*
* Assigns a new location for @user.
*
* Note this function is synchronous and ignores errors.
**/
void
act_user_set_location (ActUser *user,
const char *location)
{
g_autoptr(GError) error = NULL;
g_return_if_fail (ACT_IS_USER (user));
g_return_if_fail (location != NULL);
g_return_if_fail (ACCOUNTS_IS_USER (user->accounts_proxy));
if (!accounts_user_call_set_location_sync (user->accounts_proxy,
location,
NULL,
&error)) {
g_warning ("SetLocation call failed: %s", error->message);
return;
}
}
/**
diff --git a/src/libaccountsservice/act-user.h b/src/libaccountsservice/act-user.h
index c685fcc..2ef13b1 100644
--- a/src/libaccountsservice/act-user.h
+++ b/src/libaccountsservice/act-user.h
@@ -51,79 +51,85 @@ typedef struct _ActUserClass ActUserClass;
GType act_user_get_type (void) G_GNUC_CONST;
const char *act_user_get_object_path (ActUser *user);
uid_t act_user_get_uid (ActUser *user);
const char *act_user_get_user_name (ActUser *user);
const char *act_user_get_real_name (ActUser *user);
ActUserAccountType act_user_get_account_type (ActUser *user);
ActUserPasswordMode act_user_get_password_mode (ActUser *user);
const char *act_user_get_password_hint (ActUser *user);
const char *act_user_get_home_dir (ActUser *user);
const char *act_user_get_shell (ActUser *user);
const char *act_user_get_email (ActUser *user);
const char *act_user_get_location (ActUser *user);
guint act_user_get_num_sessions (ActUser *user);
guint act_user_get_num_sessions_anywhere (ActUser *user);
gboolean act_user_is_logged_in (ActUser *user);
gboolean act_user_is_logged_in_anywhere (ActUser *user);
int act_user_get_login_frequency (ActUser *user);
gint64 act_user_get_login_time (ActUser *user);
const GVariant*act_user_get_login_history (ActUser *user);
gboolean act_user_get_locked (ActUser *user);
gboolean act_user_get_automatic_login (ActUser *user);
gboolean act_user_is_system_account (ActUser *user);
gboolean act_user_is_local_account (ActUser *user);
gboolean act_user_is_nonexistent (ActUser *user);
const char *act_user_get_icon_file (ActUser *user);
const char *act_user_get_language (ActUser *user);
const char *act_user_get_x_session (ActUser *user);
+const char *act_user_get_session (ActUser *user);
+const char *act_user_get_session_type (ActUser *user);
const char *act_user_get_primary_session_id (ActUser *user);
gint act_user_collate (ActUser *user1,
ActUser *user2);
gboolean act_user_is_loaded (ActUser *user);
void act_user_get_password_expiration_policy (ActUser *user,
gint64 *expiration_time,
gint64 *last_change_time,
gint64 *min_days_between_changes,
gint64 *max_days_between_changes,
gint64 *days_to_warn,
gint64 *days_after_expiration_until_lock);
void act_user_set_email (ActUser *user,
const char *email);
void act_user_set_language (ActUser *user,
const char *language);
void act_user_set_x_session (ActUser *user,
const char *x_session);
+void act_user_set_session (ActUser *user,
+ const char *session);
+void act_user_set_session_type (ActUser *user,
+ const char *session_type);
void act_user_set_location (ActUser *user,
const char *location);
void act_user_set_user_name (ActUser *user,
const char *user_name);
void act_user_set_real_name (ActUser *user,
const char *real_name);
void act_user_set_icon_file (ActUser *user,
const char *icon_file);
void act_user_set_account_type (ActUser *user,
ActUserAccountType account_type);
void act_user_set_password (ActUser *user,
const gchar *password,
const gchar *hint);
void act_user_set_password_hint (ActUser *user,
const gchar *hint);
void act_user_set_password_mode (ActUser *user,
ActUserPasswordMode password_mode);
void act_user_set_locked (ActUser *user,
gboolean locked);
void act_user_set_automatic_login (ActUser *user,
gboolean enabled);
#if GLIB_CHECK_VERSION(2, 44, 0)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ActUser, g_object_unref)
#endif
G_END_DECLS
#endif /* __ACT_USER_H__ */
diff --git a/src/user.c b/src/user.c
index 174530f..94c0244 100644
--- a/src/user.c
+++ b/src/user.c
@@ -232,60 +232,75 @@ user_update_from_pwent (User *user,
user->account_expiration_policy_known = TRUE;
}
accounts_user_set_password_mode (ACCOUNTS_USER (user), mode);
is_system_account = !user_classify_is_human (accounts_user_get_uid (ACCOUNTS_USER (user)),
accounts_user_get_user_name (ACCOUNTS_USER (user)),
accounts_user_get_shell (ACCOUNTS_USER (user)),
passwd);
accounts_user_set_system_account (ACCOUNTS_USER (user), is_system_account);
g_object_thaw_notify (G_OBJECT (user));
}
void
user_update_from_keyfile (User *user,
GKeyFile *keyfile)
{
gchar *s;
g_object_freeze_notify (G_OBJECT (user));
s = g_key_file_get_string (keyfile, "User", "Language", NULL);
if (s != NULL) {
accounts_user_set_language (ACCOUNTS_USER (user), s);
g_clear_pointer (&s, g_free);
}
s = g_key_file_get_string (keyfile, "User", "XSession", NULL);
if (s != NULL) {
accounts_user_set_xsession (ACCOUNTS_USER (user), s);
+
+ /* for backward compat */
+ accounts_user_set_session (ACCOUNTS_USER (user), s);
+ g_clear_pointer (&s, g_free);
+ }
+
+ s = g_key_file_get_string (keyfile, "User", "Session", NULL);
+ if (s != NULL) {
+ accounts_user_set_session (ACCOUNTS_USER (user), s);
+ g_clear_pointer (&s, g_free);
+ }
+
+ s = g_key_file_get_string (keyfile, "User", "SessionType", NULL);
+ if (s != NULL) {
+ accounts_user_set_session_type (ACCOUNTS_USER (user), s);
g_clear_pointer (&s, g_free);
}
s = g_key_file_get_string (keyfile, "User", "Email", NULL);
if (s != NULL) {
accounts_user_set_email (ACCOUNTS_USER (user), s);
g_clear_pointer (&s, g_free);
}
s = g_key_file_get_string (keyfile, "User", "Location", NULL);
if (s != NULL) {
accounts_user_set_location (ACCOUNTS_USER (user), s);
g_clear_pointer (&s, g_free);
}
s = g_key_file_get_string (keyfile, "User", "PasswordHint", NULL);
if (s != NULL) {
accounts_user_set_password_hint (ACCOUNTS_USER (user), s);
g_clear_pointer (&s, g_free);
}
s = g_key_file_get_string (keyfile, "User", "Icon", NULL);
if (s != NULL) {
accounts_user_set_icon_file (ACCOUNTS_USER (user), s);
g_clear_pointer (&s, g_free);
}
if (g_key_file_has_key (keyfile, "User", "SystemAccount", NULL)) {
gboolean system_account;
@@ -299,60 +314,66 @@ user_update_from_keyfile (User *user,
g_object_thaw_notify (G_OBJECT (user));
}
void
user_update_local_account_property (User *user,
gboolean local)
{
accounts_user_set_local_account (ACCOUNTS_USER (user), local);
}
void
user_update_system_account_property (User *user,
gboolean system)
{
accounts_user_set_system_account (ACCOUNTS_USER (user), system);
}
static void
user_save_to_keyfile (User *user,
GKeyFile *keyfile)
{
g_key_file_remove_group (keyfile, "User", NULL);
if (accounts_user_get_email (ACCOUNTS_USER (user)))
g_key_file_set_string (keyfile, "User", "Email", accounts_user_get_email (ACCOUNTS_USER (user)));
if (accounts_user_get_language (ACCOUNTS_USER (user)))
g_key_file_set_string (keyfile, "User", "Language", accounts_user_get_language (ACCOUNTS_USER (user)));
+ if (accounts_user_get_session (ACCOUNTS_USER (user)))
+ g_key_file_set_string (keyfile, "User", "Session", accounts_user_get_session (ACCOUNTS_USER (user)));
+
+ if (accounts_user_get_session_type (ACCOUNTS_USER (user)))
+ g_key_file_set_string (keyfile, "User", "SessionType", accounts_user_get_session_type (ACCOUNTS_USER (user)));
+
if (accounts_user_get_xsession (ACCOUNTS_USER (user)))
g_key_file_set_string (keyfile, "User", "XSession", accounts_user_get_xsession (ACCOUNTS_USER (user)));
if (accounts_user_get_location (ACCOUNTS_USER (user)))
g_key_file_set_string (keyfile, "User", "Location", accounts_user_get_location (ACCOUNTS_USER (user)));
if (accounts_user_get_password_hint (ACCOUNTS_USER (user)))
g_key_file_set_string (keyfile, "User", "PasswordHint", accounts_user_get_password_hint (ACCOUNTS_USER (user)));
if (accounts_user_get_icon_file (ACCOUNTS_USER (user)))
g_key_file_set_string (keyfile, "User", "Icon", accounts_user_get_icon_file (ACCOUNTS_USER (user)));
g_key_file_set_boolean (keyfile, "User", "SystemAccount", accounts_user_get_system_account (ACCOUNTS_USER (user)));
user_set_cached (user, TRUE);
}
static void
save_extra_data (User *user)
{
g_autofree gchar *data = NULL;
g_autofree gchar *filename = NULL;
g_autoptr(GError) error = NULL;
user_save_to_keyfile (user, user->keyfile);
data = g_key_file_to_data (user->keyfile, NULL, &error);
if (data == NULL) {
g_warning ("Saving data for user %s failed: %s",
accounts_user_get_user_name (ACCOUNTS_USER (user)), error->message);
@@ -996,60 +1017,158 @@ static gboolean
user_set_language (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *language)
{
User *user = (User*)auser;
int uid;
const gchar *action_id;
if (!get_caller_uid (context, &uid)) {
throw_error (context, ERROR_FAILED, "identifying caller failed");
return FALSE;
}
if (accounts_user_get_uid (ACCOUNTS_USER (user)) == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
daemon_local_check_auth (user->daemon,
user,
action_id,
TRUE,
user_change_language_authorized_cb,
context,
g_strdup (language),
(GDestroyNotify)g_free);
return TRUE;
}
+static void
+user_change_session_authorized_cb (Daemon *daemon,
+ User *user,
+ GDBusMethodInvocation *context,
+ gpointer user_data)
+
+{
+ const gchar *session = user_data;
+
+ if (g_strcmp0 (accounts_user_get_session (ACCOUNTS_USER (user)), session) != 0) {
+ accounts_user_set_session (ACCOUNTS_USER (user), session);
+
+ save_extra_data (user);
+ }
+
+ accounts_user_complete_set_session (ACCOUNTS_USER (user), context);
+}
+
+static gboolean
+user_set_session (AccountsUser *auser,
+ GDBusMethodInvocation *context,
+ const gchar *session)
+{
+ User *user = (User*)auser;
+ int uid;
+ const gchar *action_id;
+
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (accounts_user_get_uid (ACCOUNTS_USER (user)) == (uid_t) uid)
+ action_id = "org.freedesktop.accounts.change-own-user-data";
+ else
+ action_id = "org.freedesktop.accounts.user-administration";
+
+ daemon_local_check_auth (user->daemon,
+ user,
+ action_id,
+ TRUE,
+ user_change_session_authorized_cb,
+ context,
+ g_strdup (session),
+ (GDestroyNotify) g_free);
+
+ return TRUE;
+}
+
+static void
+user_change_session_type_authorized_cb (Daemon *daemon,
+ User *user,
+ GDBusMethodInvocation *context,
+ gpointer user_data)
+
+{
+ const gchar *session_type = user_data;
+
+ if (g_strcmp0 (accounts_user_get_session_type (ACCOUNTS_USER (user)), session_type) != 0) {
+ accounts_user_set_session_type (ACCOUNTS_USER (user), session_type);
+
+ save_extra_data (user);
+ }
+
+ accounts_user_complete_set_session_type (ACCOUNTS_USER (user), context);
+}
+
+static gboolean
+user_set_session_type (AccountsUser *auser,
+ GDBusMethodInvocation *context,
+ const gchar *session_type)
+{
+ User *user = (User*)auser;
+ int uid;
+ const gchar *action_id;
+
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (accounts_user_get_uid (ACCOUNTS_USER (user)) == (uid_t) uid)
+ action_id = "org.freedesktop.accounts.change-own-user-data";
+ else
+ action_id = "org.freedesktop.accounts.user-administration";
+
+ daemon_local_check_auth (user->daemon,
+ user,
+ action_id,
+ TRUE,
+ user_change_session_type_authorized_cb,
+ context,
+ g_strdup (session_type),
+ (GDestroyNotify) g_free);
+
+ return TRUE;
+}
+
static void
user_change_x_session_authorized_cb (Daemon *daemon,
User *user,
GDBusMethodInvocation *context,
gpointer data)
{
gchar *x_session = data;
if (g_strcmp0 (accounts_user_get_xsession (ACCOUNTS_USER (user)), x_session) != 0) {
accounts_user_set_xsession (ACCOUNTS_USER (user), x_session);
save_extra_data (user);
}
accounts_user_complete_set_xsession (ACCOUNTS_USER (user), context);
}
static gboolean
user_set_x_session (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *x_session)
{
User *user = (User*)auser;
int uid;
const gchar *action_id;
if (!get_caller_uid (context, &uid)) {
throw_error (context, ERROR_FAILED, "identifying caller failed");
return FALSE;
@@ -1966,41 +2085,43 @@ user_finalize (GObject *object)
}
static void
user_class_init (UserClass *class)
{
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = user_finalize;
}
static void
user_accounts_user_iface_init (AccountsUserIface *iface)
{
iface->handle_set_account_type = user_set_account_type;
iface->handle_set_automatic_login = user_set_automatic_login;
iface->handle_set_email = user_set_email;
iface->handle_set_home_directory = user_set_home_directory;
iface->handle_set_icon_file = user_set_icon_file;
iface->handle_set_language = user_set_language;
iface->handle_set_location = user_set_location;
iface->handle_set_locked = user_set_locked;
iface->handle_set_password = user_set_password;
iface->handle_set_password_mode = user_set_password_mode;
iface->handle_set_password_hint = user_set_password_hint;
iface->handle_set_real_name = user_set_real_name;
iface->handle_set_shell = user_set_shell;
iface->handle_set_user_name = user_set_user_name;
iface->handle_set_xsession = user_set_x_session;
+ iface->handle_set_session = user_set_session;
+ iface->handle_set_session_type = user_set_session_type;
iface->handle_get_password_expiration_policy = user_get_password_expiration_policy;
}
static void
user_init (User *user)
{
user->system_bus_connection = NULL;
user->default_icon_file = NULL;
user->login_history = NULL;
user->keyfile = g_key_file_new ();
}
--
2.17.1

View File

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

View File

@ -1,8 +1,8 @@
%global _hardened_build 1 %global _hardened_build 1
Name: accountsservice Name: accountsservice
Version: 0.6.50 Version: 0.6.55
Release: 8%{?dist} Release: 1%{?dist}
Summary: D-Bus interfaces for querying and manipulating user account information Summary: D-Bus interfaces for querying and manipulating user account information
License: GPLv3+ License: GPLv3+
URL: https://www.freedesktop.org/wiki/Software/AccountsService/ URL: https://www.freedesktop.org/wiki/Software/AccountsService/
@ -10,32 +10,27 @@ URL: https://www.freedesktop.org/wiki/Software/AccountsService/
#VCS: git:git://git.freedesktop.org/accountsservice #VCS: git:git://git.freedesktop.org/accountsservice
Source0: http://www.freedesktop.org/software/accountsservice/accountsservice-%{version}.tar.xz Source0: http://www.freedesktop.org/software/accountsservice/accountsservice-%{version}.tar.xz
BuildRequires: gettext-devel
BuildRequires: pkgconfig(dbus-1)
BuildRequires: glib2-devel BuildRequires: glib2-devel
BuildRequires: polkit-devel BuildRequires: polkit-devel
BuildRequires: libtool, automake, autoconf, gettext-devel, intltool
BuildRequires: systemd BuildRequires: systemd
BuildRequires: systemd-devel BuildRequires: systemd-devel
BuildRequires: gobject-introspection-devel BuildRequires: gobject-introspection-devel
BuildRequires: gtk-doc BuildRequires: gtk-doc
BuildRequires: git BuildRequires: git
BuildRequires: meson
Patch01: 0001-user-add-new-Session-SessionType-properties-to-repla.patch
Patch02: 0002-user-export-new-Saved-property.patch
Patch10: 0001-daemon-Fix-warnings-about-type-punning.patch
Patch20: 0001-lib-don-t-set-loaded-state-until-seat-is-fetched.patch
Patch30: 0001-data-don-t-send-change-updates-for-login-history.patch
Patch40: 0001-daemon-if-no-local-users-check-if-machine-is-enrolle.patch
Patch90: 0001-lib-save-os-when-creating-user.patch
Requires: polkit Requires: polkit
Requires: shadow-utils Requires: shadow-utils
%{?systemd_requires} %{?systemd_requires}
Patch10001: 0001-data-don-t-send-change-updates-for-login-history.patch
Patch20001: 0001-daemon-if-no-local-users-check-if-machine-is-enrolle.patch
Patch30001: 0001-lib-save-os-when-creating-user.patch
%description %description
The accountsservice project provides a set of D-Bus interfaces for The accountsservice project provides a set of D-Bus interfaces for
querying and manipulating user account information and an implementation querying and manipulating user account information and an implementation
@ -61,18 +56,15 @@ files needed to build applications that use accountsservice-libs.
%prep %prep
%autosetup -S git %autosetup -S git
autoreconf -f -i
%build %build
export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" %meson -Dgtk_doc=true -Dsystemd=true -Duser_heuristics=true
%configure --enable-user-heuristics %meson_build
make %{?_smp_mflags}
%install %install
make install DESTDIR=$RPM_BUILD_ROOT %meson_install
rm $RPM_BUILD_ROOT%{_libdir}/*.la
rm $RPM_BUILD_ROOT%{_libdir}/*.a
%find_lang accounts-service %find_lang accounts-service
%ldconfig_scriptlets libs %ldconfig_scriptlets libs
@ -88,7 +80,7 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.a
%files -f accounts-service.lang %files -f accounts-service.lang
%license COPYING %license COPYING
%doc README AUTHORS %doc README.md AUTHORS
%{_sysconfdir}/dbus-1/system.d/org.freedesktop.Accounts.conf %{_sysconfdir}/dbus-1/system.d/org.freedesktop.Accounts.conf
%{_libexecdir}/accounts-daemon %{_libexecdir}/accounts-daemon
%{_datadir}/dbus-1/interfaces/org.freedesktop.Accounts.xml %{_datadir}/dbus-1/interfaces/org.freedesktop.Accounts.xml
@ -115,6 +107,10 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.a
%{_datadir}/gtk-doc/html/libaccountsservice/* %{_datadir}/gtk-doc/html/libaccountsservice/*
%changelog %changelog
* Fri Jan 15 2021 Ray Strode <rstrode@redhat.com> - 0.6.55-1
- Rebase to 0.6.55
Resolves: #1846376
* Sun Dec 15 2019 Ray Strode <rstrode@redhat.com> - 0.6.50-8 * Sun Dec 15 2019 Ray Strode <rstrode@redhat.com> - 0.6.50-8
- Don't set HasNoUsers=true if realmd has providers - Don't set HasNoUsers=true if realmd has providers
Related: #1750516 Related: #1750516
@ -279,7 +275,7 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.a
- Fixes CVE-2012-2737 - local file disclosure - Fixes CVE-2012-2737 - local file disclosure
Related: #832532 Related: #832532
* Thu May 30 2012 Matthias Clasen <mclasen@redhatcom> 0.6.21-1 * Thu May 31 2012 Matthias Clasen <mclasen@redhat.com> 0.6.21-1
- Update to 0.6.21 - Update to 0.6.21
* Fri May 04 2012 Ray Strode <rstrode@redhat.com> 0.6.20-1 * Fri May 04 2012 Ray Strode <rstrode@redhat.com> 0.6.20-1