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