diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2021-10-05 11:15:16 +0100 |
---|---|---|
committer | Fabiano FidĂȘncio <fabiano@fidencio.org> | 2021-10-10 12:20:08 +0000 |
commit | b9cbac75b62e05c3009179a547c8ce682bd1d79e (patch) | |
tree | 10cee33c30097d4bd0a3d220f758dba9f27dde06 | |
parent | 86c10477b360274fc60047d6cd582e1e2dfb3d20 (diff) | |
download | libosinfo-b9cbac75b62e05c3009179a547c8ce682bd1d79e.tar.gz |
Fix hiding of database entries
The osinfo-db documentation says that a local admin/user can hide an
entity from the system location:
[quote]
If the file is zero-length or points to /dev/null, then this
represents a black-out override. This indicates that the
ENTITY-NAME.xml file from a lower priority directory MUST NOT
be loaded.
[/quote]
This does not, however, work at all. If a zero length file is given,
it tries to parse this as XML and fails, causing the entire DB loading
process to be aborted. This leaves the DB with dangling references.
If a symlink to /dev/null is given, it is entirely ignored because
the file is a block device and we only try to load regular files.
Instead of only loading regular files, we need to load any type of
file that has a .xml extension.
This appears to be broken since the very first impl of the new DB
loading process, despite having written the spec at the same time.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rw-r--r-- | osinfo/osinfo_loader.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index feff650..9ec99cd 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -2176,6 +2176,8 @@ osinfo_loader_process_file_reg_xml(OsinfoLoader *loader, if (error_is_set(err)) return; + if (xmlLen == 0) + return; if (base) { relpath = g_file_get_relative_path(base, file); if (relpath == NULL) { @@ -2346,11 +2348,10 @@ static void osinfo_loader_find_files(OsinfoLoader *loader, ent = g_file_get_child(file, name); type = g_file_info_get_attribute_uint32(info, G_FILE_ATTRIBUTE_STANDARD_TYPE); - if (type == G_FILE_TYPE_REGULAR) { - if (g_str_has_suffix(name, ".xml")) - osinfo_loader_entity_files_add_path(entries, base, ent); - } else if (type == G_FILE_TYPE_DIRECTORY) { + if (type == G_FILE_TYPE_DIRECTORY) { osinfo_loader_find_files(loader, base, ent, entries, FALSE, &error); + } else if (g_str_has_suffix(name, ".xml")) { + osinfo_loader_entity_files_add_path(entries, base, ent); } g_object_unref(ent); g_object_unref(info); |