[gnome-settings-daemon/rhel/account-and-subman-plugins: 20/23] subman: Add DBus API to subscribe for updates on already registered system
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/rhel/account-and-subman-plugins: 20/23] subman: Add DBus API to subscribe for updates on already registered system
- Date: Tue, 13 Apr 2021 14:21:52 +0000 (UTC)
commit 7f4e3d1bd460c6925d5fba0d8994cb58e52ce842
Author: Ray Strode <rstrode redhat com>
Date: Sun Jan 24 11:27:42 2021 -0500
subman: Add DBus API to subscribe for updates on already registered system
It's possible an admin may have registered their system without
attaching any subscriptions to it.
At the moment, gnome-settings-daemon only provides a way to register
and subscribe in one step.
This commit adds an API to support doing the last half of the process
on its own.
plugins/subman/gsd-subscription-manager.c | 51 +++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
---
diff --git a/plugins/subman/gsd-subscription-manager.c b/plugins/subman/gsd-subscription-manager.c
index 1f9ca447..705f8b11 100644
--- a/plugins/subman/gsd-subscription-manager.c
+++ b/plugins/subman/gsd-subscription-manager.c
@@ -46,6 +46,7 @@ static const gchar introspection_xml[] =
" <arg type='a{sv}' name='options' direction='in'/>"
" </method>"
" <method name='Unregister'/>"
+" <method name='Attach'/>"
" <property name='InstalledProducts' type='aa{sv}' access='read'/>"
" <property name='SubscriptionStatus' type='u' access='read'/>"
" </interface>"
@@ -696,6 +697,50 @@ _client_unregister (GsdSubscriptionManager *manager, GError **error)
return TRUE;
}
+static gboolean
+_client_attach (GsdSubscriptionManager *manager,
+ GError **error)
+{
+ g_autoptr(GSubprocess) subprocess = NULL;
+ g_autoptr(GBytes) stderr_buf = NULL;
+ gint rc;
+
+ g_debug ("spawning %s", LIBEXECDIR "/gsd-subman-helper");
+ subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDERR_PIPE,
+ error,
+ "pkexec", LIBEXECDIR "/gsd-subman-helper",
+ "--kind", "auto-attach",
+ NULL);
+ if (subprocess == NULL) {
+ g_prefix_error (error, "failed to find pkexec: ");
+ return FALSE;
+ }
+
+ if (!g_subprocess_communicate (subprocess, NULL, NULL, NULL, &stderr_buf, error)) {
+ g_prefix_error (error, "failed to run pkexec: ");
+ return FALSE;
+ }
+
+ rc = g_subprocess_get_exit_status (subprocess);
+ if (rc != 0) {
+ if (g_bytes_get_size (stderr_buf) == 0) {
+ g_set_error_literal (error, G_IO_ERROR, rc,
+ "Failed to run helper without stderr");
+ return FALSE;
+ }
+
+ g_set_error (error, G_IO_ERROR, rc,
+ "%.*s",
+ (int) g_bytes_get_size (stderr_buf),
+ (char *) g_bytes_get_data (stderr_buf, NULL));
+ }
+
+ if (!_client_subscription_status_update (manager, error))
+ return FALSE;
+ _client_maybe__show_notification (manager);
+ return TRUE;
+}
+
static gboolean
_client_update_config (GsdSubscriptionManager *manager, GError **error)
{
@@ -1029,6 +1074,12 @@ handle_method_call (GDBusConnection *connection,
return;
}
g_dbus_method_invocation_return_value (invocation, NULL);
+ } else if (g_strcmp0 (method_name, "Attach") == 0) {
+ if (!_client_attach (manager, &error)) {
+ g_dbus_method_invocation_return_gerror (invocation, error);
+ return;
+ }
+ g_dbus_method_invocation_return_value (invocation, NULL);
} else {
g_assert_not_reached ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]