add check for unknown file type
(cherry picked from commit 4907cf39127c4a35facc199cb0af3785e098da8a)
This commit is contained in:
parent
a980980643
commit
1bd2f9d9ae
45
backport-add-check-for-unknown-filetype.patch
Normal file
45
backport-add-check-for-unknown-filetype.patch
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
From d3b1587f7b77b630bae8ab3f4760eda69bd7fe66 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Victor Toso <victortoso@redhat.com>
|
||||||
|
Date: Fri, 26 Nov 2021 17:36:09 +0100
|
||||||
|
Subject: [PATCH] loader: add check for unknown file type
|
||||||
|
|
||||||
|
So we can provide a meaningful error message in case the provided path
|
||||||
|
is not accessible to running process.
|
||||||
|
|
||||||
|
e.g: running HOME=/root osinfo-query os we would get
|
||||||
|
`Error loading OS data: Unexpected file type`
|
||||||
|
and now we get
|
||||||
|
`Error loading OS data: Can't read path /root/.config/osinfo`
|
||||||
|
|
||||||
|
This error was first hit with v2v [0] that was leaking $USER and $HOME
|
||||||
|
of root user when osinfo-query as vsdm user with `sudo -c vdsm`. The
|
||||||
|
example above is a simple way to show lack of permision of
|
||||||
|
osinfo-query to read the root's $HOME.
|
||||||
|
|
||||||
|
[0] https://bugzilla.redhat.com/show_bug.cgi?id=1901423
|
||||||
|
|
||||||
|
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1902720
|
||||||
|
Signed-off-by: Victor Toso <victortoso@redhat.com>
|
||||||
|
---
|
||||||
|
osinfo/osinfo_loader.c | 5 +++++
|
||||||
|
1 file changed, 5 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
|
||||||
|
index 972f2a4..4403b75 100644
|
||||||
|
--- a/osinfo/osinfo_loader.c
|
||||||
|
+++ b/osinfo/osinfo_loader.c
|
||||||
|
@@ -2356,6 +2356,11 @@ static void osinfo_loader_find_files(OsinfoLoader *loader,
|
||||||
|
}
|
||||||
|
g_object_unref(ents);
|
||||||
|
g_list_free(children);
|
||||||
|
+ } else if (type == G_FILE_TYPE_UNKNOWN) {
|
||||||
|
+ g_autofree gchar *path = g_file_get_path(file);
|
||||||
|
+ g_autofree gchar *msg = g_strdup_printf("Can't read path %s", path);
|
||||||
|
+ OSINFO_LOADER_SET_ERROR(&error, msg);
|
||||||
|
+ g_propagate_error(err, error);
|
||||||
|
} else {
|
||||||
|
OSINFO_LOADER_SET_ERROR(&error, "Unexpected file type");
|
||||||
|
g_propagate_error(err, error);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: libosinfo
|
Name: libosinfo
|
||||||
Version: 1.8.0
|
Version: 1.8.0
|
||||||
Release: 1
|
Release: 2
|
||||||
Summary: A library for managing OS information for virtualization
|
Summary: A library for managing OS information for virtualization
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
URL: https://libosinfo.org/
|
URL: https://libosinfo.org/
|
||||||
@ -16,7 +16,7 @@ Requires: osinfo-db >= 20180920-1
|
|||||||
|
|
||||||
Patch0001: 0001-db-Force-anchored-patterns-when-matching-regex.patch
|
Patch0001: 0001-db-Force-anchored-patterns-when-matching-regex.patch
|
||||||
Patch6002: fix-build-error-for-CVE-2019-13313.patch
|
Patch6002: fix-build-error-for-CVE-2019-13313.patch
|
||||||
|
Patch6003: backport-add-check-for-unknown-filetype.patch
|
||||||
|
|
||||||
Provides: %{name}-vala
|
Provides: %{name}-vala
|
||||||
Obsoletes: %{name}-vala
|
Obsoletes: %{name}-vala
|
||||||
@ -95,6 +95,8 @@ rm -rf %{buildroot}
|
|||||||
%files lang -f %{name}.lang
|
%files lang -f %{name}.lang
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Jan 26 2022 tianwei <tianwei12@huawei.com> - 1.8.0-2
|
||||||
|
- add check for unknown file type
|
||||||
|
|
||||||
* Tue Feb 2 2021 liudabo <liudabo1@huawei.com> - 1.8.0-1
|
* Tue Feb 2 2021 liudabo <liudabo1@huawei.com> - 1.8.0-1
|
||||||
- upgrade version to 1.8.0
|
- upgrade version to 1.8.0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user