createrepo_c/SOURCES/0001-Libmagic-to-follow-symlinks-RhBug1776399.patch
2021-09-09 15:44:14 +00:00

61 lines
2.2 KiB
Diff

From 566311457542d08f48507b0ab7bd68cb848594e9 Mon Sep 17 00:00:00 2001
From: Marek Blaha <mblaha@redhat.com>
Date: Fri, 29 Nov 2019 09:47:29 +0100
Subject: [PATCH 1/2] Libmagic to follow symlinks (RhBug:1776399)
If the input metadata file for modifyrepo_c was a symlink the
program failed to detect compression type. This patch instructs
libmagic to follow the symlinks when guessing the mime type.
Let modules.yaml be a symlink:
$ modifyrepo_c ./modules.yaml ./repodata
Cannot open ./modules.yaml: Cannot detect compression type
https://bugzilla.redhat.com/show_bug.cgi?id=1776399
---
src/compression_wrapper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/compression_wrapper.c b/src/compression_wrapper.c
index d04ab24..6fdb8ea 100644
--- a/src/compression_wrapper.c
+++ b/src/compression_wrapper.c
@@ -166,7 +166,7 @@ cr_detect_compression(const char *filename, GError **err)
// No success? Let's get hardcore... (Use magic bytes)
- magic_t myt = magic_open(MAGIC_MIME);
+ magic_t myt = magic_open(MAGIC_MIME | MAGIC_SYMLINK);
if (myt == NULL) {
g_set_error(err, ERR_DOMAIN, CRE_MAGIC,
"magic_open() failed: Cannot allocate the magic cookie");
From b1b849c3bd63424760152981f96031ef578d752c Mon Sep 17 00:00:00 2001
From: Marek Blaha <mblaha@redhat.com>
Date: Fri, 29 Nov 2019 10:53:25 +0100
Subject: [PATCH 2/2] Add shortcut to detect *.yaml files as not compressed
---
src/compression_wrapper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/compression_wrapper.c b/src/compression_wrapper.c
index 6fdb8ea..56d1dc5 100644
--- a/src/compression_wrapper.c
+++ b/src/compression_wrapper.c
@@ -158,12 +158,12 @@ cr_detect_compression(const char *filename, GError **err)
return CR_CW_ZCK_COMPRESSION;
} else if (g_str_has_suffix(filename, ".xml") ||
g_str_has_suffix(filename, ".tar") ||
+ g_str_has_suffix(filename, ".yaml") ||
g_str_has_suffix(filename, ".sqlite"))
{
return CR_CW_NO_COMPRESSION;
}
-
// No success? Let's get hardcore... (Use magic bytes)
magic_t myt = magic_open(MAGIC_MIME | MAGIC_SYMLINK);