Blame SOURCES/0001-loader-add-check-for-unknown-file-type.patch

9a58d4
From d3b1587f7b77b630bae8ab3f4760eda69bd7fe66 Mon Sep 17 00:00:00 2001
9a58d4
From: Victor Toso <victortoso@redhat.com>
9a58d4
Date: Fri, 26 Nov 2021 17:36:09 +0100
9a58d4
Subject: [PATCH] loader: add check for unknown file type
9a58d4
9a58d4
So we can provide a meaningful error message in case the provided path
9a58d4
is not accessible to running process.
9a58d4
9a58d4
e.g: running HOME=/root osinfo-query os we would get
9a58d4
  `Error loading OS data: Unexpected file type`
9a58d4
and now we get
9a58d4
  `Error loading OS data: Can't read path /root/.config/osinfo`
9a58d4
9a58d4
This error was first hit with v2v [0] that was leaking $USER and $HOME
9a58d4
of root user when osinfo-query as vsdm user with `sudo -c vdsm`. The
9a58d4
example above is a simple way to show lack of permision of
9a58d4
osinfo-query to read the root's $HOME.
9a58d4
9a58d4
[0] https://bugzilla.redhat.com/show_bug.cgi?id=1901423
9a58d4
9a58d4
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1902720
9a58d4
Signed-off-by: Victor Toso <victortoso@redhat.com>
9a58d4
---
9a58d4
 osinfo/osinfo_loader.c | 5 +++++
9a58d4
 1 file changed, 5 insertions(+)
9a58d4
9a58d4
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
9a58d4
index 3f04fa5..96ca6ee 100644
9a58d4
--- a/osinfo/osinfo_loader.c
9a58d4
+++ b/osinfo/osinfo_loader.c
9a58d4
@@ -2374,6 +2374,11 @@ static void osinfo_loader_find_files(OsinfoLoader *loader,
9a58d4
         }
9a58d4
         g_object_unref(ents);
9a58d4
         g_list_free(children);
9a58d4
+    } else if (type == G_FILE_TYPE_UNKNOWN) {
9a58d4
+        g_autofree gchar *path = g_file_get_path(file);
9a58d4
+        g_autofree gchar *msg = g_strdup_printf("Can't read path %s", path);
9a58d4
+        OSINFO_LOADER_SET_ERROR(&error, msg);
9a58d4
+        g_propagate_error(err, error);
9a58d4
     } else {
9a58d4
         OSINFO_LOADER_SET_ERROR(&error, "Unexpected file type");
9a58d4
         g_propagate_error(err, error);
9a58d4
-- 
9a58d4
2.33.1
9a58d4