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

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