Compare commits
No commits in common. 'i8c' and 'c9' have entirely different histories.
@ -0,0 +1,35 @@
|
||||
From e8ea9f09f4ec718c42b1909e21369a9487ed5f4b Mon Sep 17 00:00:00 2001
|
||||
From: Jaroslav Mracek <jmracek@redhat.com>
|
||||
Date: Tue, 13 Nov 2018 18:31:57 +0100
|
||||
Subject: [PATCH 1/4] Replace bool option with int to generate repo files
|
||||
|
||||
During the testing of subscription manager it was discovered that
|
||||
subscription manager detects disabled repository by test if key
|
||||
"enabled == 0". It means that enabled=false was detected as enabled
|
||||
repository. I know that the issue is in subscription manager, but
|
||||
keeping the patch is not harmful because the 0/1 is also valid
|
||||
combination like false/true.
|
||||
---
|
||||
rhsm/rhsm-utils.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/rhsm/rhsm-utils.c b/rhsm/rhsm-utils.c
|
||||
index 7b6a26b305515c53e10b9cecb9f95b2e9d84ad02..06b12fca7fe366f42f0daa1e77c275c3a8e9375c 100644
|
||||
--- a/rhsm/rhsm-utils.c
|
||||
+++ b/rhsm/rhsm-utils.c
|
||||
@@ -260,11 +260,11 @@ rhsm_utils_yum_repo_from_context (RHSMContext *ctx)
|
||||
}
|
||||
|
||||
g_autofree gchar *baseurl = g_strconcat (ctx_baseurl, path, NULL);
|
||||
g_key_file_set_string (repofile, id, "name", name);
|
||||
g_key_file_set_string (repofile, id, "baseurl", baseurl);
|
||||
- g_key_file_set_boolean (repofile, id, "enabled", enabled);
|
||||
+ g_key_file_set_integer (repofile, id, "enabled", enabled ? 1 : 0);
|
||||
|
||||
if (json_object_has_member (repo, "gpg_url"))
|
||||
{
|
||||
const gchar *gpg_url = json_object_get_string_member (repo, "gpg_url");
|
||||
g_key_file_set_string (repofile, id, "gpgkey", gpg_url);
|
||||
--
|
||||
2.26.2
|
||||
|
@ -0,0 +1,113 @@
|
||||
From 09f9b923f04a8276252fcfbc4f502be49df483c6 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
||||
Date: Fri, 27 Oct 2023 15:34:16 +0200
|
||||
Subject: [PATCH] Fix relocating certificate paths to /etc/rhsm-host
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
If /etc/rhsm-host directory exists, librhsm corrects CA certificate
|
||||
location (rhsm_context_get_ca_cert_dir()) and YUM repository CA
|
||||
certificate location (rhsm_context_get_repo_ca_cert()) from /etc/rhsm
|
||||
to /etc/rhsm-host prefix.
|
||||
|
||||
However, there was a bug in the path relocation and, as a result, the
|
||||
locations were mangled to a wrong /etc/rhsm-host-host prefix.
|
||||
|
||||
This patch fixes the relocation algorithm to consider boundaries
|
||||
between the path components.
|
||||
|
||||
Note that the relocation was and still is applied not only to default
|
||||
values, but also to values loaded from a configuration file. That's
|
||||
probably on purpose to ease sharing the configuration among a host and
|
||||
the containers.
|
||||
|
||||
https://github.com/rpm-software-management/librhsm/issues/9
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
rhsm/rhsm-context.c | 61 ++++++++++++++++++++++++++++++++++++++++++---
|
||||
1 file changed, 58 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/rhsm/rhsm-context.c b/rhsm/rhsm-context.c
|
||||
index 311dcdd..e0302fd 100644
|
||||
--- a/rhsm/rhsm-context.c
|
||||
+++ b/rhsm/rhsm-context.c
|
||||
@@ -482,6 +482,61 @@ rhsm_context_set_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * path_has_prefix:
|
||||
+ * @path: pointer to a null-terminated path string.
|
||||
+ * @prefix: pointer to a null-terminated path prefix without a trailing slash.
|
||||
+ *
|
||||
+ * Returns: TRUE if the @prefix is a base path of the @path. FALSE otherwise.
|
||||
+ */
|
||||
+
|
||||
+static gboolean
|
||||
+path_has_prefix (const gchar *path, const gchar *prefix)
|
||||
+{
|
||||
+ if (!path || !prefix)
|
||||
+ {
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ {
|
||||
+ const size_t prefix_length = strlen (prefix);
|
||||
+ return (!strncmp (path, prefix, prefix_length) &&
|
||||
+ (G_IS_DIR_SEPARATOR (path [prefix_length]) || path [prefix_length] == '\0'));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * relocate_path:
|
||||
+ * @path: (inout): pointer to a null-terminated string.
|
||||
+ * @old_prefix: null-terminated path prefix without a trailing slash to relocate from.
|
||||
+ * @new_prefix: null-terminated path prefix without a trailing slash to relocate to.
|
||||
+ *
|
||||
+ * If @path starts with @old_prefix path components, the @old_prefix path
|
||||
+ * components will be replaced with @new_prefix.
|
||||
+ *
|
||||
+ * Returns: (transfer none): null-terminated string with the relocated path.
|
||||
+ */
|
||||
+static gchar *
|
||||
+relocate_path (gchar **path, const gchar *old_prefix, const gchar *new_prefix)
|
||||
+{
|
||||
+ if (!path || !*path || !old_prefix || !new_prefix)
|
||||
+ {
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (path_has_prefix (*path, old_prefix))
|
||||
+ {
|
||||
+ const size_t old_prefix_length = strlen (old_prefix);
|
||||
+ GString *tmp = g_string_sized_new (strlen (*path) - old_prefix_length + strlen (new_prefix));
|
||||
+ g_string_append (tmp, new_prefix);
|
||||
+ g_string_append (tmp, *path + old_prefix_length);
|
||||
+
|
||||
+ g_free (*path);
|
||||
+ *path = g_string_free (tmp, FALSE);
|
||||
+ }
|
||||
+
|
||||
+ return *path;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
rhsm_context_constructed (GObject *object)
|
||||
{
|
||||
@@ -539,10 +594,10 @@ rhsm_context_constructed (GObject *object)
|
||||
}
|
||||
|
||||
/* If we have conf coming from /etc/rhsm-host, most probably we need to replace /etc/rhsm */
|
||||
- if (g_str_has_prefix (ctx->conf_file, CONFIG_DIR_HOST))
|
||||
+ if (path_has_prefix (ctx->conf_file, CONFIG_DIR_HOST))
|
||||
{
|
||||
- rhsm_utils_str_replace (&ctx->ca_cert_dir, CONFIG_DIR, CONFIG_DIR_HOST);
|
||||
- rhsm_utils_str_replace (&ctx->repo_ca_cert, CONFIG_DIR, CONFIG_DIR_HOST);
|
||||
+ relocate_path (&ctx->ca_cert_dir, CONFIG_DIR, CONFIG_DIR_HOST);
|
||||
+ relocate_path (&ctx->repo_ca_cert, CONFIG_DIR, CONFIG_DIR_HOST);
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.41.0
|
||||
|
Loading…
Reference in new issue