Compare commits

...

No commits in common. "c8" and "c10s" have entirely different histories.
c8 ... c10s

38 changed files with 491 additions and 35688 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/gnome-settings-daemon-3.32.0.tar.xz
/gnome-settings-daemon-*.tar.xz

View File

@ -1 +0,0 @@
92145a7a5714ebf3aeb90baaacb7e6955335731b SOURCES/gnome-settings-daemon-3.32.0.tar.xz

View File

@ -1,47 +0,0 @@
From bd0488fe501bae74fae1fbb21566aa35f38aa6fc Mon Sep 17 00:00:00 2001
From: Felipe Borges <felipeborges@gnome.org>
Date: Wed, 15 Feb 2023 15:27:59 +0100
Subject: [PATCH] Make power-button-action always power off when chassis=server
Servers often don't support hibernation/suspend.
---
...rg.gnome.settings-daemon.plugins.power.gschema.xml.in | 2 +-
plugins/media-keys/gsd-media-keys-manager.c | 9 ++++++---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in b/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
index fc61d133..952104ed 100644
--- a/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
+++ b/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
@@ -39,7 +39,7 @@
<key name="power-button-action" enum="org.gnome.settings-daemon.GsdPowerButtonActionType">
<default>'suspend'</default>
<summary>Power button action</summary>
- <description>The action to take when the system power button is pressed. Virtual machines only honor the 'nothing' action, and will shutdown otherwise. Tablets always suspend, ignoring all the other action options.</description>
+ <description>The action to take when the system power button is pressed. Virtual machines and servers only honor the 'nothing' action, and will shutdown otherwise. Tablets always suspend, ignoring all the other action options.</description>
</key>
</schema>
</schemalist>
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index ac6f7ab4..46bdade6 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -2083,9 +2083,12 @@ do_config_power_button_action (GsdMediaKeysManager *manager,
if (manager->priv->power_button_disabled)
return;
- action_type = g_settings_get_enum (manager->priv->power_settings, "power-button-action");
- /* Always power off VMs, except when power-button-action is "nothing" */
- if (g_strcmp0 (manager->priv->chassis_type, "vm") == 0) {
+ action_type = g_settings_get_enum (manager->priv->power_settings, "power-button-action");
+ /* Always power off VMs and servers, except when power-button-action is "nothing" */
+ if (g_strcmp0 (manager->priv->chassis_type, "vm") == 0 ||
+ g_strcmp0 (manager->priv->chassis_type, "server")) {
+ g_warning ("Virtual machines and servers only honor the 'nothing' power-button-action, and will shutdown otherwise");
+
if (action_type != GSD_POWER_BUTTON_ACTION_NOTHING)
power_action (manager, "PowerOff", !in_lock_screen);
--
2.37.1

File diff suppressed because it is too large Load Diff

View File

@ -1,125 +0,0 @@
From a8115378fd876bfd4c3871428cdc16134ed484b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Tue, 5 Jan 2021 11:11:18 +0100
Subject: [PATCH] media-keys: Mark screen cast as stopped if it was signalled
as such
gnome-shell now sends a 'Stopped' signal if it was stopped without
gsd-media-keys itself being the stopper.
---
plugins/media-keys/gsd-media-keys-manager.c | 52 +++++++++++++++++++--
1 file changed, 49 insertions(+), 3 deletions(-)
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index 4d251f08..a526d5cf 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -210,6 +210,7 @@ struct GsdMediaKeysManagerPrivate
guint screencast_timeout_id;
gboolean screencast_recording;
GCancellable *screencast_cancellable;
+ guint screencast_stopped_signal_id;
/* Rotation */
guint iio_sensor_watch_id;
@@ -2346,20 +2347,26 @@ do_rfkill_action (GsdMediaKeysManager *manager,
}
static void
-screencast_stop (GsdMediaKeysManager *manager)
+screencast_stopped (GsdMediaKeysManager *manager)
{
if (manager->priv->screencast_timeout_id > 0) {
g_source_remove (manager->priv->screencast_timeout_id);
manager->priv->screencast_timeout_id = 0;
}
+ manager->priv->screencast_recording = FALSE;
+}
+
+static void
+screencast_stop (GsdMediaKeysManager *manager)
+{
+ screencast_stopped (manager);
+
g_dbus_proxy_call (manager->priv->screencast_proxy,
"StopScreencast", NULL,
G_DBUS_CALL_FLAGS_NONE, -1,
manager->priv->screencast_cancellable,
NULL, NULL);
-
- manager->priv->screencast_recording = FALSE;
}
static gboolean
@@ -2835,6 +2842,21 @@ initialize_volume_handler (GsdMediaKeysManager *manager)
gnome_settings_profile_end ("gvc_mixer_control_new");
}
+
+static void
+on_screencast_stopped (GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer data)
+{
+ GsdMediaKeysManager *manager = data;
+
+ screencast_stopped (manager);
+}
+
static void
on_screencast_proxy_ready (GObject *source,
GAsyncResult *result,
@@ -2850,7 +2872,20 @@ on_screencast_proxy_ready (GObject *source,
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning ("Failed to create proxy for screencast: %s", error->message);
g_error_free (error);
+ return;
}
+
+ manager->priv->screencast_stopped_signal_id =
+ g_dbus_connection_signal_subscribe (manager->priv->connection,
+ SHELL_DBUS_NAME ".Screencast",
+ SHELL_DBUS_NAME ".Screencast",
+ "Stopped",
+ SHELL_DBUS_PATH "/Screencast",
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ on_screencast_stopped,
+ manager,
+ NULL);
}
static void
@@ -2901,6 +2936,11 @@ shell_presence_changed (GsdMediaKeysManager *manager)
on_screencast_proxy_ready, manager);
g_free (name_owner);
} else {
+ if (manager->priv->screencast_stopped_signal_id)
+ g_dbus_connection_signal_unsubscribe (manager->priv->connection,
+ manager->priv->screencast_stopped_signal_id);
+ manager->priv->screencast_stopped_signal_id = 0;
+
g_ptr_array_set_size (manager->priv->keys, 0);
g_clear_object (&manager->priv->key_grabber);
g_clear_object (&manager->priv->screencast_proxy);
@@ -3091,6 +3131,12 @@ gsd_media_keys_manager_stop (GsdMediaKeysManager *manager)
priv->reenable_power_button_timer_id = 0;
}
+ if (priv->screencast_stopped_signal_id) {
+ g_dbus_connection_signal_unsubscribe (priv->connection,
+ priv->screencast_stopped_signal_id);
+ priv->screencast_stopped_signal_id = 0;
+ }
+
g_clear_pointer (&manager->priv->ca, ca_context_destroy);
#if HAVE_GUDEV
--
2.27.0

View File

@ -1,34 +0,0 @@
From 77b52a04c9154a7e7b2434f6c70ba6b4fd84c9f1 Mon Sep 17 00:00:00 2001
From: Benjamin Berg <bberg@redhat.com>
Date: Thu, 15 Oct 2020 15:18:35 +0200
Subject: [PATCH] power: Avoid automatic logout in GDM/greeter
In GDM sessions (greeter, initial-setup), it does not make sense to
automatically logout. This can happen if the system wide default is
changed to default to the "logout" action.
Note that we already use the RUNNING_UNDER_GDM environment variable in
the keyboard plugin currently. So doing this is likely sane, even if we
probably want a more elegant strategy to detect whether we are in a
"login" session.
---
plugins/power/gsd-power-manager.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index e103a8a7..b100ff9e 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -872,6 +872,9 @@ static void
gnome_session_logout (GsdPowerManager *manager,
guint logout_mode)
{
+ if (g_getenv("RUNNING_UNDER_GDM"))
+ return;
+
g_dbus_proxy_call (G_DBUS_PROXY (manager->priv->session),
"Logout",
g_variant_new ("(u)", logout_mode),
--
2.26.2

View File

@ -1,53 +0,0 @@
From fbe9b7dba44cb284f649a1e916b2cf3ce8281211 Mon Sep 17 00:00:00 2001
From: Benjamin Berg <bberg@redhat.com>
Date: Tue, 7 May 2019 15:40:20 +0200
Subject: [PATCH] power: Only disable Suspend/Hibernate actions inside VM
While we theoretically only want a different default value inside a VM,
we currently hack this by never doing a suspend action inside VMs.
However, that also breaks automatic logout, which is an unintended side
effect.
Move the check to not install the corresponding timeout (preventing
sleep warnings from being displayed) and also only enforce the VM
specific hack for the Suspend and Hibernate actions.
---
plugins/power/gsd-power-manager.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index f965f6f..dbaa262 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -1520,13 +1520,6 @@ idle_set_mode (GsdPowerManager *manager, GsdPowerIdleMode mode)
return;
}
- /* don't do any power saving if we're a VM */
- if (manager->priv->is_virtual_machine) {
- g_debug ("ignoring state transition to %s as virtual machine",
- idle_mode_to_string (mode));
- return;
- }
-
manager->priv->current_idle_mode = mode;
g_debug ("Doing a state transition: %s", idle_mode_to_string (mode));
@@ -1727,6 +1720,14 @@ idle_configure (GsdPowerManager *manager)
clear_idle_watch (manager->priv->idle_monitor,
&manager->priv->idle_sleep_warning_id);
+ /* don't do any power saving if we're a VM */
+ if (manager->priv->is_virtual_machine &&
+ (action_type == GSD_POWER_ACTION_SUSPEND ||
+ action_type == GSD_POWER_ACTION_HIBERNATE)) {
+ g_debug ("Ignoring sleep timeout with suspend action inside VM");
+ timeout_sleep = 0;
+ }
+
if (timeout_sleep != 0) {
g_debug ("setting up sleep callback %is", timeout_sleep);
--
2.31.1

View File

@ -1,59 +0,0 @@
From 0e2c4aec104b65d2f8ea7167269e91c303908a6f Mon Sep 17 00:00:00 2001
From: Felipe Borges <felipeborges@gnome.org>
Date: Wed, 4 Jan 2023 15:30:15 +0100
Subject: [PATCH] power: Respect the "nothing" power-button-action for VMs
There are use-cases when one wants to forcefully make the guest ignore
poweroff requests from the hypervisor.
See https://bugzilla.redhat.com/2062051
See also https://gitlab.gnome.org/GNOME/gnome-settings-daemon/-/issues/46
---
...org.gnome.settings-daemon.plugins.power.gschema.xml.in | 2 +-
plugins/media-keys/gsd-media-keys-manager.c | 8 +++++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in b/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
index 93c704e9..fc61d133 100644
--- a/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
+++ b/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
@@ -39,7 +39,7 @@
<key name="power-button-action" enum="org.gnome.settings-daemon.GsdPowerButtonActionType">
<default>'suspend'</default>
<summary>Power button action</summary>
- <description>The action to take when the system power button is pressed. This action is hard-coded (and the setting ignored) on virtual machines (power off) and tablets (suspend).</description>
+ <description>The action to take when the system power button is pressed. Virtual machines only honor the 'nothing' action, and will shutdown otherwise. Tablets always suspend, ignoring all the other action options.</description>
</key>
</schema>
</schemalist>
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index a526d5cf..ac6f7ab4 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -2083,9 +2083,12 @@ do_config_power_button_action (GsdMediaKeysManager *manager,
if (manager->priv->power_button_disabled)
return;
- /* Always power off VMs when power off is pressed in the menus */
+ action_type = g_settings_get_enum (manager->priv->power_settings, "power-button-action");
+ /* Always power off VMs, except when power-button-action is "nothing" */
if (g_strcmp0 (manager->priv->chassis_type, "vm") == 0) {
- power_action (manager, "PowerOff", !in_lock_screen);
+ if (action_type != GSD_POWER_BUTTON_ACTION_NOTHING)
+ power_action (manager, "PowerOff", !in_lock_screen);
+
return;
}
@@ -2095,7 +2098,6 @@ do_config_power_button_action (GsdMediaKeysManager *manager,
return;
}
- action_type = g_settings_get_enum (manager->priv->power_settings, "power-button-action");
switch (action_type) {
case GSD_POWER_BUTTON_ACTION_SUSPEND:
action = GSD_POWER_ACTION_SUSPEND;
--
2.37.1

View File

@ -1,58 +0,0 @@
From a1c2685bc6b255f22b6ce4645c001d428cb67907 Mon Sep 17 00:00:00 2001
From: Marek Kasik <mkasik@redhat.com>
Date: Wed, 22 May 2019 14:56:42 +0200
Subject: [PATCH] smartcard: Cancel cancellable when stopping
self->cancellable in GsdSmartcardManager is not cancelled
at gsd_smartcard_manager_stop() and hence some callbacks are
still called after unload_nss() which clears SECMODListLock
which is used by SECMOD_GetReadLock() / SECMOD_ReleaseReadLock().
This leads to crashes in NSSRWLock_LockRead_Util() and
NSSRWLock_UnlockRead_Util() probably.
Also check for return value of g_cancellable_connect()
and initialize pointer to PK11SlotInfo.
See https://bugzilla.redhat.com/show_bug.cgi?id=1646359,
https://bugzilla.redhat.com/show_bug.cgi?id=1688791 and
their duplicates for additional info.
---
plugins/smartcard/gsd-smartcard-manager.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletion(-)
diff --git a/plugins/smartcard/gsd-smartcard-manager.c b/plugins/smartcard/gsd-smartcard-manager.c
index 014c17be..da1e0d6d 100644
--- a/plugins/smartcard/gsd-smartcard-manager.c
+++ b/plugins/smartcard/gsd-smartcard-manager.c
@@ -184,7 +184,7 @@
GError **error)
{
GsdSmartcardManagerPrivate *priv = self->priv;
- PK11SlotInfo *card, *old_card;
+ PK11SlotInfo *card = NULL, *old_card;
CK_SLOT_ID slot_id;
gulong handler_id;
int old_slot_series = -1, slot_series;
@@ -190,7 +190,8 @@ watch_one_event_from_driver (GsdSmartcardManager *self,
operation,
NULL);
- card = SECMOD_WaitForAnyTokenEvent (operation->driver, 0, PR_SecondsToInterval (1));
+ if (handler_id != 0)
+ card = SECMOD_WaitForAnyTokenEvent (operation->driver, 0, PR_SecondsToInterval (1));
g_cancellable_disconnect (cancellable, handler_id);
@@ -773,6 +774,8 @@ gsd_smartcard_manager_stop (GsdSmartcardManager *self)
g_debug ("Stopping smartcard manager");
+ g_cancellable_cancel (priv->cancellable);
+
unload_nss (self);
g_clear_object (&priv->settings);
--
2.23.0

View File

@ -1,25 +0,0 @@
From 6e790966c2b6e1db8dd2c145119d3fdd19e0c18f Mon Sep 17 00:00:00 2001
From: Matthias Clasen <mclasen@redhat.com>
Date: Wed, 22 May 2019 16:04:42 -0400
Subject: [PATCH] xsettings: Add an entry for the overlay scrolling setting
This will be used by GTK.
---
plugins/xsettings/gsd-xsettings-manager.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/plugins/xsettings/gsd-xsettings-manager.c b/plugins/xsettings/gsd-xsettings-manager.c
index c3ac7892..4164de40 100644
--- a/plugins/xsettings/gsd-xsettings-manager.c
+++ b/plugins/xsettings/gsd-xsettings-manager.c
@@ -478,6 +478,7 @@ static TranslationEntry translations [] = {
{ "org.gnome.desktop.interface", "icon-theme", "Net/IconThemeName", translate_string_string },
{ "org.gnome.desktop.interface", "cursor-theme", "Gtk/CursorThemeName", translate_string_string },
{ "org.gnome.desktop.interface", "gtk-enable-primary-paste", "Gtk/EnablePrimaryPaste", translate_bool_int },
+ { "org.gnome.desktop.interface", "overlay-scrolling", "Gtk/OverlayScrolling", translate_bool_int },
/* cursor-size is handled via the Xft side as it needs the scaling factor */
{ "org.gnome.desktop.sound", "theme-name", "Net/SoundThemeName", translate_string_string },
--
2.23.0

View File

@ -1,271 +0,0 @@
From ad0fd6c905011b7bb9eac9fa8cb91f58d71e4a29 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Mon, 6 Nov 2017 15:49:58 -0500
Subject: [PATCH 2/4] account: reshow the notification when screen unlocks
---
plugins/account/gsd-account-manager.c | 48 ++++++++++++++++++++++++---
1 file changed, 43 insertions(+), 5 deletions(-)
diff --git a/plugins/account/gsd-account-manager.c b/plugins/account/gsd-account-manager.c
index 40b91cb6..cb37f466 100644
--- a/plugins/account/gsd-account-manager.c
+++ b/plugins/account/gsd-account-manager.c
@@ -11,72 +11,75 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <locale.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <cups/cups.h>
#include <cups/ppd.h>
#include <libnotify/notify.h>
#include "gnome-settings-profile.h"
+#include "gnome-settings-bus.h"
#include "gsd-account-manager.h"
#include "org.freedesktop.Accounts.h"
#include "org.freedesktop.Accounts.User.h"
#define GSD_ACCOUNT_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_ACCOUNT_MANAGER, GsdAccountManagerPrivate))
struct GsdAccountManagerPrivate
{
GsdAccounts *accounts_proxy;
GsdAccountsUser *accounts_user_proxy;
GCancellable *cancellable;
+ GsdScreenSaver *screensaver_proxy;
+
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;
NotifyNotification *notification;
};
static void gsd_account_manager_class_init (GsdAccountManagerClass *klass);
static void gsd_account_manager_init (GsdAccountManager *account_manager);
static void gsd_account_manager_finalize (GObject *object);
G_DEFINE_TYPE (GsdAccountManager, gsd_account_manager, G_TYPE_OBJECT)
static gpointer manager_object = NULL;
static void
on_notification_closed (NotifyNotification *notification,
gpointer user_data)
{
GsdAccountManager *manager = user_data;
g_clear_object (&manager->priv->notification);
}
static void
hide_notification (GsdAccountManager *manager)
{
@@ -221,77 +224,111 @@ on_got_password_expiration_policy (GsdAccountsUser *accounts_user_proxy,
gint64 days_after_expiration_until_lock;
gnome_settings_profile_start (NULL);
succeeded = gsd_accounts_user_call_get_password_expiration_policy_finish (accounts_user_proxy,
&expiration_time,
&last_change_time,
&min_days_between_changes,
&max_days_between_changes,
&days_to_warn,
&days_after_expiration_until_lock,
res,
&error);
if (!succeeded) {
g_warning ("Failed to get password expiration policy for user: %s", error->message);
goto out;
}
set_policy_number (&manager->priv->expiration_time, expiration_time);
set_policy_number (&manager->priv->last_change_time, last_change_time);
set_policy_number (&manager->priv->min_days_between_changes, min_days_between_changes);
set_policy_number (&manager->priv->max_days_between_changes, max_days_between_changes);
set_policy_number (&manager->priv->days_to_warn, days_to_warn);
set_policy_number (&manager->priv->days_after_expiration_until_lock, days_after_expiration_until_lock);
update_password_notification (manager);
out:
gnome_settings_profile_end (NULL);
}
+static void
+fetch_password_expiration_policy (GsdAccountManager *manager)
+{
+ gsd_accounts_user_call_get_password_expiration_policy (manager->priv->accounts_user_proxy,
+ manager->priv->cancellable,
+ (GAsyncReadyCallback)
+ on_got_password_expiration_policy,
+ manager);
+}
+
+static void
+on_screensaver_signal (GDBusProxy *proxy,
+ const gchar *sender_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ GsdAccountManager *manager = user_data;
+
+ if (g_strcmp0 (signal_name, "ActiveChanged") == 0) {
+ gboolean active;
+
+ g_variant_get (parameters, "(b)", &active);
+
+ if (!active) {
+ fetch_password_expiration_policy (manager);
+ }
+ }
+}
+
static void
on_got_accounts_user_proxy (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GsdAccountManager *manager = user_data;
g_autoptr(GError) error = NULL;
gnome_settings_profile_start (NULL);
manager->priv->accounts_user_proxy = gsd_accounts_user_proxy_new_finish (res, &error);
if (manager->priv->accounts_user_proxy != NULL) {
- gsd_accounts_user_call_get_password_expiration_policy (manager->priv->accounts_user_proxy,
- manager->priv->cancellable,
- (GAsyncReadyCallback)
- on_got_password_expiration_policy,
- manager);
+ fetch_password_expiration_policy (manager);
+
+ manager->priv->screensaver_proxy = gnome_settings_bus_get_screen_saver_proxy ();
+
+ g_signal_connect (manager->priv->screensaver_proxy,
+ "g-signal",
+ G_CALLBACK (on_screensaver_signal),
+ manager);
+
} else {
g_warning ("Failed to get user proxy to accounts service: %s", error->message);
goto out;
}
out:
gnome_settings_profile_end (NULL);
}
static void
on_got_user_object_path (GsdAccounts *accounts_proxy,
GAsyncResult *res,
gpointer user_data)
{
GsdAccountManager *manager = user_data;
g_autoptr(GError) error = NULL;
gboolean succeeded;
gchar *object_path;
GDBusConnection *connection;
gnome_settings_profile_start (NULL);
succeeded = gsd_accounts_call_find_user_by_id_finish (accounts_proxy,
&object_path,
res,
&error);
if (!succeeded) {
g_warning ("Unable to find current user in accounts service: %s",
error->message);
@@ -343,60 +380,61 @@ gsd_account_manager_start (GsdAccountManager *manager,
g_debug ("Starting accounts manager");
gnome_settings_profile_start (NULL);
manager->priv->cancellable = g_cancellable_new ();
gsd_accounts_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
"org.freedesktop.Accounts",
"/org/freedesktop/Accounts",
manager->priv->cancellable,
(GAsyncReadyCallback)
on_got_accounts_proxy,
manager);
gnome_settings_profile_end (NULL);
return TRUE;
}
void
gsd_account_manager_stop (GsdAccountManager *manager)
{
g_debug ("Stopping accounts manager");
if (manager->priv->cancellable != NULL) {
g_cancellable_cancel (manager->priv->cancellable);
g_clear_object (&manager->priv->cancellable);
}
g_clear_object (&manager->priv->accounts_proxy);
g_clear_object (&manager->priv->accounts_user_proxy);
g_clear_object (&manager->priv->notification);
+ g_clear_object (&manager->priv->screensaver_proxy);
}
static void
gsd_account_manager_class_init (GsdAccountManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gsd_account_manager_finalize;
notify_init ("gnome-settings-daemon");
g_type_class_add_private (klass, sizeof (GsdAccountManagerPrivate));
}
static void
gsd_account_manager_init (GsdAccountManager *manager)
{
manager->priv = GSD_ACCOUNT_MANAGER_GET_PRIVATE (manager);
}
static void
gsd_account_manager_finalize (GObject *object)
{
GsdAccountManager *manager;
g_return_if_fail (object != NULL);
g_return_if_fail (GSD_IS_ACCOUNT_MANAGER (object));
manager = GSD_ACCOUNT_MANAGER (object);
--
2.21.0

View File

@ -1,49 +0,0 @@
From f2cd5fb30892e3868732fca1d38fc15fdb73ec18 Mon Sep 17 00:00:00 2001
From: Benjamin Berg <bberg@redhat.com>
Date: Tue, 27 Oct 2020 10:20:34 +0100
Subject: [PATCH 2/2] power: Never register sleep timeout for logout in GDM
We already suppress logout actions in GDM (10aa1714b05b, power: Avoid
automatic logout in GDM/greeter). However, while this prevents the
action, we may still warn.
Change it so that the corresponding timeouts will never be registered.
Leave the guard in gnome_session_logout but add a warning as we should
never be hitting that code path.
---
plugins/power/gsd-power-manager.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 9f2e858e..ed855b6b 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -872,8 +872,10 @@ static void
gnome_session_logout (GsdPowerManager *manager,
guint logout_mode)
{
- if (g_getenv("RUNNING_UNDER_GDM"))
+ if (g_getenv ("RUNNING_UNDER_GDM")) {
+ g_warning ("Prevented logout from GDM session! This indicates an issue in gsd-power.");
return;
+ }
g_dbus_proxy_call (G_DBUS_PROXY (manager->priv->session),
"Logout",
@@ -1773,6 +1775,13 @@ idle_configure (GsdPowerManager *manager)
timeout_sleep = 0;
}
+ /* don't do any automatic logout if we are in GDM */
+ if (g_getenv ("RUNNING_UNDER_GDM") &&
+ (action_type == GSD_POWER_ACTION_LOGOUT)) {
+ g_debug ("Ignoring sleep timeout with logout action inside GDM");
+ timeout_sleep = 0;
+ }
+
if (timeout_sleep != 0) {
g_debug ("setting up sleep callback %is", timeout_sleep);
--
2.26.2

View File

@ -1,768 +0,0 @@
From f723ed1078e050c4d966d40b2aea74970c74279c Mon Sep 17 00:00:00 2001
From: Kalev Lember <klember@redhat.com>
Date: Thu, 27 Jun 2019 16:12:00 +0200
Subject: [PATCH 02/15] subman: Add InstalledProducts dbus property for g-c-c
---
plugins/subman/gsd-subscription-manager.c | 135 ++++++++++++++++++++++
1 file changed, 135 insertions(+)
diff --git a/plugins/subman/gsd-subscription-manager.c b/plugins/subman/gsd-subscription-manager.c
index 08b13fa6..a8c18a26 100644
--- a/plugins/subman/gsd-subscription-manager.c
+++ b/plugins/subman/gsd-subscription-manager.c
@@ -1,186 +1,304 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2019 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2019 Kalev Lember <klember@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <glib/gi18n.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <json-glib/json-glib.h>
#include <libnotify/notify.h>
#include "gnome-settings-profile.h"
#include "gsd-subman-common.h"
#include "gsd-subscription-manager.h"
#define GSD_DBUS_NAME "org.gnome.SettingsDaemon"
#define GSD_DBUS_PATH "/org/gnome/SettingsDaemon"
#define GSD_DBUS_BASE_INTERFACE "org.gnome.SettingsDaemon"
#define GSD_SUBSCRIPTION_DBUS_NAME GSD_DBUS_NAME ".Subscription"
#define GSD_SUBSCRIPTION_DBUS_PATH GSD_DBUS_PATH "/Subscription"
#define GSD_SUBSCRIPTION_DBUS_INTERFACE GSD_DBUS_BASE_INTERFACE ".Subscription"
static const gchar introspection_xml[] =
"<node>"
" <interface name='org.gnome.SettingsDaemon.Subscription'>"
" <method name='Register'>"
" <arg type='a{sv}' name='options' direction='in'/>"
" </method>"
" <method name='Unregister'/>"
+" <property name='InstalledProducts' type='aa{sv}' access='read'/>"
" <property name='SubscriptionStatus' type='u' access='read'/>"
" </interface>"
"</node>";
#define GSD_SUBSCRIPTION_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_SUBSCRIPTION_MANAGER, GsdSubscriptionManagerPrivate))
typedef enum {
_RHSM_INTERFACE_CONFIG,
_RHSM_INTERFACE_REGISTER_SERVER,
_RHSM_INTERFACE_ATTACH,
_RHSM_INTERFACE_ENTITLEMENT,
_RHSM_INTERFACE_PRODUCTS,
_RHSM_INTERFACE_CONSUMER,
_RHSM_INTERFACE_SYSPURPOSE,
_RHSM_INTERFACE_LAST
} _RhsmInterface;
struct GsdSubscriptionManagerPrivate
{
/* D-Bus */
guint name_id;
GDBusNodeInfo *introspection_data;
GDBusConnection *connection;
GCancellable *bus_cancellable;
GDBusProxy *proxies[_RHSM_INTERFACE_LAST];
const gchar *userlang; /* owned by GLib internally */
GHashTable *config; /* str:str */
+ GPtrArray *installed_products;
gchar *address;
GTimer *timer_last_notified;
NotifyNotification *notification_expired;
NotifyNotification *notification_registered;
NotifyNotification *notification_registration_required;
GsdSubmanSubscriptionStatus subscription_status;
GsdSubmanSubscriptionStatus subscription_status_last;
};
enum {
PROP_0,
};
static void gsd_subscription_manager_class_init (GsdSubscriptionManagerClass *klass);
static void gsd_subscription_manager_init (GsdSubscriptionManager *subscription_manager);
static void gsd_subscription_manager_finalize (GObject *object);
G_DEFINE_TYPE (GsdSubscriptionManager, gsd_subscription_manager, G_TYPE_OBJECT)
+typedef struct
+{
+ gchar *product_name;
+ gchar *product_id;
+ gchar *version;
+ gchar *arch;
+ gchar *status;
+ gchar *starts;
+ gchar *ends;
+} ProductData;
+
+static void
+product_data_free (ProductData *product)
+{
+ g_free (product->product_name);
+ g_free (product->product_id);
+ g_free (product->version);
+ g_free (product->arch);
+ g_free (product->status);
+ g_free (product->starts);
+ g_free (product->ends);
+ g_free (product);
+}
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProductData, product_data_free);
+
static gpointer manager_object = NULL;
GQuark
gsd_subscription_manager_error_quark (void)
{
static GQuark quark = 0;
if (!quark)
quark = g_quark_from_static_string ("gsd_subscription_manager_error");
return quark;
}
static GsdSubmanSubscriptionStatus
_client_subscription_status_from_text (const gchar *status_txt)
{
if (g_strcmp0 (status_txt, "Unknown") == 0)
return GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN;
if (g_strcmp0 (status_txt, "Current") == 0)
return GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID;
if (g_strcmp0 (status_txt, "Invalid") == 0)
return GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID;
if (g_strcmp0 (status_txt, "Disabled") == 0)
return GSD_SUBMAN_SUBSCRIPTION_STATUS_DISABLED;
if (g_strcmp0 (status_txt, "Insufficient") == 0)
return GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID;
g_warning ("Unknown subscription status: %s", status_txt); // 'Current'?
return GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN;
}
+static GVariant *
+_make_installed_products_variant (GPtrArray *installed_products)
+{
+ GVariantBuilder builder;
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}"));
+
+ for (guint i = 0; i < installed_products->len; i++) {
+ ProductData *product = g_ptr_array_index (installed_products, i);
+ g_auto(GVariantDict) dict;
+
+ g_variant_dict_init (&dict, NULL);
+
+ g_variant_dict_insert (&dict, "product-name", "s", product->product_name);
+ g_variant_dict_insert (&dict, "product-id", "s", product->product_id);
+ g_variant_dict_insert (&dict, "version", "s", product->version);
+ g_variant_dict_insert (&dict, "arch", "s", product->arch);
+ g_variant_dict_insert (&dict, "status", "s", product->status);
+ g_variant_dict_insert (&dict, "starts", "s", product->starts);
+ g_variant_dict_insert (&dict, "ends", "s", product->ends);
+
+ g_variant_builder_add_value (&builder, g_variant_dict_end (&dict));
+ }
+
+ return g_variant_builder_end (&builder);
+}
+
static void
_emit_property_changed (GsdSubscriptionManager *manager,
const gchar *property_name,
GVariant *property_value)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
GVariantBuilder builder;
GVariantBuilder invalidated_builder;
/* not yet connected */
if (priv->connection == NULL)
return;
/* build the dict */
g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
g_variant_builder_add (&builder,
"{sv}",
property_name,
property_value);
g_dbus_connection_emit_signal (priv->connection,
NULL,
GSD_SUBSCRIPTION_DBUS_PATH,
"org.freedesktop.DBus.Properties",
"PropertiesChanged",
g_variant_new ("(sa{sv}as)",
GSD_SUBSCRIPTION_DBUS_INTERFACE,
&builder,
&invalidated_builder),
NULL);
g_variant_builder_clear (&builder);
g_variant_builder_clear (&invalidated_builder);
}
+static gboolean
+_client_installed_products_update (GsdSubscriptionManager *manager, GError **error)
+{
+ GsdSubscriptionManagerPrivate *priv = manager->priv;
+ JsonNode *json_root;
+ JsonArray *json_products_array;
+ const gchar *json_txt = NULL;
+ g_autoptr(GVariant) val = NULL;
+ g_autoptr(JsonParser) json_parser = json_parser_new ();
+
+ val = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_PRODUCTS],
+ "ListInstalledProducts",
+ g_variant_new ("(sa{sv}s)",
+ "" /* filter_string */,
+ NULL /* proxy_options */,
+ priv->userlang),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, error);
+ if (val == NULL)
+ return FALSE;
+ g_variant_get (val, "(&s)", &json_txt);
+ g_debug ("Products.ListInstalledProducts JSON: %s", json_txt);
+ if (!json_parser_load_from_data (json_parser, json_txt, -1, error))
+ return FALSE;
+ json_root = json_parser_get_root (json_parser);
+ json_products_array = json_node_get_array (json_root);
+ if (json_products_array == NULL) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
+ "no InstalledProducts array in %s", json_txt);
+ return FALSE;
+ }
+
+ g_ptr_array_set_size (priv->installed_products, 0);
+
+ for (guint i = 0; i < json_array_get_length (json_products_array); i++) {
+ JsonArray *json_product = json_array_get_array_element (json_products_array, i);
+ g_autoptr(ProductData) product = g_new0 (ProductData, 1);
+
+ if (json_product == NULL)
+ continue;
+ if (json_array_get_length (json_product) < 8) {
+ g_debug ("Unexpected number of array elements in InstalledProducts JSON");
+ continue;
+ }
+
+ product->product_name = g_strdup (json_array_get_string_element (json_product, 0));
+ product->product_id = g_strdup (json_array_get_string_element (json_product, 1));
+ product->version = g_strdup (json_array_get_string_element (json_product, 2));
+ product->arch = g_strdup (json_array_get_string_element (json_product, 3));
+ product->status = g_strdup (json_array_get_string_element (json_product, 4));
+ product->starts = g_strdup (json_array_get_string_element (json_product, 6));
+ product->ends = g_strdup (json_array_get_string_element (json_product, 7));
+
+ g_ptr_array_add (priv->installed_products, g_steal_pointer (&product));
+ }
+
+ /* emit notification for g-c-c */
+ _emit_property_changed (manager, "InstalledProducts",
+ _make_installed_products_variant (priv->installed_products));
+
+ return TRUE;
+}
+
static gboolean
_client_subscription_status_update (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
JsonNode *json_root;
JsonObject *json_obj;
const gchar *json_txt = NULL;
const gchar *status_txt = NULL;
g_autoptr(GVariant) val = NULL;
g_autoptr(JsonParser) json_parser = json_parser_new ();
/* save old value */
priv->subscription_status_last = priv->subscription_status;
val = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_ENTITLEMENT],
"GetStatus",
g_variant_new ("(ss)",
"", /* assumed as 'now' */
priv->userlang),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (val == NULL)
return FALSE;
g_variant_get (val, "(&s)", &json_txt);
g_debug ("Entitlement.GetStatus JSON: %s", json_txt);
if (!json_parser_load_from_data (json_parser, json_txt, -1, error))
return FALSE;
json_root = json_parser_get_root (json_parser);
json_obj = json_node_get_object (json_root);
if (!json_object_has_member (json_obj, "status")) {
@@ -423,185 +541,195 @@ _client_register_with_keys (GsdSubscriptionManager *manager,
GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
g_autoptr(GSubprocess) subprocess = NULL;
/* apparently: "we can't send registration credentials over the regular
* system or session bus since those aren't really locked down..." */
if (!_client_register_start (manager, error))
return FALSE;
g_debug ("spawning %s", LIBEXECDIR "/gsd-subman-helper");
subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDERR_PIPE, error,
"pkexec", LIBEXECDIR "/gsd-subman-helper",
"--kind", "register-with-key",
"--address", priv->address,
"--hostname", hostname,
"--organisation", organisation,
"--activation-key", activation_key,
NULL);
if (subprocess == NULL) {
g_prefix_error (error, "failed to find pkexec: ");
return FALSE;
}
if (!_client_subprocess_wait_check (subprocess, error))
return FALSE;
/* FIXME: also do on error? */
if (!_client_register_stop (manager, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
+ if (!_client_installed_products_update (manager, error))
+ return FALSE;
_client_maybe__show_notification (manager);
/* success */
return TRUE;
}
static gboolean
_client_register (GsdSubscriptionManager *manager,
const gchar *hostname,
const gchar *organisation,
const gchar *username,
const gchar *password,
GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
g_autoptr(GSubprocess) subprocess = NULL;
/* fallback */
if (organisation == NULL)
organisation = "";
/* apparently: "we can't send registration credentials over the regular
* system or session bus since those aren't really locked down..." */
if (!_client_register_start (manager, error))
return FALSE;
g_debug ("spawning %s", LIBEXECDIR "/gsd-subman-helper");
subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDERR_PIPE, error,
"pkexec", LIBEXECDIR "/gsd-subman-helper",
"--kind", "register-with-username",
"--address", priv->address,
"--hostname", hostname,
"--organisation", organisation,
"--username", username,
"--password", password,
NULL);
if (subprocess == NULL) {
g_prefix_error (error, "failed to find pkexec: ");
return FALSE;
}
if (!_client_subprocess_wait_check (subprocess, error))
return FALSE;
/* FIXME: also do on error? */
if (!_client_register_stop (manager, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
+ if (!_client_installed_products_update (manager, error))
+ return FALSE;
_client_maybe__show_notification (manager);
return TRUE;
}
static gboolean
_client_unregister (GsdSubscriptionManager *manager, GError **error)
{
g_autoptr(GSubprocess) subprocess = NULL;
/* apparently: "we can't send registration credentials over the regular
* system or session bus since those aren't really locked down..." */
if (!_client_register_start (manager, error))
return FALSE;
g_debug ("spawning %s", LIBEXECDIR "/gsd-subman-helper");
subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDERR_PIPE, error,
"pkexec", LIBEXECDIR "/gsd-subman-helper",
"--kind", "unregister",
NULL);
if (subprocess == NULL) {
g_prefix_error (error, "failed to find pkexec: ");
return FALSE;
}
if (!_client_subprocess_wait_check (subprocess, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
+ if (!_client_installed_products_update (manager, error))
+ return FALSE;
_client_maybe__show_notification (manager);
return TRUE;
}
static gboolean
_client_update_config (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
g_autoptr(GVariant) val = NULL;
g_autoptr(GVariant) val_server = NULL;
g_autoptr(GVariantDict) dict = NULL;
GVariantIter iter;
gchar *key;
gchar *value;
val = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_CONFIG],
"GetAll",
g_variant_new ("(s)", priv->userlang),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (val == NULL)
return FALSE;
dict = g_variant_dict_new (g_variant_get_child_value (val, 0));
val_server = g_variant_dict_lookup_value (dict, "server", G_VARIANT_TYPE("a{ss}"));
if (val_server != NULL) {
g_variant_iter_init (&iter, val_server);
while (g_variant_iter_next (&iter, "{ss}", &key, &value)) {
g_debug ("%s=%s", key, value);
g_hash_table_insert (priv->config,
g_steal_pointer (&key),
g_steal_pointer (&value));
}
}
return TRUE;
}
static void
_subman_proxy_signal_cb (GDBusProxy *proxy,
const gchar *sender_name,
const gchar *signal_name,
GVariant *parameters,
GsdSubscriptionManager *manager)
{
g_autoptr(GError) error = NULL;
if (!_client_syspurpose_update (manager, &error)) {
g_warning ("failed to update syspurpose: %s", error->message);
g_clear_error (&error);
}
if (!_client_subscription_status_update (manager, &error)) {
g_warning ("failed to update subscription status: %s", error->message);
g_clear_error (&error);
}
+ if (!_client_installed_products_update (manager, &error)) {
+ g_warning ("failed to update installed products: %s", error->message);
+ g_clear_error (&error);
+ }
_client_maybe__show_notification (manager);
}
static void
_client_unload (GsdSubscriptionManager *manager)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
for (guint i = 0; i < _RHSM_INTERFACE_LAST; i++)
g_clear_object (&priv->proxies[i]);
g_hash_table_unref (priv->config);
}
static const gchar *
_rhsm_interface_to_string (_RhsmInterface kind)
{
if (kind == _RHSM_INTERFACE_CONFIG)
return "Config";
if (kind == _RHSM_INTERFACE_REGISTER_SERVER)
return "RegisterServer";
if (kind == _RHSM_INTERFACE_ATTACH)
return "Attach";
if (kind == _RHSM_INTERFACE_ENTITLEMENT)
return "Entitlement";
if (kind == _RHSM_INTERFACE_PRODUCTS)
return "Products";
if (kind == _RHSM_INTERFACE_CONSUMER)
return "Consumer";
if (kind == _RHSM_INTERFACE_SYSPURPOSE)
return "Syspurpose";
return NULL;
@@ -613,60 +741,62 @@ _client_load (GsdSubscriptionManager *manager, GError **error)
GsdSubscriptionManagerPrivate *priv = manager->priv;
priv->config = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
/* connect to all the interfaces on the *different* objects :| */
for (guint i = 0; i < _RHSM_INTERFACE_LAST; i++) {
const gchar *kind = _rhsm_interface_to_string (i);
g_autofree gchar *opath = g_strdup_printf ("/com/redhat/RHSM1/%s", kind);
g_autofree gchar *iface = g_strdup_printf ("com.redhat.RHSM1.%s", kind);
priv->proxies[i] =
g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
"com.redhat.RHSM1",
opath, iface,
NULL,
error);
if (priv->proxies[i] == NULL)
return FALSE;
/* we want to get notified if the status of the system changes */
g_signal_connect (priv->proxies[i], "g-signal",
G_CALLBACK (_subman_proxy_signal_cb), manager);
}
/* get initial status */
priv->userlang = "";
if (!_client_update_config (manager, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
+ if (!_client_installed_products_update (manager, error))
+ return FALSE;
if (!_client_syspurpose_update (manager, error))
return FALSE;
/* success */
return TRUE;
}
gboolean
gsd_subscription_manager_start (GsdSubscriptionManager *manager, GError **error)
{
gboolean ret;
g_debug ("Starting subscription manager");
gnome_settings_profile_start (NULL);
ret = _client_load (manager, error);
_client_maybe__show_notification (manager);
gnome_settings_profile_end (NULL);
return ret;
}
void
gsd_subscription_manager_stop (GsdSubscriptionManager *manager)
{
g_debug ("Stopping subscription manager");
_client_unload (manager);
}
static void
gsd_subscription_manager_class_init (GsdSubscriptionManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -676,60 +806,61 @@ gsd_subscription_manager_class_init (GsdSubscriptionManagerClass *klass)
}
static void
_launch_info_overview (void)
{
const gchar *argv[] = { "gnome-control-center", "info-overview", NULL };
g_debug ("Running gnome-control-center info-overview");
g_spawn_async (NULL, (gchar **) argv, NULL, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, NULL);
}
static void
_notify_closed_cb (NotifyNotification *notification, gpointer user_data)
{
/* FIXME: only launch when clicking on the main body, not the window close */
if (notify_notification_get_closed_reason (notification) == 0x400)
_launch_info_overview ();
}
static void
_notify_clicked_cb (NotifyNotification *notification, char *action, gpointer user_data)
{
_launch_info_overview ();
}
static void
gsd_subscription_manager_init (GsdSubscriptionManager *manager)
{
GsdSubscriptionManagerPrivate *priv = manager->priv = GSD_SUBSCRIPTION_MANAGER_GET_PRIVATE (manager);
+ priv->installed_products = g_ptr_array_new_with_free_func ((GDestroyNotify) product_data_free);
priv->timer_last_notified = g_timer_new ();
/* expired */
priv->notification_expired =
notify_notification_new (_("Subscription Has Expired"),
_("Add or renew a subscription to continue receiving software updates."),
NULL);
notify_notification_set_app_name (priv->notification_expired, _("Subscription"));
notify_notification_set_hint_string (priv->notification_expired, "desktop-entry", "subman-panel");
notify_notification_set_hint_string (priv->notification_expired, "x-gnome-privacy-scope", "system");
notify_notification_set_urgency (priv->notification_expired, NOTIFY_URGENCY_CRITICAL);
notify_notification_add_action (priv->notification_expired,
"info-overview", _("Subscribe System…"),
_notify_clicked_cb,
manager, NULL);
g_signal_connect (priv->notification_expired, "closed",
G_CALLBACK (_notify_closed_cb), manager);
/* registered */
priv->notification_registered =
notify_notification_new (_("Registration Successful"),
_("The system has been registered and software updates have been enabled."),
NULL);
notify_notification_set_app_name (priv->notification_registered, _("Subscription"));
notify_notification_set_hint_string (priv->notification_registered, "desktop-entry", "subman-panel");
notify_notification_set_hint_string (priv->notification_registered, "x-gnome-privacy-scope", "system");
notify_notification_set_urgency (priv->notification_registered, NOTIFY_URGENCY_CRITICAL);
g_signal_connect (priv->notification_registered, "closed",
G_CALLBACK (_notify_closed_cb), manager);
@@ -740,60 +871,61 @@ gsd_subscription_manager_init (GsdSubscriptionManager *manager)
NULL);
notify_notification_set_app_name (priv->notification_registration_required, _("Subscription"));
notify_notification_set_hint_string (priv->notification_registration_required, "desktop-entry", "subman-panel");
notify_notification_set_hint_string (priv->notification_registration_required, "x-gnome-privacy-scope", "system");
notify_notification_set_urgency (priv->notification_registration_required, NOTIFY_URGENCY_CRITICAL);
notify_notification_add_action (priv->notification_registration_required,
"info-overview", _("Register System…"),
_notify_clicked_cb,
manager, NULL);
g_signal_connect (priv->notification_registration_required, "closed",
G_CALLBACK (_notify_closed_cb), manager);
}
static void
gsd_subscription_manager_finalize (GObject *object)
{
GsdSubscriptionManager *manager;
g_return_if_fail (object != NULL);
g_return_if_fail (GSD_IS_SUBSCRIPTION_MANAGER (object));
manager = GSD_SUBSCRIPTION_MANAGER (object);
gsd_subscription_manager_stop (manager);
if (manager->priv->bus_cancellable != NULL) {
g_cancellable_cancel (manager->priv->bus_cancellable);
g_clear_object (&manager->priv->bus_cancellable);
}
+ g_clear_pointer (&manager->priv->installed_products, g_ptr_array_unref);
g_clear_pointer (&manager->priv->introspection_data, g_dbus_node_info_unref);
g_clear_object (&manager->priv->connection);
g_clear_object (&manager->priv->notification_expired);
g_clear_object (&manager->priv->notification_registered);
g_timer_destroy (manager->priv->timer_last_notified);
if (manager->priv->name_id != 0) {
g_bus_unown_name (manager->priv->name_id);
manager->priv->name_id = 0;
}
G_OBJECT_CLASS (gsd_subscription_manager_parent_class)->finalize (object);
}
static void
handle_method_call (GDBusConnection *connection,
const gchar *sender,
const gchar *object_path,
const gchar *interface_name,
const gchar *method_name,
GVariant *parameters,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
GsdSubscriptionManager *manager = GSD_SUBSCRIPTION_MANAGER (user_data);
g_autoptr(GError) error = NULL;
if (g_strcmp0 (method_name, "Register") == 0) {
const gchar *organisation = NULL;
const gchar *hostname = NULL;
@@ -857,60 +989,63 @@ handle_method_call (GDBusConnection *connection,
if (!_client_unregister (manager, &error)) {
g_dbus_method_invocation_return_gerror (invocation, error);
return;
}
g_dbus_method_invocation_return_value (invocation, NULL);
} else {
g_assert_not_reached ();
}
}
static GVariant *
handle_get_property (GDBusConnection *connection,
const gchar *sender,
const gchar *object_path,
const gchar *interface_name,
const gchar *property_name,
GError **error, gpointer user_data)
{
GsdSubscriptionManager *manager = GSD_SUBSCRIPTION_MANAGER (user_data);
GsdSubscriptionManagerPrivate *priv = manager->priv;
if (g_strcmp0 (interface_name, GSD_SUBSCRIPTION_DBUS_INTERFACE) != 0) {
g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
"No such interface: %s", interface_name);
return NULL;
}
if (g_strcmp0 (property_name, "SubscriptionStatus") == 0)
return g_variant_new_uint32 (priv->subscription_status);
+ if (g_strcmp0 (property_name, "InstalledProducts") == 0)
+ return _make_installed_products_variant (priv->installed_products);
+
g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
"Failed to get property: %s", property_name);
return NULL;
}
static gboolean
handle_set_property (GDBusConnection *connection,
const gchar *sender,
const gchar *object_path,
const gchar *interface_name,
const gchar *property_name,
GVariant *value,
GError **error, gpointer user_data)
{
if (g_strcmp0 (interface_name, GSD_SUBSCRIPTION_DBUS_INTERFACE) != 0) {
g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
"No such interface: %s", interface_name);
return FALSE;
}
g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
"No such property: %s", property_name);
return FALSE;
}
static const GDBusInterfaceVTable interface_vtable =
{
handle_method_call,
handle_get_property,
handle_set_property
};
--
2.30.0

View File

@ -1,451 +0,0 @@
From 31844edad70876e26ab995179bc67fb3b23a1793 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Mon, 6 Nov 2017 16:39:55 -0500
Subject: [PATCH 3/4] account: display nag screen periodically
This is configurable via a gsettings key.
---
data/meson.build | 1 +
...ings-daemon.plugins.account.gschema.xml.in | 9 +++
plugins/account/gsd-account-manager.c | 55 +++++++++++++++++++
3 files changed, 65 insertions(+)
create mode 100644 data/org.gnome.settings-daemon.plugins.account.gschema.xml.in
diff --git a/data/meson.build b/data/meson.build
index e93ba641..5a2cd5a7 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,36 +1,37 @@
data_inc = include_directories('.')
schemas = [
'org.gnome.settings-daemon.peripherals.gschema.xml',
'org.gnome.settings-daemon.peripherals.wacom.gschema.xml',
'org.gnome.settings-daemon.plugins.gschema.xml',
+ 'org.gnome.settings-daemon.plugins.account.gschema.xml',
'org.gnome.settings-daemon.plugins.color.gschema.xml',
'org.gnome.settings-daemon.plugins.housekeeping.gschema.xml',
'org.gnome.settings-daemon.plugins.media-keys.gschema.xml',
'org.gnome.settings-daemon.plugins.power.gschema.xml',
'org.gnome.settings-daemon.plugins.sharing.gschema.xml',
'org.gnome.settings-daemon.plugins.xsettings.gschema.xml'
]
schema_conf = configuration_data()
schema_conf.set('GETTEXT_PACKAGE', meson.project_name())
schemas_xml = []
foreach schema: schemas
schemas_xml += [configure_file(
input: schema + '.in',
output: schema,
configuration: schema_conf,
install: true,
install_dir: gsd_schemadir
)]
endforeach
enums_header = files('gsd-enums.h')
mkenums = gnome.mkenums(
'org.gnome.settings-daemon.enums.xml',
sources: enums_header,
comments: '<!-- @comment@ -->',
fhead: '<schemalist>',
vhead: ' <@type@ id="org.gnome.settings-daemon.@EnumName@">',
diff --git a/data/org.gnome.settings-daemon.plugins.account.gschema.xml.in b/data/org.gnome.settings-daemon.plugins.account.gschema.xml.in
new file mode 100644
index 00000000..f3d59e81
--- /dev/null
+++ b/data/org.gnome.settings-daemon.plugins.account.gschema.xml.in
@@ -0,0 +1,9 @@
+<schemalist>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.plugins.account" path="/org/gnome/settings-daemon/plugins/account/">
+ <key name="notify-period" type="i">
+ <default>1440</default>
+ <summary>Time before repeated warning about account password expiration</summary>
+ <description>If a user's account is expiring, a notification will get displayed periodically after the specified number of minutes</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/plugins/account/gsd-account-manager.c b/plugins/account/gsd-account-manager.c
index cb37f466..ff054edd 100644
--- a/plugins/account/gsd-account-manager.c
+++ b/plugins/account/gsd-account-manager.c
@@ -20,126 +20,135 @@
#include "config.h"
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <locale.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <cups/cups.h>
#include <cups/ppd.h>
#include <libnotify/notify.h>
#include "gnome-settings-profile.h"
#include "gnome-settings-bus.h"
#include "gsd-account-manager.h"
#include "org.freedesktop.Accounts.h"
#include "org.freedesktop.Accounts.User.h"
#define GSD_ACCOUNT_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_ACCOUNT_MANAGER, GsdAccountManagerPrivate))
struct GsdAccountManagerPrivate
{
+ GSettings *settings;
+
GsdAccounts *accounts_proxy;
GsdAccountsUser *accounts_user_proxy;
GCancellable *cancellable;
GsdScreenSaver *screensaver_proxy;
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;
NotifyNotification *notification;
+
+ gint64 last_notify_time;
+ int notify_period;
+ guint notify_period_timeout_id;
};
static void gsd_account_manager_class_init (GsdAccountManagerClass *klass);
static void gsd_account_manager_init (GsdAccountManager *account_manager);
static void gsd_account_manager_finalize (GObject *object);
+static void fetch_password_expiration_policy (GsdAccountManager *manager);
G_DEFINE_TYPE (GsdAccountManager, gsd_account_manager, G_TYPE_OBJECT)
static gpointer manager_object = NULL;
static void
on_notification_closed (NotifyNotification *notification,
gpointer user_data)
{
GsdAccountManager *manager = user_data;
g_clear_object (&manager->priv->notification);
}
static void
hide_notification (GsdAccountManager *manager)
{
if (manager->priv->notification == NULL)
return;
notify_notification_close (manager->priv->notification, NULL);
g_clear_object (&manager->priv->notification);
}
static void
show_notification (GsdAccountManager *manager,
const char *primary_text,
const char *secondary_text)
{
g_assert (manager->priv->notification == NULL);
manager->priv->notification = notify_notification_new (primary_text,
secondary_text,
"avatar-default-symbolic");
notify_notification_set_app_name (manager->priv->notification, _("User Account"));
notify_notification_set_hint (manager->priv->notification,
"resident",
g_variant_new_boolean (TRUE));
notify_notification_set_timeout (manager->priv->notification,
NOTIFY_EXPIRES_NEVER);
g_signal_connect (manager->priv->notification,
"closed",
G_CALLBACK (on_notification_closed),
manager);
notify_notification_show (manager->priv->notification, NULL);
+
+ manager->priv->last_notify_time = g_get_monotonic_time ();
}
static void
update_password_notification (GsdAccountManager *manager)
{
gint64 days_since_epoch;
gint64 days_until_expiration = -1;
gint64 days_since_last_change = -1;
gint64 days_left = -1;
g_autofree char *primary_text = NULL;
g_autofree char *secondary_text = NULL;
gboolean password_already_expired = FALSE;
hide_notification (manager);
days_since_epoch = g_get_real_time () / G_USEC_PER_SEC / 60 / 60 / 24;
if (manager->priv->expiration_time > 0) {
days_until_expiration = manager->priv->expiration_time - days_since_epoch;
if (days_until_expiration <= 0) {
password_already_expired = TRUE;
goto out;
}
}
if (manager->priv->last_change_time == 0) {
password_already_expired = TRUE;
goto out;
}
@@ -181,99 +190,127 @@ out:
primary_text = g_strdup_printf (_("Password Expired"));
secondary_text = g_strdup_printf (_("Your password is expired. Please update it."));
} else if (days_left >= 0) {
primary_text = g_strdup_printf (_("Password Expiring Soon"));
if (days_left == 0)
secondary_text = g_strdup_printf (_("Your password is expiring today."));
else if (days_left == 1)
secondary_text = g_strdup_printf (_("Your password is expiring in a day."));
else
secondary_text = g_strdup_printf (_("Your password is expiring in %ld days."),
days_left);
}
if (primary_text != NULL && secondary_text != NULL)
show_notification (manager,
primary_text,
secondary_text);
}
static gboolean
set_policy_number (gint64 *destination,
gint64 source)
{
if (*destination == source)
return FALSE;
*destination = source;
return TRUE;
}
+static gboolean
+on_notify_period_elapsed (GsdAccountManager *manager)
+{
+ manager->priv->notify_period_timeout_id = 0;
+ fetch_password_expiration_policy (manager);
+ return G_SOURCE_REMOVE;
+}
+
+static void
+queue_periodic_timeout (GsdAccountManager *manager)
+{
+ if (manager->priv->notify_period_timeout_id != 0) {
+ g_source_remove (manager->priv->notify_period_timeout_id);
+ manager->priv->notify_period_timeout_id = 0;
+ }
+
+ if (manager->priv->notify_period > 0) {
+ gint64 already_elapsed_time;
+
+ already_elapsed_time = MAX (0, (g_get_monotonic_time () - manager->priv->last_notify_time) / G_USEC_PER_SEC);
+
+ manager->priv->notify_period_timeout_id = g_timeout_add_seconds (MAX (0, manager->priv->notify_period * 60 - already_elapsed_time),
+ (GSourceFunc) on_notify_period_elapsed,
+ manager);
+ }
+}
+
static void
on_got_password_expiration_policy (GsdAccountsUser *accounts_user_proxy,
GAsyncResult *res,
gpointer user_data)
{
GsdAccountManager *manager = user_data;
g_autoptr(GError) error = NULL;
gboolean succeeded;
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;
gnome_settings_profile_start (NULL);
succeeded = gsd_accounts_user_call_get_password_expiration_policy_finish (accounts_user_proxy,
&expiration_time,
&last_change_time,
&min_days_between_changes,
&max_days_between_changes,
&days_to_warn,
&days_after_expiration_until_lock,
res,
&error);
if (!succeeded) {
g_warning ("Failed to get password expiration policy for user: %s", error->message);
goto out;
}
set_policy_number (&manager->priv->expiration_time, expiration_time);
set_policy_number (&manager->priv->last_change_time, last_change_time);
set_policy_number (&manager->priv->min_days_between_changes, min_days_between_changes);
set_policy_number (&manager->priv->max_days_between_changes, max_days_between_changes);
set_policy_number (&manager->priv->days_to_warn, days_to_warn);
set_policy_number (&manager->priv->days_after_expiration_until_lock, days_after_expiration_until_lock);
update_password_notification (manager);
+ queue_periodic_timeout (manager);
out:
gnome_settings_profile_end (NULL);
}
static void
fetch_password_expiration_policy (GsdAccountManager *manager)
{
gsd_accounts_user_call_get_password_expiration_policy (manager->priv->accounts_user_proxy,
manager->priv->cancellable,
(GAsyncReadyCallback)
on_got_password_expiration_policy,
manager);
}
static void
on_screensaver_signal (GDBusProxy *proxy,
const gchar *sender_name,
const gchar *signal_name,
GVariant *parameters,
gpointer user_data)
{
GsdAccountManager *manager = user_data;
if (g_strcmp0 (signal_name, "ActiveChanged") == 0) {
gboolean active;
g_variant_get (parameters, "(b)", &active);
if (!active) {
fetch_password_expiration_policy (manager);
@@ -346,91 +383,109 @@ on_got_user_object_path (GsdAccounts *accounts_proxy,
manager);
out:
gnome_settings_profile_end (NULL);
}
static void
on_got_accounts_proxy (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GsdAccountManager *manager = user_data;
g_autoptr(GError) error = NULL;
gnome_settings_profile_start (NULL);
manager->priv->accounts_proxy = gsd_accounts_proxy_new_for_bus_finish (res, &error);
if (manager->priv->accounts_proxy != NULL) {
gsd_accounts_call_find_user_by_id (manager->priv->accounts_proxy,
getuid (),
manager->priv->cancellable,
(GAsyncReadyCallback)
on_got_user_object_path,
manager);
} else {
g_warning ("Failed to get proxy to accounts service: %s", error->message);
}
gnome_settings_profile_end (NULL);
}
+static void
+on_notify_period_changed (GsdAccountManager *manager)
+{
+ manager->priv->notify_period = g_settings_get_int (manager->priv->settings, "notify-period");
+
+ queue_periodic_timeout (manager);
+}
+
gboolean
gsd_account_manager_start (GsdAccountManager *manager,
GError **error)
{
g_debug ("Starting accounts manager");
gnome_settings_profile_start (NULL);
manager->priv->cancellable = g_cancellable_new ();
+ manager->priv->settings = g_settings_new ("org.gnome.settings-daemon.plugins.account");
+
+ manager->priv->notify_period = g_settings_get_int (manager->priv->settings, "notify-period");
+ g_signal_connect_object (G_OBJECT (manager->priv->settings),
+ "changed::notify-period",
+ G_CALLBACK (on_notify_period_changed),
+ manager,
+ G_CONNECT_SWAPPED);
+
gsd_accounts_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
"org.freedesktop.Accounts",
"/org/freedesktop/Accounts",
manager->priv->cancellable,
(GAsyncReadyCallback)
on_got_accounts_proxy,
manager);
gnome_settings_profile_end (NULL);
return TRUE;
}
void
gsd_account_manager_stop (GsdAccountManager *manager)
{
g_debug ("Stopping accounts manager");
if (manager->priv->cancellable != NULL) {
g_cancellable_cancel (manager->priv->cancellable);
g_clear_object (&manager->priv->cancellable);
}
+ g_clear_object (&manager->priv->settings);
g_clear_object (&manager->priv->accounts_proxy);
g_clear_object (&manager->priv->accounts_user_proxy);
g_clear_object (&manager->priv->notification);
g_clear_object (&manager->priv->screensaver_proxy);
}
static void
gsd_account_manager_class_init (GsdAccountManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gsd_account_manager_finalize;
notify_init ("gnome-settings-daemon");
g_type_class_add_private (klass, sizeof (GsdAccountManagerPrivate));
}
static void
gsd_account_manager_init (GsdAccountManager *manager)
{
manager->priv = GSD_ACCOUNT_MANAGER_GET_PRIVATE (manager);
}
static void
gsd_account_manager_finalize (GObject *object)
{
GsdAccountManager *manager;
g_return_if_fail (object != NULL);
--
2.21.0

View File

@ -1,313 +0,0 @@
From 0d88b2133b20957e00b0eeb0c0f48932485cc73d Mon Sep 17 00:00:00 2001
From: Kalev Lember <klember@redhat.com>
Date: Fri, 28 Jun 2019 18:10:36 +0200
Subject: [PATCH 03/15] subman: Increase RHSM dbus call timeouts
Increase the dbus timeouts to 5 minutes as the register/unregister calls
seem to routinely take more than a minute.
---
plugins/subman/gsd-subman-helper.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/plugins/subman/gsd-subman-helper.c b/plugins/subman/gsd-subman-helper.c
index 182f7190..af7a82e9 100644
--- a/plugins/subman/gsd-subman-helper.c
+++ b/plugins/subman/gsd-subman-helper.c
@@ -1,60 +1,62 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2019 Richard Hughes <rhughes@redhat.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <gio/gio.h>
#include <json-glib/json-glib.h>
+#define DBUS_TIMEOUT 300000 /* 5 minutes */
+
static void
_helper_convert_error (const gchar *json_txt, GError **error)
{
JsonNode *json_root;
JsonObject *json_obj;
const gchar *message;
g_autoptr(JsonParser) json_parser = json_parser_new ();
/* this may be plain text or JSON :| */
if (!json_parser_load_from_data (json_parser, json_txt, -1, NULL)) {
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
json_txt);
return;
}
json_root = json_parser_get_root (json_parser);
json_obj = json_node_get_object (json_root);
if (!json_object_has_member (json_obj, "message")) {
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"no message' in %s", json_txt);
return;
}
message = json_object_get_string_member (json_obj, "message");
if (g_strstr_len (message, -1, "Invalid user credentials") != NULL) {
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_PERMISSION_DENIED,
@@ -67,125 +69,128 @@ _helper_convert_error (const gchar *json_txt, GError **error)
message);
}
static gboolean
_helper_unregister (GError **error)
{
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GVariantBuilder) proxy_options = NULL;
g_autoptr(GVariant) res = NULL;
g_debug ("unregistering");
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
"com.redhat.RHSM1",
"/com/redhat/RHSM1/Unregister",
"com.redhat.RHSM1.Unregister",
NULL, error);
if (proxy == NULL) {
g_prefix_error (error, "Failed to get proxy: ");
return FALSE;
}
proxy_options = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);
res = g_dbus_proxy_call_sync (proxy,
"Unregister",
g_variant_new ("(a{sv}s)",
proxy_options,
""), /* lang */
G_DBUS_CALL_FLAGS_NONE,
- -1, NULL, error);
+ DBUS_TIMEOUT,
+ NULL, error);
return res != NULL;
}
static gboolean
_helper_auto_attach (GError **error)
{
const gchar *str = NULL;
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GVariantBuilder) proxy_options = NULL;
g_autoptr(GVariant) res = NULL;
g_debug ("auto-attaching subscriptions");
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
"com.redhat.RHSM1",
"/com/redhat/RHSM1/Attach",
"com.redhat.RHSM1.Attach",
NULL, error);
if (proxy == NULL) {
g_prefix_error (error, "Failed to get proxy: ");
return FALSE;
}
proxy_options = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);
res = g_dbus_proxy_call_sync (proxy,
"AutoAttach",
g_variant_new ("(sa{sv}s)",
"", /* now? */
proxy_options,
""), /* lang */
G_DBUS_CALL_FLAGS_NONE,
- -1, NULL, error);
+ DBUS_TIMEOUT,
+ NULL, error);
if (res == NULL)
return FALSE;
g_variant_get (res, "(&s)", &str);
g_debug ("Attach.AutoAttach: %s", str);
return TRUE;
}
static gboolean
_helper_save_config (const gchar *key, const gchar *value, GError **error)
{
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GVariant) res = NULL;
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
"com.redhat.RHSM1",
"/com/redhat/RHSM1/Config",
"com.redhat.RHSM1.Config",
NULL, error);
if (proxy == NULL) {
g_prefix_error (error, "Failed to get proxy: ");
return FALSE;
}
res = g_dbus_proxy_call_sync (proxy, "Set",
g_variant_new ("(svs)",
key,
g_variant_new_string (value),
""), /* lang */
G_DBUS_CALL_FLAGS_NONE,
- -1, NULL, error);
+ DBUS_TIMEOUT,
+ NULL, error);
return res != NULL;
}
int
main (int argc, char *argv[])
{
const gchar *userlang = ""; /* as root, so no translations */
g_autofree gchar *activation_key = NULL;
g_autofree gchar *address = NULL;
g_autofree gchar *hostname = NULL;
g_autofree gchar *kind = NULL;
g_autofree gchar *organisation = NULL;
g_autofree gchar *password = NULL;
g_autofree gchar *port = NULL;
g_autofree gchar *prefix = NULL;
g_autofree gchar *proxy_server = NULL;
g_autofree gchar *username = NULL;
g_autoptr(GDBusConnection) conn_private = NULL;
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GOptionContext) context = g_option_context_new (NULL);
g_autoptr(GVariantBuilder) proxy_options = NULL;
g_autoptr(GVariantBuilder) subman_conopts = NULL;
g_autoptr(GVariantBuilder) subman_options = NULL;
const GOptionEntry options[] = {
{ "kind", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
&kind, "Kind, e.g. 'username' or 'key'", NULL },
{ "address", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
&address, "UNIX address", NULL },
@@ -278,95 +283,97 @@ main (int argc, char *argv[])
g_variant_builder_add (subman_conopts, "{ss}", "host", hostname);
g_variant_builder_add (subman_conopts, "{ss}", "handler", prefix);
g_variant_builder_add (subman_conopts, "{ss}", "port", port);
/* call into RHSM */
if (g_strcmp0 (kind, "register-with-key") == 0) {
g_auto(GStrv) activation_keys = NULL;
g_autoptr(GError) error_local = NULL;
g_autoptr(GVariant) res = NULL;
if (activation_key == NULL) {
g_printerr ("Required --activation-key\n");
return G_IO_ERROR_INVALID_DATA;
}
if (organisation == NULL) {
g_printerr ("Required --organisation\n");
return G_IO_ERROR_INVALID_DATA;
}
g_debug ("registering using activation key");
activation_keys = g_strsplit (activation_key, ",", -1);
res = g_dbus_proxy_call_sync (proxy,
"RegisterWithActivationKeys",
g_variant_new ("(s^asa{ss}a{ss}s)",
organisation,
activation_keys,
subman_options,
subman_conopts,
userlang),
G_DBUS_CALL_FLAGS_NO_AUTO_START,
- -1, NULL, &error_local);
+ DBUS_TIMEOUT,
+ NULL, &error_local);
if (res == NULL) {
g_dbus_error_strip_remote_error (error_local);
_helper_convert_error (error_local->message, &error);
g_printerr ("Failed to RegisterWithActivationKeys: %s\n", error->message);
return error->code;
}
} else if (g_strcmp0 (kind, "register-with-username") == 0) {
g_autoptr(GError) error_local = NULL;
g_autoptr(GVariant) res = NULL;
g_debug ("registering using username and password");
if (username == NULL) {
g_printerr ("Required --username\n");
return G_IO_ERROR_INVALID_DATA;
}
if (password == NULL) {
g_printerr ("Required --password\n");
return G_IO_ERROR_INVALID_DATA;
}
if (organisation == NULL) {
g_printerr ("Required --organisation\n");
return G_IO_ERROR_INVALID_DATA;
}
res = g_dbus_proxy_call_sync (proxy,
"Register",
g_variant_new ("(sssa{ss}a{ss}s)",
organisation,
username,
password,
subman_options,
subman_conopts,
userlang),
G_DBUS_CALL_FLAGS_NO_AUTO_START,
- -1, NULL, &error_local);
+ DBUS_TIMEOUT,
+ NULL, &error_local);
if (res == NULL) {
g_dbus_error_strip_remote_error (error_local);
_helper_convert_error (error_local->message, &error);
g_printerr ("Failed to Register: %s\n", error->message);
return error->code;
}
} else {
g_printerr ("Invalid --kind specified: %s\n", kind);
return G_IO_ERROR_INVALID_DATA;
}
/* set the new hostname */
if (!_helper_save_config ("server.hostname", hostname, &error)) {
g_printerr ("Failed to save hostname: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
if (!_helper_save_config ("server.prefix", prefix, &error)) {
g_printerr ("Failed to save prefix: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
if (!_helper_save_config ("server.port", port, &error)) {
g_printerr ("Failed to save port: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
/* wait for rhsmd to notice the new config */
g_usleep (G_USEC_PER_SEC * 5);
/* auto-attach */
if (!_helper_auto_attach (&error)) {
--
2.30.0

View File

@ -1,110 +0,0 @@
From ff98c03c88e53041dcc861de3b3a3351d55297fe Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 9 Nov 2018 10:39:11 -0500
Subject: [PATCH 4/4] account: don't poll more frequently than notification
period
At the moment, if an account has no reason to receive a notification,
the account plugin ends up polling continuously, desperately,
and unsuccessfully trying to find a reason to notify. That leads
to unnecessary CPU utilization.
The reason is an apparent think-o in the code. The code tracks
the last time a notification was shown, so it knows when to show
the next notification later, even if the notification period, or
account policy is updated by the admin in the interim.
The problem is that it's wrong to look at the last notification
time if there's no reason to show a notification. In that case
the wakeup is merely to poll updates on the account policy.
This commit addresses the problem by only looking at the previous
notification time, if it was within the current notification period.
---
plugins/account/gsd-account-manager.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/plugins/account/gsd-account-manager.c b/plugins/account/gsd-account-manager.c
index ff054edd..b48c0fe8 100644
--- a/plugins/account/gsd-account-manager.c
+++ b/plugins/account/gsd-account-manager.c
@@ -207,65 +207,73 @@ out:
}
static gboolean
set_policy_number (gint64 *destination,
gint64 source)
{
if (*destination == source)
return FALSE;
*destination = source;
return TRUE;
}
static gboolean
on_notify_period_elapsed (GsdAccountManager *manager)
{
manager->priv->notify_period_timeout_id = 0;
fetch_password_expiration_policy (manager);
return G_SOURCE_REMOVE;
}
static void
queue_periodic_timeout (GsdAccountManager *manager)
{
if (manager->priv->notify_period_timeout_id != 0) {
g_source_remove (manager->priv->notify_period_timeout_id);
manager->priv->notify_period_timeout_id = 0;
}
if (manager->priv->notify_period > 0) {
- gint64 already_elapsed_time;
+ gint64 seconds_since_last_notification;
+ guint seconds_between_notifications;
+ guint seconds_until_next_notification;
- already_elapsed_time = MAX (0, (g_get_monotonic_time () - manager->priv->last_notify_time) / G_USEC_PER_SEC);
+ seconds_since_last_notification = MAX (0, (g_get_monotonic_time () - manager->priv->last_notify_time) / G_USEC_PER_SEC);
+ seconds_between_notifications = manager->priv->notify_period * 60;
- manager->priv->notify_period_timeout_id = g_timeout_add_seconds (MAX (0, manager->priv->notify_period * 60 - already_elapsed_time),
+ if (seconds_since_last_notification > seconds_between_notifications)
+ seconds_until_next_notification = seconds_between_notifications;
+ else
+ seconds_until_next_notification = seconds_between_notifications - seconds_since_last_notification;
+
+ manager->priv->notify_period_timeout_id = g_timeout_add_seconds (seconds_until_next_notification,
(GSourceFunc) on_notify_period_elapsed,
manager);
}
}
static void
on_got_password_expiration_policy (GsdAccountsUser *accounts_user_proxy,
GAsyncResult *res,
gpointer user_data)
{
GsdAccountManager *manager = user_data;
g_autoptr(GError) error = NULL;
gboolean succeeded;
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;
gnome_settings_profile_start (NULL);
succeeded = gsd_accounts_user_call_get_password_expiration_policy_finish (accounts_user_proxy,
&expiration_time,
&last_change_time,
&min_days_between_changes,
&max_days_between_changes,
&days_to_warn,
&days_after_expiration_until_lock,
res,
&error);
--
2.21.0

View File

@ -1,454 +0,0 @@
From df08a65d86626ff135a12d96cff6f48f3f1864ae Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Thu, 20 Aug 2020 11:20:47 -0400
Subject: [PATCH 04/15] subman: Drop userlang field
It's currently always erroneously set to empty string.
This commit drops it, and just uses "C.UTF-8" everywhere,
which is what we actually want.
---
plugins/subman/gsd-subscription-manager.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/plugins/subman/gsd-subscription-manager.c b/plugins/subman/gsd-subscription-manager.c
index a8c18a26..46f051a5 100644
--- a/plugins/subman/gsd-subscription-manager.c
+++ b/plugins/subman/gsd-subscription-manager.c
@@ -45,61 +45,60 @@ static const gchar introspection_xml[] =
" <arg type='a{sv}' name='options' direction='in'/>"
" </method>"
" <method name='Unregister'/>"
" <property name='InstalledProducts' type='aa{sv}' access='read'/>"
" <property name='SubscriptionStatus' type='u' access='read'/>"
" </interface>"
"</node>";
#define GSD_SUBSCRIPTION_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_SUBSCRIPTION_MANAGER, GsdSubscriptionManagerPrivate))
typedef enum {
_RHSM_INTERFACE_CONFIG,
_RHSM_INTERFACE_REGISTER_SERVER,
_RHSM_INTERFACE_ATTACH,
_RHSM_INTERFACE_ENTITLEMENT,
_RHSM_INTERFACE_PRODUCTS,
_RHSM_INTERFACE_CONSUMER,
_RHSM_INTERFACE_SYSPURPOSE,
_RHSM_INTERFACE_LAST
} _RhsmInterface;
struct GsdSubscriptionManagerPrivate
{
/* D-Bus */
guint name_id;
GDBusNodeInfo *introspection_data;
GDBusConnection *connection;
GCancellable *bus_cancellable;
GDBusProxy *proxies[_RHSM_INTERFACE_LAST];
- const gchar *userlang; /* owned by GLib internally */
GHashTable *config; /* str:str */
GPtrArray *installed_products;
gchar *address;
GTimer *timer_last_notified;
NotifyNotification *notification_expired;
NotifyNotification *notification_registered;
NotifyNotification *notification_registration_required;
GsdSubmanSubscriptionStatus subscription_status;
GsdSubmanSubscriptionStatus subscription_status_last;
};
enum {
PROP_0,
};
static void gsd_subscription_manager_class_init (GsdSubscriptionManagerClass *klass);
static void gsd_subscription_manager_init (GsdSubscriptionManager *subscription_manager);
static void gsd_subscription_manager_finalize (GObject *object);
G_DEFINE_TYPE (GsdSubscriptionManager, gsd_subscription_manager, G_TYPE_OBJECT)
typedef struct
{
gchar *product_name;
gchar *product_id;
gchar *version;
gchar *arch;
gchar *status;
gchar *starts;
@@ -197,61 +196,61 @@ _emit_property_changed (GsdSubscriptionManager *manager,
property_value);
g_dbus_connection_emit_signal (priv->connection,
NULL,
GSD_SUBSCRIPTION_DBUS_PATH,
"org.freedesktop.DBus.Properties",
"PropertiesChanged",
g_variant_new ("(sa{sv}as)",
GSD_SUBSCRIPTION_DBUS_INTERFACE,
&builder,
&invalidated_builder),
NULL);
g_variant_builder_clear (&builder);
g_variant_builder_clear (&invalidated_builder);
}
static gboolean
_client_installed_products_update (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
JsonNode *json_root;
JsonArray *json_products_array;
const gchar *json_txt = NULL;
g_autoptr(GVariant) val = NULL;
g_autoptr(JsonParser) json_parser = json_parser_new ();
val = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_PRODUCTS],
"ListInstalledProducts",
g_variant_new ("(sa{sv}s)",
"" /* filter_string */,
NULL /* proxy_options */,
- priv->userlang),
+ "C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (val == NULL)
return FALSE;
g_variant_get (val, "(&s)", &json_txt);
g_debug ("Products.ListInstalledProducts JSON: %s", json_txt);
if (!json_parser_load_from_data (json_parser, json_txt, -1, error))
return FALSE;
json_root = json_parser_get_root (json_parser);
json_products_array = json_node_get_array (json_root);
if (json_products_array == NULL) {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
"no InstalledProducts array in %s", json_txt);
return FALSE;
}
g_ptr_array_set_size (priv->installed_products, 0);
for (guint i = 0; i < json_array_get_length (json_products_array); i++) {
JsonArray *json_product = json_array_get_array_element (json_products_array, i);
g_autoptr(ProductData) product = g_new0 (ProductData, 1);
if (json_product == NULL)
continue;
if (json_array_get_length (json_product) < 8) {
g_debug ("Unexpected number of array elements in InstalledProducts JSON");
continue;
}
product->product_name = g_strdup (json_array_get_string_element (json_product, 0));
@@ -263,179 +262,179 @@ _client_installed_products_update (GsdSubscriptionManager *manager, GError **err
product->ends = g_strdup (json_array_get_string_element (json_product, 7));
g_ptr_array_add (priv->installed_products, g_steal_pointer (&product));
}
/* emit notification for g-c-c */
_emit_property_changed (manager, "InstalledProducts",
_make_installed_products_variant (priv->installed_products));
return TRUE;
}
static gboolean
_client_subscription_status_update (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
JsonNode *json_root;
JsonObject *json_obj;
const gchar *json_txt = NULL;
const gchar *status_txt = NULL;
g_autoptr(GVariant) val = NULL;
g_autoptr(JsonParser) json_parser = json_parser_new ();
/* save old value */
priv->subscription_status_last = priv->subscription_status;
val = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_ENTITLEMENT],
"GetStatus",
g_variant_new ("(ss)",
"", /* assumed as 'now' */
- priv->userlang),
+ "C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (val == NULL)
return FALSE;
g_variant_get (val, "(&s)", &json_txt);
g_debug ("Entitlement.GetStatus JSON: %s", json_txt);
if (!json_parser_load_from_data (json_parser, json_txt, -1, error))
return FALSE;
json_root = json_parser_get_root (json_parser);
json_obj = json_node_get_object (json_root);
if (!json_object_has_member (json_obj, "status")) {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
"no Entitlement.GetStatus status in %s", json_txt);
return FALSE;
}
status_txt = json_object_get_string_member (json_obj, "status");
g_debug ("Entitlement.GetStatus: %s", status_txt);
priv->subscription_status = _client_subscription_status_from_text (status_txt);
/* emit notification for g-c-c */
if (priv->subscription_status != priv->subscription_status_last) {
_emit_property_changed (manager, "SubscriptionStatus",
g_variant_new_uint32 (priv->subscription_status));
}
return TRUE;
}
static gboolean
_client_syspurpose_update (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
JsonNode *json_root;
JsonObject *json_obj;
const gchar *json_txt = NULL;
g_autoptr(GVariant) val = NULL;
g_autoptr(JsonParser) json_parser = json_parser_new ();
val = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_SYSPURPOSE],
"GetSyspurpose",
- g_variant_new ("(s)", priv->userlang),
+ g_variant_new ("(s)", "C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (val == NULL)
return FALSE;
g_variant_get (val, "(&s)", &json_txt);
g_debug ("Syspurpose.GetSyspurpose JSON: %s", json_txt);
if (!json_parser_load_from_data (json_parser, json_txt, -1, error))
return FALSE;
json_root = json_parser_get_root (json_parser);
json_obj = json_node_get_object (json_root);
if (!json_object_has_member (json_obj, "status")) {
g_debug ("Syspurpose.GetSyspurpose: Unknown");
return TRUE;
}
g_debug ("Syspurpose.GetSyspurpose: '%s", json_object_get_string_member (json_obj, "status"));
return TRUE;
}
static gboolean
_client_register_start (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
const gchar *address = NULL;
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GVariant) val = NULL;
/* already started */
if (priv->address != NULL)
return TRUE;
/* apparently: "we can't send registration credentials over the regular
* system or session bus since those aren't really locked down..." */
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
"com.redhat.RHSM1",
"/com/redhat/RHSM1/RegisterServer",
"com.redhat.RHSM1.RegisterServer",
NULL, error);
if (proxy == NULL)
return FALSE;
val = g_dbus_proxy_call_sync (proxy, "Start",
- g_variant_new ("(s)", priv->userlang),
+ g_variant_new ("(s)", "C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (val == NULL)
return FALSE;
g_variant_get (val, "(&s)", &address);
g_debug ("RegisterServer.Start: %s", address);
priv->address = g_strdup (address);
return TRUE;
}
static gboolean
_client_register_stop (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GVariant) val = NULL;
/* already started */
if (priv->address == NULL)
return TRUE;
/* stop registration server */
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
"com.redhat.RHSM1",
"/com/redhat/RHSM1/RegisterServer",
"com.redhat.RHSM1.RegisterServer",
NULL, error);
if (proxy == NULL)
return FALSE;
val = g_dbus_proxy_call_sync (proxy, "Stop",
- g_variant_new ("(s)", priv->userlang),
+ g_variant_new ("(s)", "C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (val == NULL)
return FALSE;
g_clear_pointer (&priv->address, g_free);
return TRUE;
}
static gboolean
_client_subprocess_wait_check (GSubprocess *subprocess, GError **error)
{
gint rc;
if (!g_subprocess_wait (subprocess, NULL, error)) {
g_prefix_error (error, "failed to run pkexec: ");
return FALSE;
}
rc = g_subprocess_get_exit_status (subprocess);
if (rc != 0) {
GInputStream *istream = g_subprocess_get_stderr_pipe (subprocess);
gchar buf[1024] = { 0x0 };
gsize sz = 0;
g_input_stream_read_all (istream, buf, sizeof(buf) - 1, &sz, NULL, NULL);
if (sz == 0) {
g_set_error_literal (error, G_IO_ERROR, rc,
"Failed to run helper without stderr");
return FALSE;
}
g_set_error_literal (error, G_IO_ERROR, rc, buf);
return FALSE;
}
@@ -637,61 +636,61 @@ _client_unregister (GsdSubscriptionManager *manager, GError **error)
"pkexec", LIBEXECDIR "/gsd-subman-helper",
"--kind", "unregister",
NULL);
if (subprocess == NULL) {
g_prefix_error (error, "failed to find pkexec: ");
return FALSE;
}
if (!_client_subprocess_wait_check (subprocess, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
if (!_client_installed_products_update (manager, error))
return FALSE;
_client_maybe__show_notification (manager);
return TRUE;
}
static gboolean
_client_update_config (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
g_autoptr(GVariant) val = NULL;
g_autoptr(GVariant) val_server = NULL;
g_autoptr(GVariantDict) dict = NULL;
GVariantIter iter;
gchar *key;
gchar *value;
val = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_CONFIG],
"GetAll",
- g_variant_new ("(s)", priv->userlang),
+ g_variant_new ("(s)", "C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (val == NULL)
return FALSE;
dict = g_variant_dict_new (g_variant_get_child_value (val, 0));
val_server = g_variant_dict_lookup_value (dict, "server", G_VARIANT_TYPE("a{ss}"));
if (val_server != NULL) {
g_variant_iter_init (&iter, val_server);
while (g_variant_iter_next (&iter, "{ss}", &key, &value)) {
g_debug ("%s=%s", key, value);
g_hash_table_insert (priv->config,
g_steal_pointer (&key),
g_steal_pointer (&value));
}
}
return TRUE;
}
static void
_subman_proxy_signal_cb (GDBusProxy *proxy,
const gchar *sender_name,
const gchar *signal_name,
GVariant *parameters,
GsdSubscriptionManager *manager)
{
g_autoptr(GError) error = NULL;
if (!_client_syspurpose_update (manager, &error)) {
g_warning ("failed to update syspurpose: %s", error->message);
g_clear_error (&error);
}
@@ -736,61 +735,60 @@ _rhsm_interface_to_string (_RhsmInterface kind)
}
static gboolean
_client_load (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
priv->config = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
/* connect to all the interfaces on the *different* objects :| */
for (guint i = 0; i < _RHSM_INTERFACE_LAST; i++) {
const gchar *kind = _rhsm_interface_to_string (i);
g_autofree gchar *opath = g_strdup_printf ("/com/redhat/RHSM1/%s", kind);
g_autofree gchar *iface = g_strdup_printf ("com.redhat.RHSM1.%s", kind);
priv->proxies[i] =
g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
"com.redhat.RHSM1",
opath, iface,
NULL,
error);
if (priv->proxies[i] == NULL)
return FALSE;
/* we want to get notified if the status of the system changes */
g_signal_connect (priv->proxies[i], "g-signal",
G_CALLBACK (_subman_proxy_signal_cb), manager);
}
/* get initial status */
- priv->userlang = "";
if (!_client_update_config (manager, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
if (!_client_installed_products_update (manager, error))
return FALSE;
if (!_client_syspurpose_update (manager, error))
return FALSE;
/* success */
return TRUE;
}
gboolean
gsd_subscription_manager_start (GsdSubscriptionManager *manager, GError **error)
{
gboolean ret;
g_debug ("Starting subscription manager");
gnome_settings_profile_start (NULL);
ret = _client_load (manager, error);
_client_maybe__show_notification (manager);
gnome_settings_profile_end (NULL);
return ret;
}
void
gsd_subscription_manager_stop (GsdSubscriptionManager *manager)
{
g_debug ("Stopping subscription manager");
_client_unload (manager);
--
2.30.0

View File

@ -1,373 +0,0 @@
From db73e2211ecc746434d78d23d801c92581fa8824 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sun, 24 Jan 2021 15:04:17 -0500
Subject: [PATCH 05/15] subman: Use user locale for registration/subscription
operations
This makes sure that error messages are in the correct locale.
---
plugins/subman/gsd-subman-helper.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/plugins/subman/gsd-subman-helper.c b/plugins/subman/gsd-subman-helper.c
index af7a82e9..f84e91bf 100644
--- a/plugins/subman/gsd-subman-helper.c
+++ b/plugins/subman/gsd-subman-helper.c
@@ -1,61 +1,63 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2019 Richard Hughes <rhughes@redhat.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
+#include <locale.h>
#include <gio/gio.h>
#include <json-glib/json-glib.h>
#define DBUS_TIMEOUT 300000 /* 5 minutes */
+static const char *locale;
static void
_helper_convert_error (const gchar *json_txt, GError **error)
{
JsonNode *json_root;
JsonObject *json_obj;
const gchar *message;
g_autoptr(JsonParser) json_parser = json_parser_new ();
/* this may be plain text or JSON :| */
if (!json_parser_load_from_data (json_parser, json_txt, -1, NULL)) {
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
json_txt);
return;
}
json_root = json_parser_get_root (json_parser);
json_obj = json_node_get_object (json_root);
if (!json_object_has_member (json_obj, "message")) {
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"no message' in %s", json_txt);
return;
}
message = json_object_get_string_member (json_obj, "message");
if (g_strstr_len (message, -1, "Invalid user credentials") != NULL) {
g_set_error_literal (error,
G_IO_ERROR,
@@ -67,184 +69,187 @@ _helper_convert_error (const gchar *json_txt, GError **error)
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
message);
}
static gboolean
_helper_unregister (GError **error)
{
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GVariantBuilder) proxy_options = NULL;
g_autoptr(GVariant) res = NULL;
g_debug ("unregistering");
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
"com.redhat.RHSM1",
"/com/redhat/RHSM1/Unregister",
"com.redhat.RHSM1.Unregister",
NULL, error);
if (proxy == NULL) {
g_prefix_error (error, "Failed to get proxy: ");
return FALSE;
}
proxy_options = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);
res = g_dbus_proxy_call_sync (proxy,
"Unregister",
g_variant_new ("(a{sv}s)",
proxy_options,
- ""), /* lang */
+ locale),
G_DBUS_CALL_FLAGS_NONE,
DBUS_TIMEOUT,
NULL, error);
return res != NULL;
}
static gboolean
_helper_auto_attach (GError **error)
{
const gchar *str = NULL;
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GVariantBuilder) proxy_options = NULL;
g_autoptr(GVariant) res = NULL;
g_debug ("auto-attaching subscriptions");
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
"com.redhat.RHSM1",
"/com/redhat/RHSM1/Attach",
"com.redhat.RHSM1.Attach",
NULL, error);
if (proxy == NULL) {
g_prefix_error (error, "Failed to get proxy: ");
return FALSE;
}
proxy_options = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);
res = g_dbus_proxy_call_sync (proxy,
"AutoAttach",
g_variant_new ("(sa{sv}s)",
"", /* now? */
proxy_options,
- ""), /* lang */
+ locale),
G_DBUS_CALL_FLAGS_NONE,
DBUS_TIMEOUT,
NULL, error);
if (res == NULL)
return FALSE;
g_variant_get (res, "(&s)", &str);
g_debug ("Attach.AutoAttach: %s", str);
return TRUE;
}
static gboolean
_helper_save_config (const gchar *key, const gchar *value, GError **error)
{
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GVariant) res = NULL;
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
"com.redhat.RHSM1",
"/com/redhat/RHSM1/Config",
"com.redhat.RHSM1.Config",
NULL, error);
if (proxy == NULL) {
g_prefix_error (error, "Failed to get proxy: ");
return FALSE;
}
res = g_dbus_proxy_call_sync (proxy, "Set",
g_variant_new ("(svs)",
key,
g_variant_new_string (value),
- ""), /* lang */
+ locale),
G_DBUS_CALL_FLAGS_NONE,
DBUS_TIMEOUT,
NULL, error);
return res != NULL;
}
int
main (int argc, char *argv[])
{
- const gchar *userlang = ""; /* as root, so no translations */
g_autofree gchar *activation_key = NULL;
g_autofree gchar *address = NULL;
g_autofree gchar *hostname = NULL;
g_autofree gchar *kind = NULL;
g_autofree gchar *organisation = NULL;
g_autofree gchar *password = NULL;
g_autofree gchar *port = NULL;
g_autofree gchar *prefix = NULL;
g_autofree gchar *proxy_server = NULL;
g_autofree gchar *username = NULL;
g_autoptr(GDBusConnection) conn_private = NULL;
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GOptionContext) context = g_option_context_new (NULL);
g_autoptr(GVariantBuilder) proxy_options = NULL;
g_autoptr(GVariantBuilder) subman_conopts = NULL;
g_autoptr(GVariantBuilder) subman_options = NULL;
const GOptionEntry options[] = {
{ "kind", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
&kind, "Kind, e.g. 'username' or 'key'", NULL },
{ "address", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
&address, "UNIX address", NULL },
{ "username", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
&username, "Username", NULL },
{ "password", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
&password, "Password", NULL },
{ "organisation", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
&organisation, "Organisation", NULL },
{ "activation-key", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
&activation_key, "Activation keys", NULL },
{ "hostname", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING,
&hostname, "Registration server hostname", NULL },
{ "prefix", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING,
&prefix, "Registration server prefix", NULL },
{ "port", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING,
&port, "Registration server port", NULL },
{ "proxy", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING,
&proxy_server, "Proxy settings", NULL },
{ NULL}
};
/* check calling UID */
if (getuid () != 0 || geteuid () != 0) {
g_printerr ("This program can only be used by the root user\n");
return G_IO_ERROR_NOT_SUPPORTED;
}
+
+ setlocale (LC_ALL, "");
+ locale = setlocale (LC_MESSAGES, NULL);
+
g_option_context_add_main_entries (context, options, NULL);
if (!g_option_context_parse (context, &argc, &argv, &error)) {
g_printerr ("Failed to parse arguments: %s\n", error->message);
return G_IO_ERROR_NOT_SUPPORTED;
}
/* uncommon actions */
if (kind == NULL) {
g_printerr ("No --kind specified\n");
return G_IO_ERROR_INVALID_DATA;
}
if (g_strcmp0 (kind, "unregister") == 0) {
if (!_helper_unregister (&error)) {
g_printerr ("Failed to Unregister: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
return EXIT_SUCCESS;
}
if (g_strcmp0 (kind, "auto-attach") == 0) {
if (!_helper_auto_attach (&error)) {
g_printerr ("Failed to AutoAttach: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
return EXIT_SUCCESS;
}
/* connect to abstract socket for reasons */
if (address == NULL) {
g_printerr ("No --address specified\n");
return G_IO_ERROR_INVALID_DATA;
@@ -281,96 +286,96 @@ main (int argc, char *argv[])
port = g_strdup ("443");
subman_conopts = g_variant_builder_new (G_VARIANT_TYPE("a{ss}"));
g_variant_builder_add (subman_conopts, "{ss}", "host", hostname);
g_variant_builder_add (subman_conopts, "{ss}", "handler", prefix);
g_variant_builder_add (subman_conopts, "{ss}", "port", port);
/* call into RHSM */
if (g_strcmp0 (kind, "register-with-key") == 0) {
g_auto(GStrv) activation_keys = NULL;
g_autoptr(GError) error_local = NULL;
g_autoptr(GVariant) res = NULL;
if (activation_key == NULL) {
g_printerr ("Required --activation-key\n");
return G_IO_ERROR_INVALID_DATA;
}
if (organisation == NULL) {
g_printerr ("Required --organisation\n");
return G_IO_ERROR_INVALID_DATA;
}
g_debug ("registering using activation key");
activation_keys = g_strsplit (activation_key, ",", -1);
res = g_dbus_proxy_call_sync (proxy,
"RegisterWithActivationKeys",
g_variant_new ("(s^asa{ss}a{ss}s)",
organisation,
activation_keys,
subman_options,
subman_conopts,
- userlang),
+ locale),
G_DBUS_CALL_FLAGS_NO_AUTO_START,
DBUS_TIMEOUT,
NULL, &error_local);
if (res == NULL) {
g_dbus_error_strip_remote_error (error_local);
_helper_convert_error (error_local->message, &error);
g_printerr ("Failed to RegisterWithActivationKeys: %s\n", error->message);
return error->code;
}
} else if (g_strcmp0 (kind, "register-with-username") == 0) {
g_autoptr(GError) error_local = NULL;
g_autoptr(GVariant) res = NULL;
g_debug ("registering using username and password");
if (username == NULL) {
g_printerr ("Required --username\n");
return G_IO_ERROR_INVALID_DATA;
}
if (password == NULL) {
g_printerr ("Required --password\n");
return G_IO_ERROR_INVALID_DATA;
}
if (organisation == NULL) {
g_printerr ("Required --organisation\n");
return G_IO_ERROR_INVALID_DATA;
}
res = g_dbus_proxy_call_sync (proxy,
"Register",
g_variant_new ("(sssa{ss}a{ss}s)",
organisation,
username,
password,
subman_options,
subman_conopts,
- userlang),
+ locale),
G_DBUS_CALL_FLAGS_NO_AUTO_START,
DBUS_TIMEOUT,
NULL, &error_local);
if (res == NULL) {
g_dbus_error_strip_remote_error (error_local);
_helper_convert_error (error_local->message, &error);
g_printerr ("Failed to Register: %s\n", error->message);
return error->code;
}
} else {
g_printerr ("Invalid --kind specified: %s\n", kind);
return G_IO_ERROR_INVALID_DATA;
}
/* set the new hostname */
if (!_helper_save_config ("server.hostname", hostname, &error)) {
g_printerr ("Failed to save hostname: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
if (!_helper_save_config ("server.prefix", prefix, &error)) {
g_printerr ("Failed to save prefix: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
if (!_helper_save_config ("server.port", port, &error)) {
g_printerr ("Failed to save port: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
/* wait for rhsmd to notice the new config */
g_usleep (G_USEC_PER_SEC * 5);
--
2.30.0

View File

@ -1,236 +0,0 @@
From f8ddd2c711cd502c74eb9d45360914fe2e6e1b3f Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Thu, 20 Aug 2020 13:34:19 -0400
Subject: [PATCH 06/15] subman: Handle subscription-manager giving invalid
status better
subscription-manager potentially returns status messages that the
subman plugin treats as enum values translated in some unknown
other language. It could be tied to system locale, or due to a
caching bug a previous locale used.
This commit tries to work around that bug, by instead relying on
the GetUUID() method and valid attribute. If there's no UUID we
know the system is unregistered. If there's a UUID but the valid
attribute is FALSE we know the system is registered, but hasn't
got proper entitlements.
---
plugins/subman/gsd-subscription-manager.c | 69 ++++++++++++-----------
1 file changed, 36 insertions(+), 33 deletions(-)
diff --git a/plugins/subman/gsd-subscription-manager.c b/plugins/subman/gsd-subscription-manager.c
index 46f051a5..e2c16056 100644
--- a/plugins/subman/gsd-subscription-manager.c
+++ b/plugins/subman/gsd-subscription-manager.c
@@ -104,77 +104,60 @@ typedef struct
gchar *starts;
gchar *ends;
} ProductData;
static void
product_data_free (ProductData *product)
{
g_free (product->product_name);
g_free (product->product_id);
g_free (product->version);
g_free (product->arch);
g_free (product->status);
g_free (product->starts);
g_free (product->ends);
g_free (product);
}
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProductData, product_data_free);
static gpointer manager_object = NULL;
GQuark
gsd_subscription_manager_error_quark (void)
{
static GQuark quark = 0;
if (!quark)
quark = g_quark_from_static_string ("gsd_subscription_manager_error");
return quark;
}
-static GsdSubmanSubscriptionStatus
-_client_subscription_status_from_text (const gchar *status_txt)
-{
- if (g_strcmp0 (status_txt, "Unknown") == 0)
- return GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN;
- if (g_strcmp0 (status_txt, "Current") == 0)
- return GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID;
- if (g_strcmp0 (status_txt, "Invalid") == 0)
- return GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID;
- if (g_strcmp0 (status_txt, "Disabled") == 0)
- return GSD_SUBMAN_SUBSCRIPTION_STATUS_DISABLED;
- if (g_strcmp0 (status_txt, "Insufficient") == 0)
- return GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID;
- g_warning ("Unknown subscription status: %s", status_txt); // 'Current'?
- return GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN;
-}
-
static GVariant *
_make_installed_products_variant (GPtrArray *installed_products)
{
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}"));
for (guint i = 0; i < installed_products->len; i++) {
ProductData *product = g_ptr_array_index (installed_products, i);
g_auto(GVariantDict) dict;
g_variant_dict_init (&dict, NULL);
g_variant_dict_insert (&dict, "product-name", "s", product->product_name);
g_variant_dict_insert (&dict, "product-id", "s", product->product_id);
g_variant_dict_insert (&dict, "version", "s", product->version);
g_variant_dict_insert (&dict, "arch", "s", product->arch);
g_variant_dict_insert (&dict, "status", "s", product->status);
g_variant_dict_insert (&dict, "starts", "s", product->starts);
g_variant_dict_insert (&dict, "ends", "s", product->ends);
g_variant_builder_add_value (&builder, g_variant_dict_end (&dict));
}
return g_variant_builder_end (&builder);
}
static void
_emit_property_changed (GsdSubscriptionManager *manager,
const gchar *property_name,
GVariant *property_value)
@@ -248,94 +231,114 @@ _client_installed_products_update (GsdSubscriptionManager *manager, GError **err
if (json_product == NULL)
continue;
if (json_array_get_length (json_product) < 8) {
g_debug ("Unexpected number of array elements in InstalledProducts JSON");
continue;
}
product->product_name = g_strdup (json_array_get_string_element (json_product, 0));
product->product_id = g_strdup (json_array_get_string_element (json_product, 1));
product->version = g_strdup (json_array_get_string_element (json_product, 2));
product->arch = g_strdup (json_array_get_string_element (json_product, 3));
product->status = g_strdup (json_array_get_string_element (json_product, 4));
product->starts = g_strdup (json_array_get_string_element (json_product, 6));
product->ends = g_strdup (json_array_get_string_element (json_product, 7));
g_ptr_array_add (priv->installed_products, g_steal_pointer (&product));
}
/* emit notification for g-c-c */
_emit_property_changed (manager, "InstalledProducts",
_make_installed_products_variant (priv->installed_products));
return TRUE;
}
static gboolean
_client_subscription_status_update (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
+ g_autoptr(GVariant) uuid = NULL;
+ const gchar *uuid_txt = NULL;
JsonNode *json_root;
JsonObject *json_obj;
const gchar *json_txt = NULL;
- const gchar *status_txt = NULL;
- g_autoptr(GVariant) val = NULL;
+ g_autoptr(GVariant) status = NULL;
g_autoptr(JsonParser) json_parser = json_parser_new ();
/* save old value */
priv->subscription_status_last = priv->subscription_status;
- val = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_ENTITLEMENT],
- "GetStatus",
- g_variant_new ("(ss)",
- "", /* assumed as 'now' */
- "C.UTF-8"),
- G_DBUS_CALL_FLAGS_NONE,
- -1, NULL, error);
- if (val == NULL)
+ uuid = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_CONSUMER],
+ "GetUuid",
+ g_variant_new ("(s)",
+ "C.UTF-8"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, error);
+ if (uuid == NULL)
return FALSE;
- g_variant_get (val, "(&s)", &json_txt);
+
+ g_variant_get (uuid, "(&s)", &uuid_txt);
+
+ status = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_ENTITLEMENT],
+ "GetStatus",
+ g_variant_new ("(ss)",
+ "", /* assumed as 'now' */
+ "C.UTF-8"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, error);
+ if (status == NULL)
+ return FALSE;
+ g_variant_get (status, "(&s)", &json_txt);
g_debug ("Entitlement.GetStatus JSON: %s", json_txt);
if (!json_parser_load_from_data (json_parser, json_txt, -1, error))
return FALSE;
json_root = json_parser_get_root (json_parser);
json_obj = json_node_get_object (json_root);
- if (!json_object_has_member (json_obj, "status")) {
+ if (!json_object_has_member (json_obj, "valid")) {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
- "no Entitlement.GetStatus status in %s", json_txt);
+ "no Entitlement.GetStatus valid in %s", json_txt);
return FALSE;
}
- status_txt = json_object_get_string_member (json_obj, "status");
- g_debug ("Entitlement.GetStatus: %s", status_txt);
- priv->subscription_status = _client_subscription_status_from_text (status_txt);
+ gboolean is_valid = json_object_get_boolean_member (json_obj, "valid");
+
+ if (uuid_txt[0] != '\0') {
+ if (is_valid) {
+ priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID;
+ } else {
+ priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID;
+ }
+ } else {
+ priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN;
+ }
/* emit notification for g-c-c */
if (priv->subscription_status != priv->subscription_status_last) {
_emit_property_changed (manager, "SubscriptionStatus",
g_variant_new_uint32 (priv->subscription_status));
}
return TRUE;
}
static gboolean
_client_syspurpose_update (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
JsonNode *json_root;
JsonObject *json_obj;
const gchar *json_txt = NULL;
g_autoptr(GVariant) val = NULL;
g_autoptr(JsonParser) json_parser = json_parser_new ();
val = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_SYSPURPOSE],
"GetSyspurpose",
g_variant_new ("(s)", "C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (val == NULL)
return FALSE;
g_variant_get (val, "(&s)", &json_txt);
g_debug ("Syspurpose.GetSyspurpose JSON: %s", json_txt);
if (!json_parser_load_from_data (json_parser, json_txt, -1, error))
--
2.30.0

View File

@ -1,260 +0,0 @@
From 477dc8accccab568002bd19caa3fbf898bc05aad Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Tue, 25 Aug 2020 10:34:03 -0400
Subject: [PATCH 07/15] subman: Force re-subscribe if the admin already
subscribed
It's possible for an admin to to half-enroll the system with RHN,
using the CLI tools.
Meaning, it's possible for them to register the system with the
service, but not attach to a purchased license for the machine,
the, so called, entitlements.
The subman module always does both halves of the registration process
in lock step. This means, if an admin tries to register using GNOME
while in a half-registered state, subman will fail because the first
step, the registration step, is already finished.
This commit addresses that problem by trying to unregister up front
before registering.
---
plugins/subman/gsd-subman-helper.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/plugins/subman/gsd-subman-helper.c b/plugins/subman/gsd-subman-helper.c
index f84e91bf..3931ef2e 100644
--- a/plugins/subman/gsd-subman-helper.c
+++ b/plugins/subman/gsd-subman-helper.c
@@ -51,61 +51,60 @@ _helper_convert_error (const gchar *json_txt, GError **error)
json_root = json_parser_get_root (json_parser);
json_obj = json_node_get_object (json_root);
if (!json_object_has_member (json_obj, "message")) {
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"no message' in %s", json_txt);
return;
}
message = json_object_get_string_member (json_obj, "message");
if (g_strstr_len (message, -1, "Invalid user credentials") != NULL) {
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_PERMISSION_DENIED,
message);
return;
}
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
message);
}
static gboolean
_helper_unregister (GError **error)
{
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GVariantBuilder) proxy_options = NULL;
g_autoptr(GVariant) res = NULL;
- g_debug ("unregistering");
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
"com.redhat.RHSM1",
"/com/redhat/RHSM1/Unregister",
"com.redhat.RHSM1.Unregister",
NULL, error);
if (proxy == NULL) {
g_prefix_error (error, "Failed to get proxy: ");
return FALSE;
}
proxy_options = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);
res = g_dbus_proxy_call_sync (proxy,
"Unregister",
g_variant_new ("(a{sv}s)",
proxy_options,
locale),
G_DBUS_CALL_FLAGS_NONE,
DBUS_TIMEOUT,
NULL, error);
return res != NULL;
}
static gboolean
_helper_auto_attach (GError **error)
{
const gchar *str = NULL;
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GVariantBuilder) proxy_options = NULL;
@@ -208,60 +207,61 @@ main (int argc, char *argv[])
{ "prefix", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING,
&prefix, "Registration server prefix", NULL },
{ "port", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING,
&port, "Registration server port", NULL },
{ "proxy", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING,
&proxy_server, "Proxy settings", NULL },
{ NULL}
};
/* check calling UID */
if (getuid () != 0 || geteuid () != 0) {
g_printerr ("This program can only be used by the root user\n");
return G_IO_ERROR_NOT_SUPPORTED;
}
setlocale (LC_ALL, "");
locale = setlocale (LC_MESSAGES, NULL);
g_option_context_add_main_entries (context, options, NULL);
if (!g_option_context_parse (context, &argc, &argv, &error)) {
g_printerr ("Failed to parse arguments: %s\n", error->message);
return G_IO_ERROR_NOT_SUPPORTED;
}
/* uncommon actions */
if (kind == NULL) {
g_printerr ("No --kind specified\n");
return G_IO_ERROR_INVALID_DATA;
}
if (g_strcmp0 (kind, "unregister") == 0) {
+ g_debug ("unregistering");
if (!_helper_unregister (&error)) {
g_printerr ("Failed to Unregister: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
return EXIT_SUCCESS;
}
if (g_strcmp0 (kind, "auto-attach") == 0) {
if (!_helper_auto_attach (&error)) {
g_printerr ("Failed to AutoAttach: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
return EXIT_SUCCESS;
}
/* connect to abstract socket for reasons */
if (address == NULL) {
g_printerr ("No --address specified\n");
return G_IO_ERROR_INVALID_DATA;
}
conn_private = g_dbus_connection_new_for_address_sync (address,
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
NULL, NULL,
&error);
if (conn_private == NULL) {
g_printerr ("Invalid --address specified: %s\n", error->message);
return G_IO_ERROR_INVALID_DATA;
}
proxy = g_dbus_proxy_new_sync (conn_private,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
NULL, /* GDBusInterfaceInfo */
@@ -277,96 +277,103 @@ main (int argc, char *argv[])
/* no options */
subman_options = g_variant_builder_new (G_VARIANT_TYPE("a{ss}"));
/* set registration server */
if (hostname == NULL || hostname[0] == '\0')
hostname = g_strdup ("subscription.rhsm.redhat.com");
if (prefix == NULL || prefix[0] == '\0')
prefix = g_strdup ("/subscription");
if (port == NULL || port[0] == '\0')
port = g_strdup ("443");
subman_conopts = g_variant_builder_new (G_VARIANT_TYPE("a{ss}"));
g_variant_builder_add (subman_conopts, "{ss}", "host", hostname);
g_variant_builder_add (subman_conopts, "{ss}", "handler", prefix);
g_variant_builder_add (subman_conopts, "{ss}", "port", port);
/* call into RHSM */
if (g_strcmp0 (kind, "register-with-key") == 0) {
g_auto(GStrv) activation_keys = NULL;
g_autoptr(GError) error_local = NULL;
g_autoptr(GVariant) res = NULL;
if (activation_key == NULL) {
g_printerr ("Required --activation-key\n");
return G_IO_ERROR_INVALID_DATA;
}
if (organisation == NULL) {
g_printerr ("Required --organisation\n");
return G_IO_ERROR_INVALID_DATA;
}
+ g_debug ("trying to unregister in case machine is already registered");
+ _helper_unregister (NULL);
+
g_debug ("registering using activation key");
activation_keys = g_strsplit (activation_key, ",", -1);
res = g_dbus_proxy_call_sync (proxy,
"RegisterWithActivationKeys",
g_variant_new ("(s^asa{ss}a{ss}s)",
organisation,
activation_keys,
subman_options,
subman_conopts,
locale),
G_DBUS_CALL_FLAGS_NO_AUTO_START,
DBUS_TIMEOUT,
NULL, &error_local);
if (res == NULL) {
g_dbus_error_strip_remote_error (error_local);
_helper_convert_error (error_local->message, &error);
g_printerr ("Failed to RegisterWithActivationKeys: %s\n", error->message);
return error->code;
}
} else if (g_strcmp0 (kind, "register-with-username") == 0) {
g_autoptr(GError) error_local = NULL;
g_autoptr(GVariant) res = NULL;
- g_debug ("registering using username and password");
if (username == NULL) {
g_printerr ("Required --username\n");
return G_IO_ERROR_INVALID_DATA;
}
if (password == NULL) {
g_printerr ("Required --password\n");
return G_IO_ERROR_INVALID_DATA;
}
if (organisation == NULL) {
g_printerr ("Required --organisation\n");
return G_IO_ERROR_INVALID_DATA;
}
+
+ g_debug ("trying to unregister in case machine is already registered");
+ _helper_unregister (NULL);
+
+ g_debug ("registering using username and password");
res = g_dbus_proxy_call_sync (proxy,
"Register",
g_variant_new ("(sssa{ss}a{ss}s)",
organisation,
username,
password,
subman_options,
subman_conopts,
locale),
G_DBUS_CALL_FLAGS_NO_AUTO_START,
DBUS_TIMEOUT,
NULL, &error_local);
if (res == NULL) {
g_dbus_error_strip_remote_error (error_local);
_helper_convert_error (error_local->message, &error);
g_printerr ("Failed to Register: %s\n", error->message);
return error->code;
}
} else {
g_printerr ("Invalid --kind specified: %s\n", kind);
return G_IO_ERROR_INVALID_DATA;
}
/* set the new hostname */
if (!_helper_save_config ("server.hostname", hostname, &error)) {
g_printerr ("Failed to save hostname: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
if (!_helper_save_config ("server.prefix", prefix, &error)) {
g_printerr ("Failed to save prefix: %s\n", error->message);
--
2.30.0

View File

@ -1,576 +0,0 @@
From b73800da7f384eea66b6eb67f5f40129f3dfc372 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Tue, 25 Aug 2020 16:20:42 -0400
Subject: [PATCH 08/15] subman: Don't send secrets through command line
The command line is introspectable with "ps", and it even gets logged
to syslog, so it's not suitable for passing secrets.
Unfortunately, the user's password is currently passed.
This commit addresses that problem by passing the password through
stdin, instead.
---
plugins/subman/gsd-subman-helper.c | 32 ++++++++------
plugins/subman/gsd-subscription-manager.c | 52 ++++++++++++++++++++---
plugins/subman/meson.build | 2 +-
3 files changed, 66 insertions(+), 20 deletions(-)
diff --git a/plugins/subman/gsd-subman-helper.c b/plugins/subman/gsd-subman-helper.c
index 3931ef2e..edf1e41f 100644
--- a/plugins/subman/gsd-subman-helper.c
+++ b/plugins/subman/gsd-subman-helper.c
@@ -1,59 +1,61 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2019 Richard Hughes <rhughes@redhat.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
+
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <locale.h>
#include <gio/gio.h>
+#include <gio/gunixinputstream.h>
#include <json-glib/json-glib.h>
#define DBUS_TIMEOUT 300000 /* 5 minutes */
static const char *locale;
static void
_helper_convert_error (const gchar *json_txt, GError **error)
{
JsonNode *json_root;
JsonObject *json_obj;
const gchar *message;
g_autoptr(JsonParser) json_parser = json_parser_new ();
/* this may be plain text or JSON :| */
if (!json_parser_load_from_data (json_parser, json_txt, -1, NULL)) {
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
json_txt);
return;
}
json_root = json_parser_get_root (json_parser);
json_obj = json_node_get_object (json_root);
if (!json_object_has_member (json_obj, "message")) {
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"no message' in %s", json_txt);
return;
}
@@ -149,86 +151,82 @@ _helper_save_config (const gchar *key, const gchar *value, GError **error)
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
"com.redhat.RHSM1",
"/com/redhat/RHSM1/Config",
"com.redhat.RHSM1.Config",
NULL, error);
if (proxy == NULL) {
g_prefix_error (error, "Failed to get proxy: ");
return FALSE;
}
res = g_dbus_proxy_call_sync (proxy, "Set",
g_variant_new ("(svs)",
key,
g_variant_new_string (value),
locale),
G_DBUS_CALL_FLAGS_NONE,
DBUS_TIMEOUT,
NULL, error);
return res != NULL;
}
int
main (int argc, char *argv[])
{
g_autofree gchar *activation_key = NULL;
g_autofree gchar *address = NULL;
g_autofree gchar *hostname = NULL;
g_autofree gchar *kind = NULL;
g_autofree gchar *organisation = NULL;
- g_autofree gchar *password = NULL;
g_autofree gchar *port = NULL;
g_autofree gchar *prefix = NULL;
g_autofree gchar *proxy_server = NULL;
g_autofree gchar *username = NULL;
g_autoptr(GDBusConnection) conn_private = NULL;
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GOptionContext) context = g_option_context_new (NULL);
g_autoptr(GVariantBuilder) proxy_options = NULL;
g_autoptr(GVariantBuilder) subman_conopts = NULL;
g_autoptr(GVariantBuilder) subman_options = NULL;
+ g_autoptr(GInputStream) standard_input_stream = g_unix_input_stream_new (STDIN_FILENO, FALSE);
const GOptionEntry options[] = {
{ "kind", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
&kind, "Kind, e.g. 'username' or 'key'", NULL },
{ "address", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
&address, "UNIX address", NULL },
{ "username", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
&username, "Username", NULL },
- { "password", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
- &password, "Password", NULL },
{ "organisation", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
&organisation, "Organisation", NULL },
- { "activation-key", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
- &activation_key, "Activation keys", NULL },
{ "hostname", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING,
&hostname, "Registration server hostname", NULL },
{ "prefix", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING,
&prefix, "Registration server prefix", NULL },
{ "port", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING,
&port, "Registration server port", NULL },
{ "proxy", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING,
&proxy_server, "Proxy settings", NULL },
{ NULL}
};
/* check calling UID */
if (getuid () != 0 || geteuid () != 0) {
g_printerr ("This program can only be used by the root user\n");
return G_IO_ERROR_NOT_SUPPORTED;
}
setlocale (LC_ALL, "");
locale = setlocale (LC_MESSAGES, NULL);
g_option_context_add_main_entries (context, options, NULL);
if (!g_option_context_parse (context, &argc, &argv, &error)) {
g_printerr ("Failed to parse arguments: %s\n", error->message);
return G_IO_ERROR_NOT_SUPPORTED;
}
/* uncommon actions */
if (kind == NULL) {
g_printerr ("No --kind specified\n");
return G_IO_ERROR_INVALID_DATA;
@@ -267,109 +265,117 @@ main (int argc, char *argv[])
NULL, /* GDBusInterfaceInfo */
NULL, /* name */
"/com/redhat/RHSM1/Register",
"com.redhat.RHSM1.Register",
NULL, &error);
if (proxy == NULL) {
g_printerr ("Count not contact RHSM: %s\n", error->message);
return G_IO_ERROR_NOT_FOUND;
}
/* no options */
subman_options = g_variant_builder_new (G_VARIANT_TYPE("a{ss}"));
/* set registration server */
if (hostname == NULL || hostname[0] == '\0')
hostname = g_strdup ("subscription.rhsm.redhat.com");
if (prefix == NULL || prefix[0] == '\0')
prefix = g_strdup ("/subscription");
if (port == NULL || port[0] == '\0')
port = g_strdup ("443");
subman_conopts = g_variant_builder_new (G_VARIANT_TYPE("a{ss}"));
g_variant_builder_add (subman_conopts, "{ss}", "host", hostname);
g_variant_builder_add (subman_conopts, "{ss}", "handler", prefix);
g_variant_builder_add (subman_conopts, "{ss}", "port", port);
/* call into RHSM */
if (g_strcmp0 (kind, "register-with-key") == 0) {
g_auto(GStrv) activation_keys = NULL;
g_autoptr(GError) error_local = NULL;
g_autoptr(GVariant) res = NULL;
+ gchar activation_key[PIPE_BUF + 1] = "";
- if (activation_key == NULL) {
- g_printerr ("Required --activation-key\n");
- return G_IO_ERROR_INVALID_DATA;
- }
if (organisation == NULL) {
g_printerr ("Required --organisation\n");
return G_IO_ERROR_INVALID_DATA;
}
+ g_input_stream_read (standard_input_stream, activation_key, sizeof (activation_key) - 1, NULL, &error_local);
+
+ if (error_local != NULL) {
+ g_printerr ("Could not read activation key: %s\n", error_local->message);
+ return G_IO_ERROR_INVALID_DATA;
+ }
+
g_debug ("trying to unregister in case machine is already registered");
_helper_unregister (NULL);
g_debug ("registering using activation key");
activation_keys = g_strsplit (activation_key, ",", -1);
res = g_dbus_proxy_call_sync (proxy,
"RegisterWithActivationKeys",
g_variant_new ("(s^asa{ss}a{ss}s)",
organisation,
activation_keys,
subman_options,
subman_conopts,
locale),
G_DBUS_CALL_FLAGS_NO_AUTO_START,
DBUS_TIMEOUT,
NULL, &error_local);
if (res == NULL) {
g_dbus_error_strip_remote_error (error_local);
_helper_convert_error (error_local->message, &error);
g_printerr ("Failed to RegisterWithActivationKeys: %s\n", error->message);
return error->code;
}
} else if (g_strcmp0 (kind, "register-with-username") == 0) {
g_autoptr(GError) error_local = NULL;
g_autoptr(GVariant) res = NULL;
+ gchar password[PIPE_BUF + 1] = "";
if (username == NULL) {
g_printerr ("Required --username\n");
return G_IO_ERROR_INVALID_DATA;
}
- if (password == NULL) {
- g_printerr ("Required --password\n");
- return G_IO_ERROR_INVALID_DATA;
- }
if (organisation == NULL) {
g_printerr ("Required --organisation\n");
return G_IO_ERROR_INVALID_DATA;
}
+ g_input_stream_read (standard_input_stream, password, sizeof (password) - 1, NULL, &error_local);
+
+ if (error_local != NULL) {
+ g_printerr ("Could not read password: %s\n", error_local->message);
+ return G_IO_ERROR_INVALID_DATA;
+ }
+
g_debug ("trying to unregister in case machine is already registered");
_helper_unregister (NULL);
g_debug ("registering using username and password");
res = g_dbus_proxy_call_sync (proxy,
"Register",
g_variant_new ("(sssa{ss}a{ss}s)",
organisation,
username,
password,
subman_options,
subman_conopts,
locale),
G_DBUS_CALL_FLAGS_NO_AUTO_START,
DBUS_TIMEOUT,
NULL, &error_local);
if (res == NULL) {
g_dbus_error_strip_remote_error (error_local);
_helper_convert_error (error_local->message, &error);
g_printerr ("Failed to Register: %s\n", error->message);
return error->code;
}
} else {
g_printerr ("Invalid --kind specified: %s\n", kind);
return G_IO_ERROR_INVALID_DATA;
}
/* set the new hostname */
if (!_helper_save_config ("server.hostname", hostname, &error)) {
g_printerr ("Failed to save hostname: %s\n", error->message);
diff --git a/plugins/subman/gsd-subscription-manager.c b/plugins/subman/gsd-subscription-manager.c
index e2c16056..0838d490 100644
--- a/plugins/subman/gsd-subscription-manager.c
+++ b/plugins/subman/gsd-subscription-manager.c
@@ -1,53 +1,54 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2019 Richard Hughes <richard@hughsie.com>
* Copyright (C) 2019 Kalev Lember <klember@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <glib/gi18n.h>
+#include <gio/gunixinputstream.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <json-glib/json-glib.h>
#include <libnotify/notify.h>
#include "gnome-settings-profile.h"
#include "gsd-subman-common.h"
#include "gsd-subscription-manager.h"
#define GSD_DBUS_NAME "org.gnome.SettingsDaemon"
#define GSD_DBUS_PATH "/org/gnome/SettingsDaemon"
#define GSD_DBUS_BASE_INTERFACE "org.gnome.SettingsDaemon"
#define GSD_SUBSCRIPTION_DBUS_NAME GSD_DBUS_NAME ".Subscription"
#define GSD_SUBSCRIPTION_DBUS_PATH GSD_DBUS_PATH "/Subscription"
#define GSD_SUBSCRIPTION_DBUS_INTERFACE GSD_DBUS_BASE_INTERFACE ".Subscription"
static const gchar introspection_xml[] =
"<node>"
" <interface name='org.gnome.SettingsDaemon.Subscription'>"
" <method name='Register'>"
" <arg type='a{sv}' name='options' direction='in'/>"
" </method>"
" <method name='Unregister'/>"
" <property name='InstalledProducts' type='aa{sv}' access='read'/>"
" <property name='SubscriptionStatus' type='u' access='read'/>"
" </interface>"
"</node>";
#define GSD_SUBSCRIPTION_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_SUBSCRIPTION_MANAGER, GsdSubscriptionManagerPrivate))
@@ -517,129 +518,168 @@ _client_maybe__show_notification (GsdSubscriptionManager *manager)
}
}
/* nag again */
if (priv->subscription_status == GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN &&
g_timer_elapsed (priv->timer_last_notified, NULL) > 60 * 60 * 24) {
_show_notification (manager, _NOTIFY_REGISTRATION_REQUIRED);
return;
}
if (priv->subscription_status == GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID &&
g_timer_elapsed (priv->timer_last_notified, NULL) > 60 * 60 * 24) {
_show_notification (manager, _NOTIFY_EXPIRED);
return;
}
if (priv->subscription_status == GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID &&
g_timer_elapsed (priv->timer_last_notified, NULL) > 60 * 60 * 24) {
_show_notification (manager, _NOTIFY_EXPIRED);
return;
}
}
static gboolean
_client_register_with_keys (GsdSubscriptionManager *manager,
const gchar *hostname,
const gchar *organisation,
const gchar *activation_key,
GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
g_autoptr(GSubprocess) subprocess = NULL;
+ g_autoptr(GBytes) stdin_buf = g_bytes_new (activation_key, strlen (activation_key) + 1);
+ g_autoptr(GBytes) stderr_buf = NULL;
+ gint rc;
/* apparently: "we can't send registration credentials over the regular
* system or session bus since those aren't really locked down..." */
if (!_client_register_start (manager, error))
return FALSE;
g_debug ("spawning %s", LIBEXECDIR "/gsd-subman-helper");
- subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDERR_PIPE, error,
+ subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_PIPE | G_SUBPROCESS_FLAGS_STDERR_PIPE, error,
"pkexec", LIBEXECDIR "/gsd-subman-helper",
"--kind", "register-with-key",
"--address", priv->address,
"--hostname", hostname,
"--organisation", organisation,
- "--activation-key", activation_key,
NULL);
if (subprocess == NULL) {
g_prefix_error (error, "failed to find pkexec: ");
return FALSE;
}
- if (!_client_subprocess_wait_check (subprocess, error))
+
+ if (!g_subprocess_communicate (subprocess, stdin_buf, 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",
+ g_bytes_get_size (stderr_buf),
+ g_bytes_get_data (stderr_buf, NULL));
+ }
/* FIXME: also do on error? */
if (!_client_register_stop (manager, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
if (!_client_installed_products_update (manager, error))
return FALSE;
_client_maybe__show_notification (manager);
/* success */
return TRUE;
}
static gboolean
_client_register (GsdSubscriptionManager *manager,
const gchar *hostname,
const gchar *organisation,
const gchar *username,
const gchar *password,
GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
g_autoptr(GSubprocess) subprocess = NULL;
+ g_autoptr(GBytes) stdin_buf = g_bytes_new (password, strlen (password) + 1);
+ g_autoptr(GBytes) stderr_buf = NULL;
+ gint rc;
/* fallback */
if (organisation == NULL)
organisation = "";
/* apparently: "we can't send registration credentials over the regular
* system or session bus since those aren't really locked down..." */
if (!_client_register_start (manager, error))
return FALSE;
g_debug ("spawning %s", LIBEXECDIR "/gsd-subman-helper");
- subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDERR_PIPE, error,
+ subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_PIPE | G_SUBPROCESS_FLAGS_STDERR_PIPE,
+ error,
"pkexec", LIBEXECDIR "/gsd-subman-helper",
"--kind", "register-with-username",
"--address", priv->address,
"--hostname", hostname,
"--organisation", organisation,
"--username", username,
- "--password", password,
NULL);
if (subprocess == NULL) {
g_prefix_error (error, "failed to find pkexec: ");
return FALSE;
}
- if (!_client_subprocess_wait_check (subprocess, error))
+
+ if (!g_subprocess_communicate (subprocess, stdin_buf, 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",
+ g_bytes_get_size (stderr_buf),
+ g_bytes_get_data (stderr_buf, NULL));
+ }
/* FIXME: also do on error? */
if (!_client_register_stop (manager, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
if (!_client_installed_products_update (manager, error))
return FALSE;
_client_maybe__show_notification (manager);
return TRUE;
}
static gboolean
_client_unregister (GsdSubscriptionManager *manager, GError **error)
{
g_autoptr(GSubprocess) subprocess = NULL;
/* apparently: "we can't send registration credentials over the regular
* system or session bus since those aren't really locked down..." */
if (!_client_register_start (manager, error))
return FALSE;
g_debug ("spawning %s", LIBEXECDIR "/gsd-subman-helper");
subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDERR_PIPE, error,
"pkexec", LIBEXECDIR "/gsd-subman-helper",
"--kind", "unregister",
NULL);
if (subprocess == NULL) {
g_prefix_error (error, "failed to find pkexec: ");
return FALSE;
}
diff --git a/plugins/subman/meson.build b/plugins/subman/meson.build
index bfd073b6..e4b4589d 100644
--- a/plugins/subman/meson.build
+++ b/plugins/subman/meson.build
@@ -22,35 +22,35 @@ executable(
c_args: cflags,
install: true,
install_rpath: gsd_pkglibdir,
install_dir: gsd_libexecdir
)
# .Register needs to be called from root as subman can't do PolicyKit...
policy = 'org.gnome.settings-daemon.plugins.subman.policy'
policy_in = configure_file(
input: policy + '.in.in',
output: policy + '.in',
configuration: plugins_conf
)
i18n.merge_file(
policy,
input: policy_in,
output: policy,
po_dir: po_dir,
install: true,
install_dir: join_paths(gsd_datadir, 'polkit-1', 'actions')
)
install_data('org.gnome.settings-daemon.plugins.subman.rules',
install_dir : join_paths(gsd_datadir, 'polkit-1', 'rules.d'))
executable(
'gsd-subman-helper',
'gsd-subman-helper.c',
include_directories: top_inc,
- dependencies: [gio_dep, jsonglib_dep],
+ dependencies: [gio_dep, gio_unix_dep, jsonglib_dep],
install: true,
install_rpath: gsd_pkglibdir,
install_dir: gsd_libexecdir
)
--
2.30.0

View File

@ -1,310 +0,0 @@
From 1255b2b83284d262f6b8c3ceb23d499ddbf77d48 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Thu, 21 Jan 2021 09:52:19 -0500
Subject: [PATCH 09/15] subman: Don't treat failure to attach as fatal
Many organizations don't require specific subscriptions to get
updates (called "simple content access"). At the moment,
those systems get an error when registering.
This commit quiets the error.
---
plugins/subman/gsd-subman-helper.c | 46 ++++++++++++++++++++++++------
1 file changed, 37 insertions(+), 9 deletions(-)
diff --git a/plugins/subman/gsd-subman-helper.c b/plugins/subman/gsd-subman-helper.c
index edf1e41f..53a4d56b 100644
--- a/plugins/subman/gsd-subman-helper.c
+++ b/plugins/subman/gsd-subman-helper.c
@@ -25,145 +25,169 @@
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <locale.h>
#include <gio/gio.h>
#include <gio/gunixinputstream.h>
#include <json-glib/json-glib.h>
#define DBUS_TIMEOUT 300000 /* 5 minutes */
static const char *locale;
static void
_helper_convert_error (const gchar *json_txt, GError **error)
{
JsonNode *json_root;
JsonObject *json_obj;
const gchar *message;
g_autoptr(JsonParser) json_parser = json_parser_new ();
/* this may be plain text or JSON :| */
if (!json_parser_load_from_data (json_parser, json_txt, -1, NULL)) {
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
json_txt);
return;
}
json_root = json_parser_get_root (json_parser);
json_obj = json_node_get_object (json_root);
+ if (json_object_has_member (json_obj, "severity")) {
+ const gchar *severity;
+
+ /* warnings are non-fatal so we ignore them
+ */
+ severity = json_object_get_string_member (json_obj, "severity");
+ if (g_strstr_len (severity, -1, "warning") != NULL) {
+ return;
+ }
+ }
+
if (!json_object_has_member (json_obj, "message")) {
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"no message' in %s", json_txt);
return;
}
message = json_object_get_string_member (json_obj, "message");
if (g_strstr_len (message, -1, "Invalid user credentials") != NULL) {
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_PERMISSION_DENIED,
message);
return;
}
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
message);
}
static gboolean
_helper_unregister (GError **error)
{
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GVariantBuilder) proxy_options = NULL;
g_autoptr(GVariant) res = NULL;
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
"com.redhat.RHSM1",
"/com/redhat/RHSM1/Unregister",
"com.redhat.RHSM1.Unregister",
NULL, error);
if (proxy == NULL) {
g_prefix_error (error, "Failed to get proxy: ");
return FALSE;
}
proxy_options = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);
res = g_dbus_proxy_call_sync (proxy,
"Unregister",
g_variant_new ("(a{sv}s)",
proxy_options,
locale),
G_DBUS_CALL_FLAGS_NONE,
DBUS_TIMEOUT,
NULL, error);
return res != NULL;
}
static gboolean
_helper_auto_attach (GError **error)
{
const gchar *str = NULL;
+ g_autoptr(GError) error_local = NULL;
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GVariantBuilder) proxy_options = NULL;
g_autoptr(GVariant) res = NULL;
g_debug ("auto-attaching subscriptions");
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
"com.redhat.RHSM1",
"/com/redhat/RHSM1/Attach",
"com.redhat.RHSM1.Attach",
- NULL, error);
+ NULL, &error_local);
if (proxy == NULL) {
- g_prefix_error (error, "Failed to get proxy: ");
+ g_dbus_error_strip_remote_error (error_local);
+ g_propagate_prefixed_error (error,
+ g_steal_pointer (&error_local),
+ "Failed to get proxy: ");
return FALSE;
}
proxy_options = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);
res = g_dbus_proxy_call_sync (proxy,
"AutoAttach",
g_variant_new ("(sa{sv}s)",
"", /* now? */
proxy_options,
locale),
G_DBUS_CALL_FLAGS_NONE,
DBUS_TIMEOUT,
- NULL, error);
- if (res == NULL)
- return FALSE;
+ NULL, &error_local);
+ if (res == NULL) {
+ g_dbus_error_strip_remote_error (error_local);
+ _helper_convert_error (error_local->message, error);
+
+ if (*error != NULL) {
+ g_prefix_error (error, "Failed to get proxy: ");
+ return FALSE;
+ }
+
+ return TRUE;
+ }
g_variant_get (res, "(&s)", &str);
g_debug ("Attach.AutoAttach: %s", str);
return TRUE;
}
static gboolean
_helper_save_config (const gchar *key, const gchar *value, GError **error)
{
g_autoptr(GDBusProxy) proxy = NULL;
g_autoptr(GVariant) res = NULL;
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
"com.redhat.RHSM1",
"/com/redhat/RHSM1/Config",
"com.redhat.RHSM1.Config",
NULL, error);
if (proxy == NULL) {
g_prefix_error (error, "Failed to get proxy: ");
return FALSE;
}
res = g_dbus_proxy_call_sync (proxy, "Set",
g_variant_new ("(svs)",
key,
g_variant_new_string (value),
locale),
G_DBUS_CALL_FLAGS_NONE,
DBUS_TIMEOUT,
NULL, error);
@@ -298,105 +322,109 @@ main (int argc, char *argv[])
g_printerr ("Required --organisation\n");
return G_IO_ERROR_INVALID_DATA;
}
g_input_stream_read (standard_input_stream, activation_key, sizeof (activation_key) - 1, NULL, &error_local);
if (error_local != NULL) {
g_printerr ("Could not read activation key: %s\n", error_local->message);
return G_IO_ERROR_INVALID_DATA;
}
g_debug ("trying to unregister in case machine is already registered");
_helper_unregister (NULL);
g_debug ("registering using activation key");
activation_keys = g_strsplit (activation_key, ",", -1);
res = g_dbus_proxy_call_sync (proxy,
"RegisterWithActivationKeys",
g_variant_new ("(s^asa{ss}a{ss}s)",
organisation,
activation_keys,
subman_options,
subman_conopts,
locale),
G_DBUS_CALL_FLAGS_NO_AUTO_START,
DBUS_TIMEOUT,
NULL, &error_local);
if (res == NULL) {
g_dbus_error_strip_remote_error (error_local);
_helper_convert_error (error_local->message, &error);
- g_printerr ("Failed to RegisterWithActivationKeys: %s\n", error->message);
- return error->code;
+ if (error != NULL) {
+ g_printerr ("Failed to RegisterWithActivationKeys: %s\n", error->message);
+ return error->code;
+ }
}
} else if (g_strcmp0 (kind, "register-with-username") == 0) {
g_autoptr(GError) error_local = NULL;
g_autoptr(GVariant) res = NULL;
gchar password[PIPE_BUF + 1] = "";
if (username == NULL) {
g_printerr ("Required --username\n");
return G_IO_ERROR_INVALID_DATA;
}
if (organisation == NULL) {
g_printerr ("Required --organisation\n");
return G_IO_ERROR_INVALID_DATA;
}
g_input_stream_read (standard_input_stream, password, sizeof (password) - 1, NULL, &error_local);
if (error_local != NULL) {
g_printerr ("Could not read password: %s\n", error_local->message);
return G_IO_ERROR_INVALID_DATA;
}
g_debug ("trying to unregister in case machine is already registered");
_helper_unregister (NULL);
g_debug ("registering using username and password");
res = g_dbus_proxy_call_sync (proxy,
"Register",
g_variant_new ("(sssa{ss}a{ss}s)",
organisation,
username,
password,
subman_options,
subman_conopts,
locale),
G_DBUS_CALL_FLAGS_NO_AUTO_START,
DBUS_TIMEOUT,
NULL, &error_local);
if (res == NULL) {
g_dbus_error_strip_remote_error (error_local);
_helper_convert_error (error_local->message, &error);
- g_printerr ("Failed to Register: %s\n", error->message);
- return error->code;
+ if (error != NULL) {
+ g_printerr ("Failed to Register: %s\n", error->message);
+ return error->code;
+ }
}
} else {
g_printerr ("Invalid --kind specified: %s\n", kind);
return G_IO_ERROR_INVALID_DATA;
}
/* set the new hostname */
if (!_helper_save_config ("server.hostname", hostname, &error)) {
g_printerr ("Failed to save hostname: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
if (!_helper_save_config ("server.prefix", prefix, &error)) {
g_printerr ("Failed to save prefix: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
if (!_helper_save_config ("server.port", port, &error)) {
g_printerr ("Failed to save port: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
/* wait for rhsmd to notice the new config */
g_usleep (G_USEC_PER_SEC * 5);
/* auto-attach */
if (!_helper_auto_attach (&error)) {
g_printerr ("Failed to AutoAttach: %s\n", error->message);
return G_IO_ERROR_NOT_INITIALIZED;
}
return EXIT_SUCCESS;
--
2.30.0

View File

@ -1,427 +0,0 @@
From d53c27802c69773d63d108f57912035fd3caabf9 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sun, 24 Jan 2021 11:24:36 -0500
Subject: [PATCH 10/15] subman: Add new no-installed-products state
It's possible, though unlikley, the system has
no packages installed from Red Hat supported package sets.
This commit adds a new state to track that situation.
---
plugins/subman/gsd-subman-common.c | 2 ++
plugins/subman/gsd-subman-common.h | 1 +
plugins/subman/gsd-subscription-manager.c | 17 +++++++----------
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/plugins/subman/gsd-subman-common.c b/plugins/subman/gsd-subman-common.c
index e515131e..eef5175d 100644
--- a/plugins/subman/gsd-subman-common.c
+++ b/plugins/subman/gsd-subman-common.c
@@ -5,32 +5,34 @@
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "gsd-subman-common.h"
const gchar *
gsd_subman_subscription_status_to_string (GsdSubmanSubscriptionStatus status)
{
if (status == GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID)
return "valid";
if (status == GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID)
return "invalid";
if (status == GSD_SUBMAN_SUBSCRIPTION_STATUS_DISABLED)
return "disabled";
if (status == GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID)
return "partially-valid";
+ if (status == GSD_SUBMAN_SUBSCRIPTION_STATUS_NO_INSTALLED_PRODUCTS)
+ return "no-installed-products";
return "unknown";
}
diff --git a/plugins/subman/gsd-subman-common.h b/plugins/subman/gsd-subman-common.h
index fccf9f6a..f8a3d9f4 100644
--- a/plugins/subman/gsd-subman-common.h
+++ b/plugins/subman/gsd-subman-common.h
@@ -3,38 +3,39 @@
* Copyright (C) 2019 Richard Hughes <rhughes@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __GSD_SUBMAN_COMMON_H
#define __GSD_SUBMAN_COMMON_H
#include <glib-object.h>
G_BEGIN_DECLS
typedef enum {
GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN,
GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID,
GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID,
GSD_SUBMAN_SUBSCRIPTION_STATUS_DISABLED,
GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID,
+ GSD_SUBMAN_SUBSCRIPTION_STATUS_NO_INSTALLED_PRODUCTS,
GSD_SUBMAN_SUBSCRIPTION_STATUS_LAST
} GsdSubmanSubscriptionStatus;
const gchar *gsd_subman_subscription_status_to_string (GsdSubmanSubscriptionStatus status);
G_END_DECLS
#endif /* __GSD_SUBMAN_COMMON_H */
diff --git a/plugins/subman/gsd-subscription-manager.c b/plugins/subman/gsd-subscription-manager.c
index 0838d490..46f8d35c 100644
--- a/plugins/subman/gsd-subscription-manager.c
+++ b/plugins/subman/gsd-subscription-manager.c
@@ -242,60 +242,67 @@ _client_installed_products_update (GsdSubscriptionManager *manager, GError **err
product->version = g_strdup (json_array_get_string_element (json_product, 2));
product->arch = g_strdup (json_array_get_string_element (json_product, 3));
product->status = g_strdup (json_array_get_string_element (json_product, 4));
product->starts = g_strdup (json_array_get_string_element (json_product, 6));
product->ends = g_strdup (json_array_get_string_element (json_product, 7));
g_ptr_array_add (priv->installed_products, g_steal_pointer (&product));
}
/* emit notification for g-c-c */
_emit_property_changed (manager, "InstalledProducts",
_make_installed_products_variant (priv->installed_products));
return TRUE;
}
static gboolean
_client_subscription_status_update (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
g_autoptr(GVariant) uuid = NULL;
const gchar *uuid_txt = NULL;
JsonNode *json_root;
JsonObject *json_obj;
const gchar *json_txt = NULL;
g_autoptr(GVariant) status = NULL;
g_autoptr(JsonParser) json_parser = json_parser_new ();
/* save old value */
priv->subscription_status_last = priv->subscription_status;
+ if (!_client_installed_products_update (manager, error))
+ goto out;
+
+ if (priv->installed_products->len == 0) {
+ priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_NO_INSTALLED_PRODUCTS;
+ goto out;
+ }
uuid = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_CONSUMER],
"GetUuid",
g_variant_new ("(s)",
"C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (uuid == NULL)
return FALSE;
g_variant_get (uuid, "(&s)", &uuid_txt);
status = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_ENTITLEMENT],
"GetStatus",
g_variant_new ("(ss)",
"", /* assumed as 'now' */
"C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (status == NULL)
return FALSE;
g_variant_get (status, "(&s)", &json_txt);
g_debug ("Entitlement.GetStatus JSON: %s", json_txt);
if (!json_parser_load_from_data (json_parser, json_txt, -1, error))
return FALSE;
json_root = json_parser_get_root (json_parser);
json_obj = json_node_get_object (json_root);
if (!json_object_has_member (json_obj, "valid")) {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
"no Entitlement.GetStatus valid in %s", json_txt);
@@ -563,62 +570,60 @@ _client_register_with_keys (GsdSubscriptionManager *manager,
NULL);
if (subprocess == NULL) {
g_prefix_error (error, "failed to find pkexec: ");
return FALSE;
}
if (!g_subprocess_communicate (subprocess, stdin_buf, 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",
g_bytes_get_size (stderr_buf),
g_bytes_get_data (stderr_buf, NULL));
}
/* FIXME: also do on error? */
if (!_client_register_stop (manager, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
- if (!_client_installed_products_update (manager, error))
- return FALSE;
_client_maybe__show_notification (manager);
/* success */
return TRUE;
}
static gboolean
_client_register (GsdSubscriptionManager *manager,
const gchar *hostname,
const gchar *organisation,
const gchar *username,
const gchar *password,
GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
g_autoptr(GSubprocess) subprocess = NULL;
g_autoptr(GBytes) stdin_buf = g_bytes_new (password, strlen (password) + 1);
g_autoptr(GBytes) stderr_buf = NULL;
gint rc;
/* fallback */
if (organisation == NULL)
organisation = "";
/* apparently: "we can't send registration credentials over the regular
* system or session bus since those aren't really locked down..." */
if (!_client_register_start (manager, error))
return FALSE;
g_debug ("spawning %s", LIBEXECDIR "/gsd-subman-helper");
subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_PIPE | G_SUBPROCESS_FLAGS_STDERR_PIPE,
@@ -632,62 +637,60 @@ _client_register (GsdSubscriptionManager *manager,
NULL);
if (subprocess == NULL) {
g_prefix_error (error, "failed to find pkexec: ");
return FALSE;
}
if (!g_subprocess_communicate (subprocess, stdin_buf, 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",
g_bytes_get_size (stderr_buf),
g_bytes_get_data (stderr_buf, NULL));
}
/* FIXME: also do on error? */
if (!_client_register_stop (manager, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
- if (!_client_installed_products_update (manager, error))
- return FALSE;
_client_maybe__show_notification (manager);
return TRUE;
}
static gboolean
_client_unregister (GsdSubscriptionManager *manager, GError **error)
{
g_autoptr(GSubprocess) subprocess = NULL;
/* apparently: "we can't send registration credentials over the regular
* system or session bus since those aren't really locked down..." */
if (!_client_register_start (manager, error))
return FALSE;
g_debug ("spawning %s", LIBEXECDIR "/gsd-subman-helper");
subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDERR_PIPE, error,
"pkexec", LIBEXECDIR "/gsd-subman-helper",
"--kind", "unregister",
NULL);
if (subprocess == NULL) {
g_prefix_error (error, "failed to find pkexec: ");
return FALSE;
}
if (!_client_subprocess_wait_check (subprocess, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
if (!_client_installed_products_update (manager, error))
return FALSE;
_client_maybe__show_notification (manager);
return TRUE;
@@ -714,64 +717,60 @@ _client_update_config (GsdSubscriptionManager *manager, GError **error)
dict = g_variant_dict_new (g_variant_get_child_value (val, 0));
val_server = g_variant_dict_lookup_value (dict, "server", G_VARIANT_TYPE("a{ss}"));
if (val_server != NULL) {
g_variant_iter_init (&iter, val_server);
while (g_variant_iter_next (&iter, "{ss}", &key, &value)) {
g_debug ("%s=%s", key, value);
g_hash_table_insert (priv->config,
g_steal_pointer (&key),
g_steal_pointer (&value));
}
}
return TRUE;
}
static void
_subman_proxy_signal_cb (GDBusProxy *proxy,
const gchar *sender_name,
const gchar *signal_name,
GVariant *parameters,
GsdSubscriptionManager *manager)
{
g_autoptr(GError) error = NULL;
if (!_client_syspurpose_update (manager, &error)) {
g_warning ("failed to update syspurpose: %s", error->message);
g_clear_error (&error);
}
if (!_client_subscription_status_update (manager, &error)) {
g_warning ("failed to update subscription status: %s", error->message);
g_clear_error (&error);
}
- if (!_client_installed_products_update (manager, &error)) {
- g_warning ("failed to update installed products: %s", error->message);
- g_clear_error (&error);
- }
_client_maybe__show_notification (manager);
}
static void
_client_unload (GsdSubscriptionManager *manager)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
for (guint i = 0; i < _RHSM_INTERFACE_LAST; i++)
g_clear_object (&priv->proxies[i]);
g_hash_table_unref (priv->config);
}
static const gchar *
_rhsm_interface_to_string (_RhsmInterface kind)
{
if (kind == _RHSM_INTERFACE_CONFIG)
return "Config";
if (kind == _RHSM_INTERFACE_REGISTER_SERVER)
return "RegisterServer";
if (kind == _RHSM_INTERFACE_ATTACH)
return "Attach";
if (kind == _RHSM_INTERFACE_ENTITLEMENT)
return "Entitlement";
if (kind == _RHSM_INTERFACE_PRODUCTS)
return "Products";
if (kind == _RHSM_INTERFACE_CONSUMER)
return "Consumer";
if (kind == _RHSM_INTERFACE_SYSPURPOSE)
return "Syspurpose";
return NULL;
@@ -782,62 +781,60 @@ _client_load (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
priv->config = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
/* connect to all the interfaces on the *different* objects :| */
for (guint i = 0; i < _RHSM_INTERFACE_LAST; i++) {
const gchar *kind = _rhsm_interface_to_string (i);
g_autofree gchar *opath = g_strdup_printf ("/com/redhat/RHSM1/%s", kind);
g_autofree gchar *iface = g_strdup_printf ("com.redhat.RHSM1.%s", kind);
priv->proxies[i] =
g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
"com.redhat.RHSM1",
opath, iface,
NULL,
error);
if (priv->proxies[i] == NULL)
return FALSE;
/* we want to get notified if the status of the system changes */
g_signal_connect (priv->proxies[i], "g-signal",
G_CALLBACK (_subman_proxy_signal_cb), manager);
}
/* get initial status */
if (!_client_update_config (manager, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
- if (!_client_installed_products_update (manager, error))
- return FALSE;
if (!_client_syspurpose_update (manager, error))
return FALSE;
/* success */
return TRUE;
}
gboolean
gsd_subscription_manager_start (GsdSubscriptionManager *manager, GError **error)
{
gboolean ret;
g_debug ("Starting subscription manager");
gnome_settings_profile_start (NULL);
ret = _client_load (manager, error);
_client_maybe__show_notification (manager);
gnome_settings_profile_end (NULL);
return ret;
}
void
gsd_subscription_manager_stop (GsdSubscriptionManager *manager)
{
g_debug ("Stopping subscription manager");
_client_unload (manager);
}
static void
gsd_subscription_manager_class_init (GsdSubscriptionManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
--
2.30.0

View File

@ -1,146 +0,0 @@
From 432850e943d72daedb1d352a0332d3fdee6078e2 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sun, 24 Jan 2021 11:26:40 -0500
Subject: [PATCH 11/15] subman: Fix some build warnings
---
plugins/subman/gsd-subscription-manager.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/plugins/subman/gsd-subscription-manager.c b/plugins/subman/gsd-subscription-manager.c
index 46f8d35c..1f9ca447 100644
--- a/plugins/subman/gsd-subscription-manager.c
+++ b/plugins/subman/gsd-subscription-manager.c
@@ -561,62 +561,62 @@ _client_register_with_keys (GsdSubscriptionManager *manager,
if (!_client_register_start (manager, error))
return FALSE;
g_debug ("spawning %s", LIBEXECDIR "/gsd-subman-helper");
subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_PIPE | G_SUBPROCESS_FLAGS_STDERR_PIPE, error,
"pkexec", LIBEXECDIR "/gsd-subman-helper",
"--kind", "register-with-key",
"--address", priv->address,
"--hostname", hostname,
"--organisation", organisation,
NULL);
if (subprocess == NULL) {
g_prefix_error (error, "failed to find pkexec: ");
return FALSE;
}
if (!g_subprocess_communicate (subprocess, stdin_buf, 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",
- g_bytes_get_size (stderr_buf),
- g_bytes_get_data (stderr_buf, NULL));
+ (int) g_bytes_get_size (stderr_buf),
+ (char *) g_bytes_get_data (stderr_buf, NULL));
}
/* FIXME: also do on error? */
if (!_client_register_stop (manager, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
_client_maybe__show_notification (manager);
/* success */
return TRUE;
}
static gboolean
_client_register (GsdSubscriptionManager *manager,
const gchar *hostname,
const gchar *organisation,
const gchar *username,
const gchar *password,
GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
g_autoptr(GSubprocess) subprocess = NULL;
g_autoptr(GBytes) stdin_buf = g_bytes_new (password, strlen (password) + 1);
g_autoptr(GBytes) stderr_buf = NULL;
gint rc;
/* fallback */
if (organisation == NULL)
organisation = "";
@@ -628,62 +628,62 @@ _client_register (GsdSubscriptionManager *manager,
g_debug ("spawning %s", LIBEXECDIR "/gsd-subman-helper");
subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_PIPE | G_SUBPROCESS_FLAGS_STDERR_PIPE,
error,
"pkexec", LIBEXECDIR "/gsd-subman-helper",
"--kind", "register-with-username",
"--address", priv->address,
"--hostname", hostname,
"--organisation", organisation,
"--username", username,
NULL);
if (subprocess == NULL) {
g_prefix_error (error, "failed to find pkexec: ");
return FALSE;
}
if (!g_subprocess_communicate (subprocess, stdin_buf, 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",
- g_bytes_get_size (stderr_buf),
- g_bytes_get_data (stderr_buf, NULL));
+ (int) g_bytes_get_size (stderr_buf),
+ (char *) g_bytes_get_data (stderr_buf, NULL));
}
/* FIXME: also do on error? */
if (!_client_register_stop (manager, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
_client_maybe__show_notification (manager);
return TRUE;
}
static gboolean
_client_unregister (GsdSubscriptionManager *manager, GError **error)
{
g_autoptr(GSubprocess) subprocess = NULL;
/* apparently: "we can't send registration credentials over the regular
* system or session bus since those aren't really locked down..." */
if (!_client_register_start (manager, error))
return FALSE;
g_debug ("spawning %s", LIBEXECDIR "/gsd-subman-helper");
subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDERR_PIPE, error,
"pkexec", LIBEXECDIR "/gsd-subman-helper",
"--kind", "unregister",
NULL);
if (subprocess == NULL) {
g_prefix_error (error, "failed to find pkexec: ");
return FALSE;
}
if (!_client_subprocess_wait_check (subprocess, error))
--
2.30.0

View File

@ -1,259 +0,0 @@
From 3bb3b2b09d34deafadd3cfe3355137afab20cb23 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sun, 24 Jan 2021 11:27:42 -0500
Subject: [PATCH 12/15] 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
@@ -19,60 +19,61 @@
*/
#include "config.h"
#include <glib/gi18n.h>
#include <gio/gunixinputstream.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <json-glib/json-glib.h>
#include <libnotify/notify.h>
#include "gnome-settings-profile.h"
#include "gsd-subman-common.h"
#include "gsd-subscription-manager.h"
#define GSD_DBUS_NAME "org.gnome.SettingsDaemon"
#define GSD_DBUS_PATH "/org/gnome/SettingsDaemon"
#define GSD_DBUS_BASE_INTERFACE "org.gnome.SettingsDaemon"
#define GSD_SUBSCRIPTION_DBUS_NAME GSD_DBUS_NAME ".Subscription"
#define GSD_SUBSCRIPTION_DBUS_PATH GSD_DBUS_PATH "/Subscription"
#define GSD_SUBSCRIPTION_DBUS_INTERFACE GSD_DBUS_BASE_INTERFACE ".Subscription"
static const gchar introspection_xml[] =
"<node>"
" <interface name='org.gnome.SettingsDaemon.Subscription'>"
" <method name='Register'>"
" <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>"
"</node>";
#define GSD_SUBSCRIPTION_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_SUBSCRIPTION_MANAGER, GsdSubscriptionManagerPrivate))
typedef enum {
_RHSM_INTERFACE_CONFIG,
_RHSM_INTERFACE_REGISTER_SERVER,
_RHSM_INTERFACE_ATTACH,
_RHSM_INTERFACE_ENTITLEMENT,
_RHSM_INTERFACE_PRODUCTS,
_RHSM_INTERFACE_CONSUMER,
_RHSM_INTERFACE_SYSPURPOSE,
_RHSM_INTERFACE_LAST
} _RhsmInterface;
struct GsdSubscriptionManagerPrivate
{
/* D-Bus */
guint name_id;
GDBusNodeInfo *introspection_data;
GDBusConnection *connection;
GCancellable *bus_cancellable;
GDBusProxy *proxies[_RHSM_INTERFACE_LAST];
GHashTable *config; /* str:str */
GPtrArray *installed_products;
gchar *address;
@@ -669,60 +670,104 @@ _client_register (GsdSubscriptionManager *manager,
}
static gboolean
_client_unregister (GsdSubscriptionManager *manager, GError **error)
{
g_autoptr(GSubprocess) subprocess = NULL;
/* apparently: "we can't send registration credentials over the regular
* system or session bus since those aren't really locked down..." */
if (!_client_register_start (manager, error))
return FALSE;
g_debug ("spawning %s", LIBEXECDIR "/gsd-subman-helper");
subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDERR_PIPE, error,
"pkexec", LIBEXECDIR "/gsd-subman-helper",
"--kind", "unregister",
NULL);
if (subprocess == NULL) {
g_prefix_error (error, "failed to find pkexec: ");
return FALSE;
}
if (!_client_subprocess_wait_check (subprocess, error))
return FALSE;
if (!_client_subscription_status_update (manager, error))
return FALSE;
if (!_client_installed_products_update (manager, error))
return FALSE;
_client_maybe__show_notification (manager);
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)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
g_autoptr(GVariant) val = NULL;
g_autoptr(GVariant) val_server = NULL;
g_autoptr(GVariantDict) dict = NULL;
GVariantIter iter;
gchar *key;
gchar *value;
val = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_CONFIG],
"GetAll",
g_variant_new ("(s)", "C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (val == NULL)
return FALSE;
dict = g_variant_dict_new (g_variant_get_child_value (val, 0));
val_server = g_variant_dict_lookup_value (dict, "server", G_VARIANT_TYPE("a{ss}"));
if (val_server != NULL) {
g_variant_iter_init (&iter, val_server);
while (g_variant_iter_next (&iter, "{ss}", &key, &value)) {
g_debug ("%s=%s", key, value);
g_hash_table_insert (priv->config,
g_steal_pointer (&key),
g_steal_pointer (&value));
}
}
return TRUE;
@@ -1002,60 +1047,66 @@ handle_method_call (GDBusConnection *connection,
g_dbus_method_invocation_return_gerror (invocation, error);
return;
}
} else if (g_strcmp0 (kind, "key") == 0) {
const gchar *activation_key = NULL;
g_variant_dict_lookup (dict, "hostname", "&s", &hostname);
g_variant_dict_lookup (dict, "organisation", "&s", &organisation);
g_variant_dict_lookup (dict, "activation-key", "&s", &activation_key);
if (!_client_register_with_keys (manager,
hostname,
organisation,
activation_key,
&error)) {
g_dbus_method_invocation_return_gerror (invocation, error);
return;
}
} else {
g_dbus_method_invocation_return_error_literal (invocation,
G_IO_ERROR, G_IO_ERROR_FAILED,
"Invalid kind specified");
return;
}
g_dbus_method_invocation_return_value (invocation, NULL);
} else if (g_strcmp0 (method_name, "Unregister") == 0) {
if (!_client_unregister (manager, &error)) {
g_dbus_method_invocation_return_gerror (invocation, error);
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 ();
}
}
static GVariant *
handle_get_property (GDBusConnection *connection,
const gchar *sender,
const gchar *object_path,
const gchar *interface_name,
const gchar *property_name,
GError **error, gpointer user_data)
{
GsdSubscriptionManager *manager = GSD_SUBSCRIPTION_MANAGER (user_data);
GsdSubscriptionManagerPrivate *priv = manager->priv;
if (g_strcmp0 (interface_name, GSD_SUBSCRIPTION_DBUS_INTERFACE) != 0) {
g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
"No such interface: %s", interface_name);
return NULL;
}
if (g_strcmp0 (property_name, "SubscriptionStatus") == 0)
return g_variant_new_uint32 (priv->subscription_status);
if (g_strcmp0 (property_name, "InstalledProducts") == 0)
return _make_installed_products_variant (priv->installed_products);
g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
"Failed to get property: %s", property_name);
--
2.30.0

View File

@ -1,141 +0,0 @@
From d9eb6331efa92cd28a8ba3ccc1665c3744296465 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sun, 24 Jan 2021 11:34:03 -0500
Subject: [PATCH 13/15] subman: Improve subscription status handling
This commit improves how subscription-manager status is
parsed to give more detailed information about subscription
state.
---
plugins/subman/gsd-subscription-manager.c | 33 +++++++++++++++++++----
1 file changed, 28 insertions(+), 5 deletions(-)
diff --git a/plugins/subman/gsd-subscription-manager.c b/plugins/subman/gsd-subscription-manager.c
index 705f8b11..6d80bfa9 100644
--- a/plugins/subman/gsd-subscription-manager.c
+++ b/plugins/subman/gsd-subscription-manager.c
@@ -262,93 +262,116 @@ _client_subscription_status_update (GsdSubscriptionManager *manager, GError **er
GsdSubscriptionManagerPrivate *priv = manager->priv;
g_autoptr(GVariant) uuid = NULL;
const gchar *uuid_txt = NULL;
JsonNode *json_root;
JsonObject *json_obj;
const gchar *json_txt = NULL;
g_autoptr(GVariant) status = NULL;
g_autoptr(JsonParser) json_parser = json_parser_new ();
/* save old value */
priv->subscription_status_last = priv->subscription_status;
if (!_client_installed_products_update (manager, error))
goto out;
if (priv->installed_products->len == 0) {
priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_NO_INSTALLED_PRODUCTS;
goto out;
}
uuid = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_CONSUMER],
"GetUuid",
g_variant_new ("(s)",
"C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (uuid == NULL)
return FALSE;
g_variant_get (uuid, "(&s)", &uuid_txt);
+ if (uuid_txt[0] == '\0') {
+ priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN;
+ goto out;
+ }
+
status = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_ENTITLEMENT],
"GetStatus",
g_variant_new ("(ss)",
"", /* assumed as 'now' */
"C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (status == NULL)
return FALSE;
g_variant_get (status, "(&s)", &json_txt);
g_debug ("Entitlement.GetStatus JSON: %s", json_txt);
if (!json_parser_load_from_data (json_parser, json_txt, -1, error))
return FALSE;
json_root = json_parser_get_root (json_parser);
json_obj = json_node_get_object (json_root);
+
+ const gchar *status_id = NULL;
+
+ if (json_object_has_member (json_obj, "status_id")) {
+ status_id = json_object_get_string_member (json_obj, "status_id");
+ }
+
if (!json_object_has_member (json_obj, "valid")) {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
"no Entitlement.GetStatus valid in %s", json_txt);
return FALSE;
}
gboolean is_valid = json_object_get_boolean_member (json_obj, "valid");
- if (uuid_txt[0] != '\0') {
- if (is_valid) {
+ if (is_valid) {
+ if (g_strcmp0 (status_id, "disabled") != 0) {
priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID;
} else {
- priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID;
+ priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_DISABLED;
+ }
+ goto out;
+ }
+
+ for (guint i = 0; i < priv->installed_products->len; i++) {
+ ProductData *product = g_ptr_array_index (priv->installed_products, i);
+
+ if (g_strcmp0 (product->status, "subscribed") == 0) {
+ priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID;
+ goto out;
}
- } else {
- priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN;
}
+ priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID;
+
+out:
/* emit notification for g-c-c */
if (priv->subscription_status != priv->subscription_status_last) {
_emit_property_changed (manager, "SubscriptionStatus",
g_variant_new_uint32 (priv->subscription_status));
}
return TRUE;
}
static gboolean
_client_syspurpose_update (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
JsonNode *json_root;
JsonObject *json_obj;
const gchar *json_txt = NULL;
g_autoptr(GVariant) val = NULL;
g_autoptr(JsonParser) json_parser = json_parser_new ();
val = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_SYSPURPOSE],
"GetSyspurpose",
g_variant_new ("(s)", "C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (val == NULL)
return FALSE;
g_variant_get (val, "(&s)", &json_txt);
g_debug ("Syspurpose.GetSyspurpose JSON: %s", json_txt);
if (!json_parser_load_from_data (json_parser, json_txt, -1, error))
return FALSE;
--
2.30.0

View File

@ -1,56 +0,0 @@
From a78b25b9507edb958a46779f2bb808bf678fa4a7 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sun, 24 Jan 2021 11:55:19 -0500
Subject: [PATCH 14/15] subman: Drop "LAST" from status enum
It's unused, so get rid of it.
---
plugins/subman/gsd-subman-common.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/plugins/subman/gsd-subman-common.h b/plugins/subman/gsd-subman-common.h
index f8a3d9f4..88226564 100644
--- a/plugins/subman/gsd-subman-common.h
+++ b/plugins/subman/gsd-subman-common.h
@@ -4,38 +4,37 @@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __GSD_SUBMAN_COMMON_H
#define __GSD_SUBMAN_COMMON_H
#include <glib-object.h>
G_BEGIN_DECLS
typedef enum {
GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN,
GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID,
GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID,
GSD_SUBMAN_SUBSCRIPTION_STATUS_DISABLED,
GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID,
GSD_SUBMAN_SUBSCRIPTION_STATUS_NO_INSTALLED_PRODUCTS,
- GSD_SUBMAN_SUBSCRIPTION_STATUS_LAST
} GsdSubmanSubscriptionStatus;
const gchar *gsd_subman_subscription_status_to_string (GsdSubmanSubscriptionStatus status);
G_END_DECLS
#endif /* __GSD_SUBMAN_COMMON_H */
--
2.30.0

View File

@ -1,419 +0,0 @@
From 3412be1f63df2a5967ef92c27028368df1646b5c Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sun, 24 Jan 2021 12:41:20 -0500
Subject: [PATCH 15/15] subman: Clean up notification behavior
Notifications were only displayed for some status transitions.
This commit introduces some booleans based on the old and new
statuses to make the code clearer and to make it easier to hit
all the cases.
---
plugins/subman/gsd-subman-common.h | 1 +
plugins/subman/gsd-subscription-manager.c | 141 ++++++++++++++++++----
2 files changed, 120 insertions(+), 22 deletions(-)
diff --git a/plugins/subman/gsd-subman-common.h b/plugins/subman/gsd-subman-common.h
index 88226564..9397dbe4 100644
--- a/plugins/subman/gsd-subman-common.h
+++ b/plugins/subman/gsd-subman-common.h
@@ -1,40 +1,41 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2019 Richard Hughes <rhughes@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __GSD_SUBMAN_COMMON_H
#define __GSD_SUBMAN_COMMON_H
#include <glib-object.h>
G_BEGIN_DECLS
typedef enum {
+ GSD_SUBMAN_SUBSCRIPTION_STATUS_NOT_READ = -1,
GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN,
GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID,
GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID,
GSD_SUBMAN_SUBSCRIPTION_STATUS_DISABLED,
GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID,
GSD_SUBMAN_SUBSCRIPTION_STATUS_NO_INSTALLED_PRODUCTS,
} GsdSubmanSubscriptionStatus;
const gchar *gsd_subman_subscription_status_to_string (GsdSubmanSubscriptionStatus status);
G_END_DECLS
#endif /* __GSD_SUBMAN_COMMON_H */
diff --git a/plugins/subman/gsd-subscription-manager.c b/plugins/subman/gsd-subscription-manager.c
index 6d80bfa9..aaccbbc6 100644
--- a/plugins/subman/gsd-subscription-manager.c
+++ b/plugins/subman/gsd-subscription-manager.c
@@ -243,60 +243,61 @@ _client_installed_products_update (GsdSubscriptionManager *manager, GError **err
product->version = g_strdup (json_array_get_string_element (json_product, 2));
product->arch = g_strdup (json_array_get_string_element (json_product, 3));
product->status = g_strdup (json_array_get_string_element (json_product, 4));
product->starts = g_strdup (json_array_get_string_element (json_product, 6));
product->ends = g_strdup (json_array_get_string_element (json_product, 7));
g_ptr_array_add (priv->installed_products, g_steal_pointer (&product));
}
/* emit notification for g-c-c */
_emit_property_changed (manager, "InstalledProducts",
_make_installed_products_variant (priv->installed_products));
return TRUE;
}
static gboolean
_client_subscription_status_update (GsdSubscriptionManager *manager, GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
g_autoptr(GVariant) uuid = NULL;
const gchar *uuid_txt = NULL;
JsonNode *json_root;
JsonObject *json_obj;
const gchar *json_txt = NULL;
g_autoptr(GVariant) status = NULL;
g_autoptr(JsonParser) json_parser = json_parser_new ();
/* save old value */
priv->subscription_status_last = priv->subscription_status;
+
if (!_client_installed_products_update (manager, error))
goto out;
if (priv->installed_products->len == 0) {
priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_NO_INSTALLED_PRODUCTS;
goto out;
}
uuid = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_CONSUMER],
"GetUuid",
g_variant_new ("(s)",
"C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
if (uuid == NULL)
return FALSE;
g_variant_get (uuid, "(&s)", &uuid_txt);
if (uuid_txt[0] == '\0') {
priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN;
goto out;
}
status = g_dbus_proxy_call_sync (priv->proxies[_RHSM_INTERFACE_ENTITLEMENT],
"GetStatus",
g_variant_new ("(ss)",
"", /* assumed as 'now' */
"C.UTF-8"),
G_DBUS_CALL_FLAGS_NONE,
@@ -485,109 +486,203 @@ typedef enum {
static void
_show_notification (GsdSubscriptionManager *manager, _NotifyKind notify_kind)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
switch (notify_kind) {
case _NOTIFY_EXPIRED:
notify_notification_close (priv->notification_registered, NULL);
notify_notification_close (priv->notification_registration_required, NULL);
notify_notification_show (priv->notification_expired, NULL);
break;
case _NOTIFY_REGISTRATION_REQUIRED:
notify_notification_close (priv->notification_registered, NULL);
notify_notification_close (priv->notification_expired, NULL);
notify_notification_show (priv->notification_registration_required, NULL);
break;
case _NOTIFY_REGISTERED:
notify_notification_close (priv->notification_expired, NULL);
notify_notification_close (priv->notification_registration_required, NULL);
notify_notification_show (priv->notification_registered, NULL);
break;
default:
break;
}
g_timer_reset (priv->timer_last_notified);
}
static void
_client_maybe__show_notification (GsdSubscriptionManager *manager)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
+ gboolean was_read, was_registered, had_subscriptions, needed_subscriptions;
+ gboolean is_read, is_registered, has_subscriptions, needs_subscriptions;
+
+ switch (priv->subscription_status_last) {
+ case GSD_SUBMAN_SUBSCRIPTION_STATUS_NOT_READ:
+ was_read = FALSE;
+ was_registered = FALSE;
+ needed_subscriptions = TRUE;
+ had_subscriptions = FALSE;
+ break;
+ case GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN:
+ was_read = TRUE;
+ was_registered = FALSE;
+ needed_subscriptions = TRUE;
+ had_subscriptions = FALSE;
+ break;
+ case GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID:
+ was_read = TRUE;
+ was_registered = TRUE;
+ needed_subscriptions = TRUE;
+ had_subscriptions = TRUE;
+ break;
+ case GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID:
+ was_read = TRUE;
+ was_registered = TRUE;
+ needed_subscriptions = TRUE;
+ had_subscriptions = FALSE;
+ break;
+ case GSD_SUBMAN_SUBSCRIPTION_STATUS_DISABLED:
+ was_read = TRUE;
+ was_registered = TRUE;
+ needed_subscriptions = FALSE;
+ had_subscriptions = FALSE;
+ break;
+ case GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID:
+ was_read = TRUE;
+ was_registered = TRUE;
+ needed_subscriptions = TRUE;
+ had_subscriptions = FALSE;
+ case GSD_SUBMAN_SUBSCRIPTION_STATUS_NO_INSTALLED_PRODUCTS:
+ was_read = TRUE;
+ was_registered = FALSE;
+ needed_subscriptions = FALSE;
+ had_subscriptions = FALSE;
+ break;
+ }
+
+ switch (priv->subscription_status) {
+ case GSD_SUBMAN_SUBSCRIPTION_STATUS_NOT_READ:
+ is_read = FALSE;
+ is_registered = FALSE;
+ needs_subscriptions = TRUE;
+ has_subscriptions = FALSE;
+ break;
+ case GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN:
+ is_read = TRUE;
+ is_registered = FALSE;
+ needs_subscriptions = TRUE;
+ has_subscriptions = FALSE;
+ break;
+ case GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID:
+ is_read = TRUE;
+ is_registered = TRUE;
+ needs_subscriptions = TRUE;
+ has_subscriptions = TRUE;
+ break;
+ case GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID:
+ case GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID:
+ is_read = TRUE;
+ is_registered = TRUE;
+ needs_subscriptions = TRUE;
+ has_subscriptions = FALSE;
+ break;
+ case GSD_SUBMAN_SUBSCRIPTION_STATUS_DISABLED:
+ is_read = TRUE;
+ is_registered = TRUE;
+ needs_subscriptions = FALSE;
+ has_subscriptions = FALSE;
+ break;
+ case GSD_SUBMAN_SUBSCRIPTION_STATUS_NO_INSTALLED_PRODUCTS:
+ is_read = TRUE;
+ is_registered = FALSE;
+ needs_subscriptions = FALSE;
+ has_subscriptions = FALSE;
+ break;
+ }
/* startup */
- if (priv->subscription_status_last == GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN &&
- priv->subscription_status == GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN) {
+ if (!was_read && is_read && priv->subscription_status == GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN) {
_show_notification (manager, _NOTIFY_REGISTRATION_REQUIRED);
return;
}
/* something changed */
- if (priv->subscription_status_last != priv->subscription_status) {
+ if (was_read && is_read && priv->subscription_status_last != priv->subscription_status) {
g_debug ("transisition from subscription status '%s' to '%s'",
gsd_subman_subscription_status_to_string (priv->subscription_status_last),
gsd_subman_subscription_status_to_string (priv->subscription_status));
- /* needs registration */
- if (priv->subscription_status_last == GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID &&
- priv->subscription_status == GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID) {
- _show_notification (manager, _NOTIFY_REGISTRATION_REQUIRED);
+ /* needs subscription */
+ if (is_registered && needs_subscriptions && !has_subscriptions) {
+ _show_notification (manager, _NOTIFY_EXPIRED);
return;
}
/* was unregistered */
- if (priv->subscription_status_last == GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID &&
- priv->subscription_status == GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN) {
+ if (was_registered && !is_registered) {
_show_notification (manager, _NOTIFY_REGISTRATION_REQUIRED);
return;
}
- /* registered */
- if (priv->subscription_status_last == GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN &&
- priv->subscription_status == GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID &&
- g_timer_elapsed (priv->timer_last_notified, NULL) > 60) {
- _show_notification (manager, _NOTIFY_REGISTERED);
- return;
+ /* just registered */
+ if (!was_registered && is_registered) {
+ if (!needs_subscriptions || has_subscriptions) {
+ _show_notification (manager, _NOTIFY_REGISTERED);
+ return;
+ }
+ }
+
+ /* subscriptions changed */
+ if (was_registered && is_registered) {
+ /* subscribed */
+ if (!had_subscriptions &&
+ needs_subscriptions && has_subscriptions) {
+ _show_notification (manager, _NOTIFY_REGISTERED);
+ return;
+ }
+
+ /* simple content access enabled */
+ if (needed_subscriptions && !had_subscriptions && !needs_subscriptions) {
+ _show_notification (manager, _NOTIFY_REGISTERED);
+ return;
+ }
}
}
/* nag again */
- if (priv->subscription_status == GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN &&
+ if (!is_registered &&
g_timer_elapsed (priv->timer_last_notified, NULL) > 60 * 60 * 24) {
_show_notification (manager, _NOTIFY_REGISTRATION_REQUIRED);
return;
}
- if (priv->subscription_status == GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID &&
- g_timer_elapsed (priv->timer_last_notified, NULL) > 60 * 60 * 24) {
- _show_notification (manager, _NOTIFY_EXPIRED);
- return;
- }
- if (priv->subscription_status == GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID &&
+ if (is_registered && !has_subscriptions && needs_subscriptions &&
g_timer_elapsed (priv->timer_last_notified, NULL) > 60 * 60 * 24) {
_show_notification (manager, _NOTIFY_EXPIRED);
return;
}
}
static gboolean
_client_register_with_keys (GsdSubscriptionManager *manager,
const gchar *hostname,
const gchar *organisation,
const gchar *activation_key,
GError **error)
{
GsdSubscriptionManagerPrivate *priv = manager->priv;
g_autoptr(GSubprocess) subprocess = NULL;
g_autoptr(GBytes) stdin_buf = g_bytes_new (activation_key, strlen (activation_key) + 1);
g_autoptr(GBytes) stderr_buf = NULL;
gint rc;
/* apparently: "we can't send registration credentials over the regular
* system or session bus since those aren't really locked down..." */
if (!_client_register_start (manager, error))
return FALSE;
g_debug ("spawning %s", LIBEXECDIR "/gsd-subman-helper");
subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_PIPE | G_SUBPROCESS_FLAGS_STDERR_PIPE, error,
"pkexec", LIBEXECDIR "/gsd-subman-helper",
"--kind", "register-with-key",
"--address", priv->address,
"--hostname", hostname,
"--organisation", organisation,
@@ -914,60 +1009,62 @@ gsd_subscription_manager_class_init (GsdSubscriptionManagerClass *klass)
static void
_launch_info_overview (void)
{
const gchar *argv[] = { "gnome-control-center", "info-overview", NULL };
g_debug ("Running gnome-control-center info-overview");
g_spawn_async (NULL, (gchar **) argv, NULL, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, NULL);
}
static void
_notify_closed_cb (NotifyNotification *notification, gpointer user_data)
{
/* FIXME: only launch when clicking on the main body, not the window close */
if (notify_notification_get_closed_reason (notification) == 0x400)
_launch_info_overview ();
}
static void
_notify_clicked_cb (NotifyNotification *notification, char *action, gpointer user_data)
{
_launch_info_overview ();
}
static void
gsd_subscription_manager_init (GsdSubscriptionManager *manager)
{
GsdSubscriptionManagerPrivate *priv = manager->priv = GSD_SUBSCRIPTION_MANAGER_GET_PRIVATE (manager);
priv->installed_products = g_ptr_array_new_with_free_func ((GDestroyNotify) product_data_free);
priv->timer_last_notified = g_timer_new ();
+ priv->subscription_status = GSD_SUBMAN_SUBSCRIPTION_STATUS_NOT_READ;
+ priv->subscription_status_last = GSD_SUBMAN_SUBSCRIPTION_STATUS_NOT_READ;
/* expired */
priv->notification_expired =
notify_notification_new (_("Subscription Has Expired"),
_("Add or renew a subscription to continue receiving software updates."),
NULL);
notify_notification_set_app_name (priv->notification_expired, _("Subscription"));
notify_notification_set_hint_string (priv->notification_expired, "desktop-entry", "subman-panel");
notify_notification_set_hint_string (priv->notification_expired, "x-gnome-privacy-scope", "system");
notify_notification_set_urgency (priv->notification_expired, NOTIFY_URGENCY_CRITICAL);
notify_notification_add_action (priv->notification_expired,
"info-overview", _("Subscribe System…"),
_notify_clicked_cb,
manager, NULL);
g_signal_connect (priv->notification_expired, "closed",
G_CALLBACK (_notify_closed_cb), manager);
/* registered */
priv->notification_registered =
notify_notification_new (_("Registration Successful"),
_("The system has been registered and software updates have been enabled."),
NULL);
notify_notification_set_app_name (priv->notification_registered, _("Subscription"));
notify_notification_set_hint_string (priv->notification_registered, "desktop-entry", "subman-panel");
notify_notification_set_hint_string (priv->notification_registered, "x-gnome-privacy-scope", "system");
notify_notification_set_urgency (priv->notification_registered, NOTIFY_URGENCY_CRITICAL);
g_signal_connect (priv->notification_registered, "closed",
G_CALLBACK (_notify_closed_cb), manager);
/* registration required */
--
2.30.0

View File

@ -1,25 +0,0 @@
From ff1278ecdebb5b23c80589a65f053d535a4d4f6a Mon Sep 17 00:00:00 2001
From: Kalev Lember <klember@redhat.com>
Date: Fri, 12 Feb 2021 14:51:29 +0100
Subject: [PATCH 16/16] subman: Update POTFILES.in
---
po/POTFILES.in | 2 ++
1 file changed, 2 insertions(+)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7f17d5b5..9b94dc0f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -25,6 +25,8 @@ plugins/print-notifications/gsd-printer.c
plugins/print-notifications/gsd-print-notifications-manager.c
plugins/smartcard/gsd-smartcard-manager.c
plugins/smartcard/gsd-smartcard-service.c
+plugins/subman/gsd-subscription-manager.c
+plugins/subman/org.gnome.settings-daemon.plugins.subman.policy.in.in
plugins/wacom/gsd-wacom-manager.c
plugins/wacom/org.gnome.settings-daemon.plugins.wacom.policy.in.in
plugins/xsettings/gsd-xsettings-manager.c
--
2.29.2

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +0,0 @@
[org.gnome.settings-daemon.plugins.power]
sleep-inactive-ac-timeout=0
sleep-inactive-battery-timeout=0

View File

@ -1,349 +1,214 @@
%global glib2_version 2.56
%global geocode_glib_version 3.10.0
%global gnome_desktop_version 3.27.90
%global gsettings_desktop_schemas_version 3.32.0-4
%global gtk3_version 3.15.3
%global libgweather_version 3.9.5
%global geoclue_version 2.3.1
%if %{undefined centos}
%bcond_without subman
%endif
Name: gnome-settings-daemon
Version: 3.32.0
Release: 19%{?dist}
Summary: The daemon sharing settings from GNOME to GTK+/KDE applications
License: GPLv2+
URL: https://download.gnome.org/sources/%{name}
Source0: https://download.gnome.org/sources/%{name}/3.32/%{name}-%{version}.tar.xz
Source1: org.gnome.settings-daemon.plugins.power.gschema.override
BuildRequires: meson >= 0.44.0
BuildRequires: gcc
BuildRequires: cups-devel
BuildRequires: gettext
BuildRequires: perl-interpreter
BuildRequires: git
BuildRequires: pkgconfig(alsa)
BuildRequires: pkgconfig(colord) >= 1.0.2
BuildRequires: pkgconfig(fontconfig)
BuildRequires: pkgconfig(geoclue-2.0) >= %{geoclue_version}
BuildRequires: pkgconfig(geocode-glib-1.0) >= %{geocode_glib_version}
BuildRequires: pkgconfig(glib-2.0) >= %{glib2_version}
BuildRequires: pkgconfig(gnome-desktop-3.0) >= %{gnome_desktop_version}
BuildRequires: pkgconfig(gsettings-desktop-schemas) >= %{gsettings_desktop_schemas_version}
BuildRequires: pkgconfig(gtk+-3.0) >= %{gtk3_version}
BuildRequires: pkgconfig(gudev-1.0)
BuildRequires: pkgconfig(gweather-3.0) >= %{libgweather_version}
%if %{with subman}
BuildRequires: pkgconfig(json-glib-1.0)
%endif
BuildRequires: pkgconfig(lcms2) >= 2.2
BuildRequires: pkgconfig(libcanberra-gtk3)
BuildRequires: pkgconfig(libgeoclue-2.0)
BuildRequires: pkgconfig(libnm)
BuildRequires: pkgconfig(libnotify)
BuildRequires: pkgconfig(libpulse)
BuildRequires: pkgconfig(libpulse-mainloop-glib)
BuildRequires: pkgconfig(librsvg-2.0)
BuildRequires: pkgconfig(nss)
BuildRequires: pkgconfig(polkit-gobject-1)
BuildRequires: pkgconfig(upower-glib)
BuildRequires: pkgconfig(x11)
BuildRequires: pkgconfig(xi)
BuildRequires: pkgconfig(wayland-client)
%ifnarch s390 s390x
BuildRequires: pkgconfig(libwacom) >= 0.7
BuildRequires: pkgconfig(xorg-wacom)
%endif
Requires: colord
Requires: iio-sensor-proxy
Requires: geoclue2 >= %{geoclue_version}
Requires: geocode-glib%{?_isa} >= %{geocode_glib_version}
Requires: glib2%{?_isa} >= %{glib2_version}
Requires: gnome-desktop3%{?_isa} >= %{gnome_desktop_version}
Requires: gsettings-desktop-schemas%{?_isa} >= %{gsettings_desktop_schemas_version}
Requires: gtk3%{?_isa} >= %{gtk3_version}
Requires: libgweather%{?_isa} >= %{libgweather_version}
Obsoletes: %{name}-updates < 3.13.1
Obsoletes: drwright < 3.5.0-3
Obsoletes: gnome-settings-daemon-devel < 3.23.1
# The "org.gnome.SettingsDaemon.A11yKeyboard" has been been removed, now
# handled in gnome-shell/mutter instead; this conflict here makes sure not to
# break older gdm and gnome-session releases that expect the functionality
Conflicts: gdm < 1:3.27.90
Conflicts: gnome-session < 3.27.90
# The orientation and xrandr plugins were removed in 3.25.4 and their
# functionality was moved to mutter; this conflict here makes sure not to break
# older gdm, gnome-session and gnome-shell releases that expect the functionality
Conflicts: gnome-shell < 3.25.4
# account plugin
Patch00001: 0001-account-first-cut-at-account-plugin.patch
Patch00002: 0002-account-reshow-the-notification-when-screen-unlocks.patch
Patch00003: 0003-account-display-nag-screen-periodically.patch
Patch00004: 0004-account-don-t-poll-more-frequently-than-notification.patch
Patch10001: 0001-smartcard-Cancel-cancellable-when-stopping.patch
Patch20001: 0001-xsettings-Add-an-entry-for-the-overlay-scrolling-set.patch
# Handle org.gnome.Shell.Screencast Stopped signal (#1705392)
Patch30001: 0001-media-keys-Mark-screen-cast-as-stopped-if-it-was-sig.patch
Patch40001: 0001-housekeeping-Add-a-GPU-memory-usage-notification.patch
# subscription manager integration
Patch50001: 0001-subman-Add-a-new-plugin-to-provide-system-subscripti.patch
Patch50002: 0002-subman-Add-InstalledProducts-dbus-property-for-g-c-c.patch
Patch50003: 0003-subman-Increase-RHSM-dbus-call-timeouts.patch
Patch50004: 0004-subman-Drop-userlang-field.patch
Patch50005: 0005-subman-Use-user-locale-for-registration-subscription.patch
Patch50006: 0006-subman-Handle-subscription-manager-giving-invalid-st.patch
Patch50007: 0007-subman-Force-re-subscribe-if-the-admin-already-subsc.patch
Patch50008: 0008-subman-Don-t-send-secrets-through-command-line.patch
Patch50009: 0009-subman-Don-t-treat-failure-to-attach-as-fatal.patch
Patch50010: 0010-subman-Add-new-no-installed-products-state.patch
Patch50011: 0011-subman-Fix-some-build-warnings.patch
Patch50012: 0012-subman-Add-DBus-API-to-subscribe-for-updates-on-alre.patch
Patch50013: 0013-subman-Improve-subscription-status-handling.patch
Patch50014: 0014-subman-Drop-LAST-from-status-enum.patch
Patch50015: 0015-subman-Clean-up-notification-behavior.patch
Patch50016: 0016-subman-Update-POTFILES.in.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=1876291
Patch50017: 0017-Update-translations.patch
Patch60001: 0001-power-Only-disable-Suspend-Hibernate-actions-inside-.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=2062051
Patch70001: 0001-power-Respect-the-nothing-power-button-action-for-VM.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=2018606
Patch70002: 0001-power-Avoid-automatic-logout-in-GDM-greeter.patch
Patch70003: 0002-power-Never-register-sleep-timeout-for-logout-in-GDM.patch
Patch70004: 0001-Make-power-button-action-always-power-off-when-chass.patch
%description
A daemon to share settings from GNOME to other applications. It also
handles global keybindings, as well as a number of desktop-wide settings.
%package devel
Summary: Development files for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
%prep
%autosetup -S git
%build
%meson
%meson_build
%install
%meson_install
cp %{SOURCE1} $RPM_BUILD_ROOT%{_datadir}/glib-2.0/schemas
%find_lang %{name} --with-gnome
mkdir $RPM_BUILD_ROOT%{_libdir}/gnome-settings-daemon-3.0/gtk-modules
%files -f %{name}.lang
%license COPYING
%doc AUTHORS NEWS
# list daemons explicitly, so we notice if one goes missing
# some of these don't have a separate gschema
%{_libexecdir}/gsd-account
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Account.desktop
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.account.gschema.xml
%{_libexecdir}/gsd-clipboard
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Clipboard.desktop
%{_libexecdir}/gsd-datetime
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Datetime.desktop
%{_libexecdir}/gsd-dummy
%{_libexecdir}/gsd-housekeeping
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Housekeeping.desktop
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.housekeeping.gschema.xml
%{_libexecdir}/gsd-keyboard
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Keyboard.desktop
%{_libexecdir}/gsd-media-keys
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.MediaKeys.desktop
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.media-keys.gschema.xml
%{_libexecdir}/gsd-mouse
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Mouse.desktop
%{_libexecdir}/gsd-locate-pointer
* Wed Feb 15 2023 David King <amigadave@amigadave.com> - 44~beta-1
- Update to 44.beta
%{_libexecdir}/gsd-backlight-helper
%{_datadir}/polkit-1/actions/org.gnome.settings-daemon.plugins.power.policy
%{_libexecdir}/gsd-power
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Power.desktop
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.power.gschema.xml
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.power.gschema.override
%{_libexecdir}/gsd-print-notifications
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.PrintNotifications.desktop
%{_libexecdir}/gsd-printer
%{_libexecdir}/gsd-rfkill
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Rfkill.desktop
%{_libexecdir}/gsd-screensaver-proxy
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.ScreensaverProxy.desktop
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 43.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
%{_libexecdir}/gsd-smartcard
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Smartcard.desktop
* Fri Sep 30 2022 Kalev Lember <klember@redhat.com> - 43.0-2
- Backport upstream patch to default to ibus for X11 clients (#2128423)
%{_libexecdir}/gsd-sound
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Sound.desktop
* Tue Sep 20 2022 Kalev Lember <klember@redhat.com> - 43.0-1
- Update to 43.0
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.peripherals.gschema.xml
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.peripherals.wacom.gschema.xml
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Wacom.desktop
* Tue Sep 06 2022 Kalev Lember <klember@redhat.com> - 43~rc-1
- Update to 43.rc
%ifnarch s390 s390x
%{_libexecdir}/gsd-wacom
%{_libexecdir}/gsd-wacom-led-helper
%{_libexecdir}/gsd-wacom-oled-helper
%{_datadir}/polkit-1/actions/org.gnome.settings-daemon.plugins.wacom.policy
%endif
* Wed Aug 10 2022 Kalev Lember <klember@redhat.com> - 43~beta-1
- Update to 43.beta
%{_libexecdir}/gsd-xsettings
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.XSettings.desktop
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.xsettings.gschema.xml
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 43~alpha-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
%{_libexecdir}/gsd-a11y-settings
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.A11ySettings.desktop
* Tue Jul 19 2022 Milan Crha <mcrha@redhat.com> - 43~alpha-3
- Build against gcr-4 due to other depencencies use it
%{_libexecdir}/gsd-color
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Color.desktop
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.color.gschema.xml
* Mon Jul 18 2022 Kalev Lember <klember@redhat.com> - 43~alpha-2
- Build against geocode-glib2 for libsoup3 support
%{_libexecdir}/gsd-sharing
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Sharing.desktop
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.sharing.gschema.xml
* Fri Jul 15 2022 Kalev Lember <klember@redhat.com> - 43~alpha-1
- Update to 43.alpha
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Subscription.desktop
%{_libexecdir}/gsd-subman
%{_libexecdir}/gsd-subman-helper
%{_datadir}/polkit-1/actions/org.gnome.settings-daemon.plugins.subman.policy
%{_datadir}/polkit-1/rules.d/org.gnome.settings-daemon.plugins.subman.rules
* Thu Jun 16 2022 David King <amigadave@amigadave.com> - 42.2-1
- Update to 42.2
%{_libdir}/gnome-settings-daemon-3.0/libgsd.so
* Sun Mar 20 2022 David King <amigadave@amigadave.com> - 42.1-1
- Update to 42.1
/usr/lib/udev/rules.d/*.rules
%{_datadir}/gnome-settings-daemon/
%{_datadir}/GConf/gsettings/gnome-settings-daemon.convert
* Tue Mar 08 2022 David King <amigadave@amigadave.com> - 42~rc-1
- Update to 42.rc
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.enums.xml
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.gschema.xml
* Mon Feb 14 2022 David King <amigadave@amigadave.com> - 42~beta-1
- Update to 42.beta
%files devel
%{_includedir}/gnome-settings-daemon-3.0
%{_libdir}/pkgconfig/gnome-settings-daemon.pc
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 42~alpha-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
%changelog
* Fri Feb 17 2023 Felipe Borges <feborges@redhat.com> - 4.32.0-19
- Make power-button-action default to poweroff on servers
- Resolves: #1920829
* Tue Jan 11 2022 Stephen Gallagher <sgallagh@redhat.com> - 42~alpha-2
- Lessen dependency on gsettings-desktop-schemas
* Tue Jan 24 2023 Felipe Borges <feborges@redhat.com> - 3.32.0-18
- Prevent automatic logout warning in greeter sessions
- Resolves: #2018606
* Mon Jan 10 2022 David King <amigadave@amigadave.com> - 42~alpha-1
- Update to 42.alpha
* Wed Jan 04 2023 Felipe Borges <feborges@redhat.com> - 3.32.0-17
- Make power-button-action respect the "nothing" action on VMs
- Resolves: #2062051
* Mon Dec 13 2021 Peter Hutterer <peter.hutterer@redhat.com> - 41.0-2
- Rebuild for libwacom soname bump
* Fri Sep 10 2021 Kalev Lember <klember@redhat.com> - 3.32.0-16
- Update pt_BR translations
- Resolves: #2003069
* Sat Sep 18 2021 Kalev Lember <klember@redhat.com> - 41.0-1
- Update to 41.0
* Fri Aug 06 2021 Carlos Garnacho <cgarnach@redhat.com> - 3.32.0-15
- Keep auto-logout working inside VMs
Resolves: #1904139
* Mon Aug 30 2021 Adam Williamson <awilliam@redhat.com> - 41~rc-2
- Rebuild with no changes for update wrangling reasons (#1998700)
* Mon Mar 01 2021 Kalev Lember <klember@redhat.com> - 3.32.0-14
- Update fr, ja, zh_CN translations
- Resolves: #1876291
* Thu Jan 21 2021 Ray Strode <rstrode@redhat.com> - 3.32.0-13
- Add back subscription-manager plugin
Related: #1870837
* Tue Jan 05 2021 Jonas Ådahl <jadahl@redhat.com> - 3.32.0-12
- Handle org.gnome.Shell.Screencast Stopped signal
Related: #1705392
* Wed Sep 02 2020 Ray Strode <rstrode@redhat.com> - 3.32.0-11
- Remove subman plugin for now
Resolves: #1872457
* Mon Aug 30 2021 Bastien Nocera <bnocera@redhat.com> - 41~rc-1
+ gnome-settings-daemon-41~rc-1
- Update to 41.rc
* Thu Aug 13 2020 Carl George <carl@redhat.com> - 3.32.0-10
- Disable subman plugin on CentOS
Resolves: #1827030
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 40.0.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Fri Nov 22 2019 Benjamin Otte <otte@redhat.com> - 3.32.0-9
- Update gsettings-deskto-schemas dependency for new setting
Resolves: #1775683, #1723462
* Wed Apr 14 2021 Kalev Lember <klember@redhat.com> - 40.0.1-1
- Update to 40.0.1
* Thu Nov 21 2019 Benjamin Otte <otte@redhat.com> - 3.32.0-8
- Add upstream setting for overlay scrolling
Resolves: #1723462
* Mon Mar 22 2021 Kalev Lember <klember@redhat.com> - 40.0-1
- Update to 40.0
- Drop old obsoletes/conflicts
* Mon Nov 18 2019 Kalev Lember <klember@redhat.com> - 3.32.0-7
- Add a new plugin to provide system subscription information
- Resolves: #1720249
* Mon Nov 04 2019 Marek Kasik <mkasik@redhat.com> - 3.32.0-6
- Initialize a variable from previous commit.
- Previous commit made it possible to use uninitialized variable.
- Detected by Coverity.
- Related: #1742710
* Mon Mar 15 2021 Kalev Lember <klember@redhat.com> - 40~rc-1
- Update to 40.rc
* Mon Nov 04 2019 Marek Kasik <mkasik@redhat.com> - 3.32.0-5
- Cancel cancellable when stopping smartcard plugin to avoid crash
- Resolves: #1742710
* Mon Feb 15 2021 Kalev Lember <klember@redhat.com> - 40~beta-2
- Fix loading gtk modules
- Update versioned dependencies
* Tue Jul 09 2019 Richard Hughes <rhughes@redhat.com> - 3.32.0-4
- Remove the subman plugin -- move to a 8.2 feature instead.
- Resolves: #1720249
* Mon Feb 15 2021 Florian Müllner <fmuellner@redhat.com> - 40~beta-1
- Update to 40.beta
* Mon Jun 17 2019 Richard Hughes <rhughes@redhat.com> - 3.32.0-3
- Add a new plugin to provide system subscription information
- Resolves: #1720249
* Mon Feb 15 2021 Florian Müllner <fmuellner@redhat.com> - 40~alpha.1-1
- Update to 40.alpha.1
* Mon Jun 10 2019 Ray Strode <rstrode@redhat.com> - 3.32.0-2
- Add dropped patches
Related: #1674382
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.38.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Thu May 23 2019 Florian Müllner <fmuellner@redhat.com> - 3.32.0-1
* Fri Oct 9 2020 Kalev Lember <klember@redhat.com> - 3.38.1-1
- Update to 3.38.1
* Mon Sep 14 2020 Kalev Lember <klember@redhat.com> - 3.38.0-1
- Update to 3.38.0
* Mon Sep 07 2020 Kalev Lember <klember@redhat.com> - 3.37.92-1
- Update to 3.37.92
* Sat Aug 29 2020 Kalev Lember <klember@redhat.com> - 3.37.1-1
- Update to 3.37.1
* Mon Aug 17 2020 Kalev Lember <klember@redhat.com> - 3.37.0-1
- Update to 3.37.0
* Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.36.1-3
- Second attempt - Rebuilt for
https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.36.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Thu Apr 30 2020 Kalev Lember <klember@redhat.com> - 3.36.1-1
- Update to 3.36.1
* Mon Mar 09 2020 Kalev Lember <klember@redhat.com> - 3.36.0-1
- Update to 3.36.0
* Mon Mar 02 2020 Kalev Lember <klember@redhat.com> - 3.35.92-1
- Update to 3.35.92
* Tue Feb 18 2020 Kalev Lember <klember@redhat.com> - 3.35.91-1
- Update to 3.35.91
* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.35.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Jan 16 2020 Kalev Lember <klember@redhat.com> - 3.35.0-2
- Rebuilt for libgnome-desktop soname bump
* Tue Jan 07 2020 Kalev Lember <klember@redhat.com> - 3.35.0-1
- Update to 3.35.0
* Mon Oct 14 2019 Kalev Lember <klember@redhat.com> - 3.34.1-1
- Update to 3.34.1
* Mon Sep 09 2019 Kalev Lember <klember@redhat.com> - 3.34.0-1
- Update to 3.34.0
* Fri Sep 06 2019 Kalev Lember <klember@redhat.com> - 3.33.92-1
- Update to 3.33.92
* Mon Aug 26 2019 Kalev Lember <klember@redhat.com> - 3.33.90-1
- Update to 3.33.90
- Drop old versioned conflicts
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.33.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sun Jul 21 2019 Kalev Lember <klember@redhat.com> - 3.33.0-3
- Rebuilt for libgnome-desktop soname bump
* Mon Jul 08 2019 Kalev Lember <klember@redhat.com> - 3.33.0-2
- Rebuilt for libgweather soname bump
* Tue Jun 25 2019 Kalev Lember <klember@redhat.com> - 3.33.0-1
- Update to 3.33.0
* Wed Jun 19 2019 Kalev Lember <klember@redhat.com> - 3.32.1-1
- Update to 3.32.1
* Tue May 28 2019 Marek Kasik <mkasik@redhat.com> - 3.32.0-2
- Fix NSS crash at smartcard plugin (#1688791)
* Mon Mar 11 2019 Kalev Lember <klember@redhat.com> - 3.32.0-1
- Update to 3.32.0
Resolves: #1698929
* Mon Jan 14 2019 Carlos Garnacho <cgarnach@redhat.com> - 3.28.1-2
- Enable IBus for OSK purposes, necessary for focus tracking
Resolves: #1626105
* Wed Mar 06 2019 Kalev Lember <klember@redhat.com> - 3.31.92-1
- Update to 3.31.92
* Wed Feb 20 2019 Kalev Lember <klember@redhat.com> - 3.31.91-1
- Update to 3.31.91
* Wed Feb 06 2019 Kalev Lember <klember@redhat.com> - 3.31.90-1
- Update to 3.31.90
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.31.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Wed Jan 09 2019 Kalev Lember <klember@redhat.com> - 3.31.2-1
- Update to 3.31.2
* Tue Nov 20 2018 Pete Walter <pwalter@fedoraproject.org> - 3.30.1.2-3
- Move gnome-remote-desktop recommends to gnome-control-center
* Fri Nov 09 2018 Ray Strode <rstrode@redhat.com> - 3.30.1.2-2
- Add recommends for gnome-remote-desktop after irc discussion
* Thu Oct 04 2018 Kalev Lember <klember@redhat.com> - 3.30.1.2-1
- Update to 3.30.1.2
* Fri Sep 28 2018 Kalev Lember <klember@redhat.com> - 3.30.1.1-1
- Update to 3.30.1.1
* Thu Sep 06 2018 Kalev Lember <klember@redhat.com> - 3.30.0-1
- Update to 3.30.0
* Sun Aug 12 2018 Kalev Lember <klember@redhat.com> - 3.29.90.1-1
- Update to 3.29.90.1
* Tue Jul 31 2018 Florian Weimer <fweimer@redhat.com> - 3.28.1-3
- Rebuild with fixed binutils
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.28.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Thu Apr 12 2018 Kalev Lember <klember@redhat.com> - 3.28.1-1
- Update to 3.28.1
* Tue Apr 10 2018 Michael Catanzaro <mcatanzaro@gnome.org> - 3.28.0-2
- Disable automatic suspend
- Disable automatic suspend, except when on battery power
* Mon Mar 12 2018 Kalev Lember <klember@redhat.com> - 3.28.0-1
- Update to 3.28.0
@ -1490,4 +1355,3 @@ http://bugzilla.gnome.org/show_bug.cgi?id=580761 for details
* Thu Dec 06 2007 - Bastien Nocera <bnocera@redhat.com> - 2.21.5-1
- First package

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-10
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: desktop-qe.desktop-ci.tier1-gating.functional}

203
gnome-settings-daemon.spec Normal file
View File

@ -0,0 +1,203 @@
%global glib2_version 2.58
%global colord_version 1.4.5
%global geocode_glib_version 3.26.3
%global gnome_desktop_version 3.37.1
%global gsettings_desktop_schemas_version 42
%global gtk3_version 3.15.3
%global geoclue_version 2.3.1
%ifnarch s390 s390x
%global wacom_unit org.gnome.SettingsDaemon.Wacom.service
%else
%global wacom_unit %{nil}
%endif
%global systemd_units org.gnome.SettingsDaemon.A11ySettings.service org.gnome.SettingsDaemon.Color.service org.gnome.SettingsDaemon.Datetime.service org.gnome.SettingsDaemon.Housekeeping.service org.gnome.SettingsDaemon.Keyboard.service org.gnome.SettingsDaemon.MediaKeys.service org.gnome.SettingsDaemon.Power.service org.gnome.SettingsDaemon.PrintNotifications.service org.gnome.SettingsDaemon.Rfkill.service org.gnome.SettingsDaemon.ScreensaverProxy.service org.gnome.SettingsDaemon.Sharing.service org.gnome.SettingsDaemon.Smartcard.service org.gnome.SettingsDaemon.Sound.service org.gnome.SettingsDaemon.UsbProtection.service org.gnome.SettingsDaemon.Wwan.service org.gnome.SettingsDaemon.XSettings.service %%{wacom_unit}
%global tarball_version %%(echo %{version} | tr '~' '.')
%global major_version %%(echo %{version} | cut -f 1 -d '~' | cut -f 1 -d '.')
Name: gnome-settings-daemon
Version: 46.0
Release: %autorelease
Summary: The daemon sharing settings from GNOME to GTK+/KDE applications
License: GPL-2.0-or-later AND LGPL-2.1-or-later
URL: https://gitlab.gnome.org/GNOME/gnome-settings-daemon
Source0: https://download.gnome.org/sources/%{name}/%{major_version}/%{name}-%{tarball_version}.tar.xz
# https://issues.redhat.com/browse/RHEL-30294
Patch0: power-server-sleep-type-default.patch
BuildRequires: gcc
BuildRequires: gettext
BuildRequires: meson >= 0.49.0
BuildRequires: perl-interpreter
BuildRequires: systemd-rpm-macros
BuildRequires: pkgconfig(alsa)
BuildRequires: pkgconfig(colord) >= %{colord_version}
BuildRequires: pkgconfig(cups)
BuildRequires: pkgconfig(fontconfig)
BuildRequires: pkgconfig(gck-2)
BuildRequires: pkgconfig(gcr-4)
BuildRequires: pkgconfig(geoclue-2.0) >= %{geoclue_version}
BuildRequires: pkgconfig(geocode-glib-2.0) >= %{geocode_glib_version}
BuildRequires: pkgconfig(glib-2.0) >= %{glib2_version}
BuildRequires: pkgconfig(gnome-desktop-3.0) >= %{gnome_desktop_version}
BuildRequires: pkgconfig(gsettings-desktop-schemas) >= %{gsettings_desktop_schemas_version}
BuildRequires: pkgconfig(gtk+-3.0) >= %{gtk3_version}
BuildRequires: pkgconfig(gudev-1.0)
BuildRequires: pkgconfig(gweather4)
BuildRequires: pkgconfig(lcms2) >= 2.2
BuildRequires: pkgconfig(libcanberra-gtk3)
BuildRequires: pkgconfig(libgeoclue-2.0)
BuildRequires: pkgconfig(libnm)
BuildRequires: pkgconfig(libnotify)
BuildRequires: pkgconfig(libpulse)
BuildRequires: pkgconfig(libpulse-mainloop-glib)
BuildRequires: pkgconfig(librsvg-2.0)
BuildRequires: pkgconfig(mm-glib)
BuildRequires: pkgconfig(nss)
BuildRequires: pkgconfig(polkit-gobject-1)
BuildRequires: pkgconfig(upower-glib)
BuildRequires: pkgconfig(x11)
BuildRequires: pkgconfig(xi)
BuildRequires: pkgconfig(wayland-client)
%ifnarch s390 s390x
BuildRequires: pkgconfig(libwacom) >= 0.7
%endif
Requires: colord >= %{colord_version}
Requires: iio-sensor-proxy
Requires: geoclue2 >= %{geoclue_version}
Requires: geocode-glib2%{?_isa} >= %{geocode_glib_version}
Requires: glib2%{?_isa} >= %{glib2_version}
Requires: gnome-desktop3%{?_isa} >= %{gnome_desktop_version}
Requires: gsettings-desktop-schemas%{?_isa} >= %{gsettings_desktop_schemas_version}
Requires: gtk3%{?_isa} >= %{gtk3_version}
Requires: libgweather4%{?_isa}
%description
A daemon to share settings from GNOME to other applications. It also
handles global keybindings, as well as a number of desktop-wide settings.
%package devel
Summary: Development files for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
%prep
%autosetup -p1 -n %{name}-%{tarball_version}
%build
%meson
%meson_build
%install
%meson_install
%find_lang %{name} --with-gnome
%post
%systemd_user_post %{systemd_units}
%preun
%systemd_user_preun %{systemd_units}
%files -f %{name}.lang
%license COPYING COPYING.LIB
%doc AUTHORS NEWS README
# list daemons explicitly, so we notice if one goes missing
# some of these don't have a separate gschema
%{_libexecdir}/gsd-datetime
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Datetime.desktop
%{_libexecdir}/gsd-housekeeping
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Housekeeping.desktop
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.housekeeping.gschema.xml
%{_libexecdir}/gsd-keyboard
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Keyboard.desktop
%{_libexecdir}/gsd-media-keys
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.MediaKeys.desktop
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.media-keys.gschema.xml
%{_libexecdir}/gsd-backlight-helper
%{_datadir}/polkit-1/actions/org.gnome.settings-daemon.plugins.power.policy
%{_libexecdir}/gsd-power
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Power.desktop
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.power.gschema.xml
%{_libexecdir}/gsd-print-notifications
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.PrintNotifications.desktop
%{_libexecdir}/gsd-printer
%{_libexecdir}/gsd-rfkill
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Rfkill.desktop
%{_libexecdir}/gsd-screensaver-proxy
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.ScreensaverProxy.desktop
%{_libexecdir}/gsd-smartcard
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Smartcard.desktop
%{_libexecdir}/gsd-sound
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Sound.desktop
%{_libexecdir}/gsd-usb-protection
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.UsbProtection.desktop
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.peripherals.gschema.xml
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.peripherals.wacom.gschema.xml
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Wacom.desktop
%ifnarch s390 s390x
%{_libexecdir}/gsd-wacom
%{_libexecdir}/gsd-wacom-oled-helper
%{_datadir}/polkit-1/actions/org.gnome.settings-daemon.plugins.wacom.policy
%endif
%{_libexecdir}/gsd-xsettings
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.XSettings.desktop
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.xsettings.gschema.xml
%{_libexecdir}/gsd-a11y-settings
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.A11ySettings.desktop
%{_libexecdir}/gsd-color
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Color.desktop
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.color.gschema.xml
%{_libexecdir}/gsd-sharing
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Sharing.desktop
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.sharing.gschema.xml
%{_sysconfdir}/xdg/autostart/org.gnome.SettingsDaemon.Wwan.desktop
%{_libexecdir}/gsd-wwan
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.wwan.gschema.xml
%dir %{_libdir}/gnome-settings-daemon-%{major_version}
%{_libdir}/gnome-settings-daemon-%{major_version}/libgsd.so
%{_sysconfdir}/xdg/Xwayland-session.d/00-xrdb
%{_userunitdir}/gnome-session-x11-services-ready.target.wants/
%{_userunitdir}/gnome-session-x11-services.target.wants/
%{lua: for service in string.gmatch(rpm.expand('%{systemd_units}'), "[^%s]+") do print(rpm.expand('%{_userunitdir}/')..service..'\n') end}
%{_userunitdir}/*.target
%{_udevrulesdir}/61-gnome-settings-daemon-rfkill.rules
%{_datadir}/gnome-settings-daemon/
%{_datadir}/GConf/gsettings/gnome-settings-daemon.convert
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.enums.xml
%{_datadir}/glib-2.0/schemas/org.gnome.settings-daemon.plugins.gschema.xml
%files devel
%{_includedir}/gnome-settings-daemon-%{major_version}
%{_libdir}/pkgconfig/gnome-settings-daemon.pc
%changelog
%autochangelog

View File

@ -0,0 +1,105 @@
From 394cbc30d8093808ddba69c6c709e20f38d9f280 Mon Sep 17 00:00:00 2001
From: Felipe Borges <felipeborges@gnome.org>
Date: Tue, 6 Aug 2024 15:49:21 +0200
Subject: [PATCH] power: Add "sleep-inactive-ac-type-server" as a side
setting for servers
This avoids servers having the defaults from other chassis types.
A "server" is determined by hostnamed chassis-type server.
---
...ttings-daemon.plugins.power.gschema.xml.in | 5 +++++
plugins/power/gsd-power-manager.c | 19 ++++++++++++++-----
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in b/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
index 051bcf70..438cd62b 100644
--- a/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
+++ b/data/org.gnome.settings-daemon.plugins.power.gschema.xml.in
@@ -21,6 +21,11 @@
<summary>Whether to hibernate, suspend or do nothing when inactive</summary>
<description>The type of sleeping that should be performed when the computer is inactive.</description>
</key>
+ <key name="sleep-inactive-ac-type-server" enum="org.gnome.settings-daemon.GsdPowerActionType">
+ <default>'nothing'</default>
+ <summary>Whether to hibernate, suspend or do nothing when inactive</summary>
+ <description>The type of sleeping that should be performed when a server is inactive. A server is defined by hostnamed chassis-type.</description>
+ </key>
<key name="sleep-inactive-battery-timeout" type="i">
<default>900</default>
<summary>Sleep timeout computer when on battery</summary>
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 268a46cc..2c2d5f8f 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -223,6 +223,9 @@ struct _GsdPowerManager
/* Device Properties */
gboolean show_sleep_warnings;
+
+ /* hostnamed chassis-type */
+ gchar *chassis_type;
};
enum {
@@ -1915,6 +1918,7 @@ idle_configure (GsdPowerManager *manager)
guint timeout_sleep;
guint timeout_dim;
gboolean on_battery;
+ gboolean on_server = FALSE;
if (!idle_is_session_inhibited (manager,
GSM_INHIBITOR_FLAG_IDLE,
@@ -1961,8 +1965,11 @@ idle_configure (GsdPowerManager *manager)
/* only do the sleep timeout when the session is idle
* and we aren't inhibited from sleeping (or logging out, etc.) */
on_battery = up_client_get_on_battery (manager->up_client);
- action_type = g_settings_get_enum (manager->settings, on_battery ?
- "sleep-inactive-battery-type" : "sleep-inactive-ac-type");
+ on_server = g_strcmp0 (manager->chassis_type, "server") == 0;
+ action_type = g_settings_get_enum (manager->settings,
+ /* Read from "sleep-inactive-ac-type-server when hostnamed chassis-type = "server" */
+ on_server ? "sleep-inactive-ac-type-server" :
+ on_battery ? "sleep-inactive-battery-type" : "sleep-inactive-ac-type");
timeout_sleep = 0;
if (!is_action_inhibited (manager, action_type)) {
gint timeout_sleep_;
@@ -3059,7 +3066,6 @@ gboolean
gsd_power_manager_start (GsdPowerManager *manager,
GError **error)
{
- g_autofree char *chassis_type = NULL;
g_debug ("Starting power manager");
gnome_settings_profile_start (NULL);
@@ -3087,8 +3093,7 @@ gsd_power_manager_start (GsdPowerManager *manager,
return FALSE;
}
- chassis_type = gnome_settings_get_chassis_type ();
- if (g_strcmp0 (chassis_type, "tablet") == 0 || g_strcmp0 (chassis_type, "handset") == 0) {
+ if (g_strcmp0 (manager->chassis_type, "tablet") == 0 || g_strcmp0 (manager->chassis_type, "handset") == 0) {
manager->show_sleep_warnings = FALSE;
} else {
manager->show_sleep_warnings = TRUE;
@@ -3182,6 +3187,8 @@ gsd_power_manager_stop (GsdPowerManager *manager)
g_source_remove (manager->xscreensaver_watchdog_timer_id);
manager->xscreensaver_watchdog_timer_id = 0;
}
+
+ g_clear_pointer (&manager->chassis_type, g_free);
}
static void
@@ -3190,6 +3197,8 @@ gsd_power_manager_init (GsdPowerManager *manager)
manager->inhibit_lid_switch_fd = -1;
manager->inhibit_suspend_fd = -1;
manager->cancellable = g_cancellable_new ();
+
+ manager->chassis_type = gnome_settings_get_chassis_type ();
}
/* returns new level */
--
2.45.2

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (gnome-settings-daemon-46.0.tar.xz) = 445e9ee4709af7a67ded55733d4041357995fe9746bcf00fa81f52f6dddc2071e7114e9bf836bcf464bc0f04da3b3c08be04c1942963c1910d1a14b4434f6633