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