summaryrefslogtreecommitdiff
path: root/osinfo
Commit message (Collapse)AuthorAgeFilesLines
* install-script: Fix "trough" typo in docstringsWill Thompson2023-02-151-4/+4
| | | | | | | A trough is a long, narrow container, open on top, for feeding or watering animals. Signed-off-by: Will Thompson <wjt@endlessos.org>
* DRY meson build scriptDan Church2022-08-221-5/+7
| | | | | | | | Introduce versioned_name = 'libosinfo-1.0' No functional change other than getting rid of the repetition. Signed-off-by: Dan Church <amphetamachine@gmail.com>
* build: only include header file in the declared libosinfo depDaniel Kolesa2022-03-271-1/+1
| | | | | | | | | This prevents compiling a separate copy of the enums .c file into anything using the libosinfo_dep target. Doing so would result in types occasionally getting registered twice, at least when libosinfo is built with Clang. Signed-off-by: Daniel Kolesa <daniel@octaforge.org>
* build: remove unused enum template filesDaniel Kolesa2022-03-272-60/+0
| | | | | | | | | | These are not used as Meson uses its own builtin ones in the gnome module, so they were just left over. They were also incorrect as G_GNUC_CONST on _get_type would break things (_get_type functions have side effects here). Signed-off-by: Daniel Kolesa <daniel@octaforge.org>
* media: Fix leak of GList *Victor Toso2022-02-151-0/+1
| | | | | | | | | | | | | | | | Found by covscan. 6. libosinfo-1.9.0/osinfo/osinfo_media.c:1675: alloc_fn: Storage is returned from allocation function "osinfo_entity_get_param_value_list". 7. libosinfo-1.9.0/osinfo/osinfo_media.c:1675: var_assign: Assigning: "ids" = storage returned from "osinfo_entity_get_param_value_list(OSINFO_ENTITY(media), "variant")". 8. libosinfo-1.9.0/osinfo/osinfo_media.c:1679: var_assign: Assigning: "node" = "ids". 12. libosinfo-1.9.0/osinfo/osinfo_media.c:1690: leaked_storage: Variable "ids" going out of scope leaks the storage it points to. # 1688| g_object_unref(os_variants); # 1689| # 1690|-> return media_variants; # 1691| } # 1692| Signed-off-by: Victor Toso <victortoso@redhat.com>
* install-script: Fix leak of GList *Victor Toso2022-02-151-2/+1
| | | | | | | | | | | | | | | Found by covscan. 14. libosinfo-1.9.0/osinfo/osinfo_install_script.c:832: leaked_storage: Variable "values" going out of scope leaks the storage it points to. # 830| propagate_libxml_error(error, _("Unable to create XML node '%s'"), # 831| (const gchar *)tmp1->data); # 832|-> goto error; # 833| } # 834| if (!(xmlAddChild(node, data))) { Signed-off-by: Victor Toso <victortoso@redhat.com>
* tree: Fix small leak of char *Victor Toso2022-02-151-0/+1
| | | | | | | | | | | | | | | | | | ==422112== 15 bytes in 1 blocks are definitely lost in loss record 216 of 2,333 ==422112== at 0x484486F: malloc (vg_replace_malloc.c:381) ==422112== by 0x4AEE9AF: __vasprintf_internal (vasprintf.c:71) ==422112== by 0x49B3812: g_vasprintf (in /usr/lib64/libglib-2.0.so.0.7000.3) ==422112== by 0x4989830: g_strdup_vprintf (in /usr/lib64/libglib-2.0.so.0.7000.3) ==422112== by 0x49898EC: g_strdup_printf (in /usr/lib64/libglib-2.0.so.0.7000.3) ==422112== by 0x488173F: load_keyinfo (osinfo_tree.c:597) ==422112== by 0x4032B2: test_create_from_treeinfo (test-tree.c:93) ==422112== by 0x4992BD5: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==422112== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==422112== by 0x49930A9: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7000.3) ==422112== by 0x49930D0: g_test_run (in /usr/lib64/libglib-2.0.so.0.7000.3) ==422112== by 0x402449: main (test-tree.c:206) Signed-off-by: Victor Toso <victortoso@redhat.com>
* tree: Fix leaks in osinfo_tree_get_os_variants()Victor Toso2022-02-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Leak of OsinfoFilter * ==420790== 343 (40 direct, 303 indirect) bytes in 1 blocks are definitely lost in loss record 2,302 of 2,343 ==420790== at 0x48F3437: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420790== by 0x48DAD4C: ??? (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420790== by 0x48DBD1C: g_object_new_with_properties (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420790== by 0x48DC820: g_object_new (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==420790== by 0x4882C2D: osinfo_tree_get_os_variants (osinfo_tree.c:1147) ==420790== by 0x402C0A: test_os_variants (test-tree.c:57) ==420790== by 0x4992BD5: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420790== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420790== by 0x49930A9: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420790== by 0x49930D0: g_test_run (in /usr/lib64/libglib-2.0.so.0.7000.3) ==420790== by 0x402449: main (test-tree.c:206) Leak of GList * ==421621== 24 bytes in 1 blocks are definitely lost in loss record 1,016 of 2,334 ==421621== at 0x484486F: malloc (vg_replace_malloc.c:381) ==421621== by 0x496E3D8: g_malloc (in /usr/lib64/libglib-2.0.so.0.7000.3) ==421621== by 0x4987024: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.7000.3) ==421621== by 0x4963A2A: g_list_copy_deep (in /usr/lib64/libglib-2.0.so.0.7000.3) ==421621== by 0x4882C25: osinfo_tree_get_os_variants (osinfo_tree.c:1145) ==421621== by 0x402C0A: test_os_variants (test-tree.c:57) ==421621== by 0x4992BD5: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==421621== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==421621== by 0x49930A9: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7000.3) ==421621== by 0x49930D0: g_test_run (in /usr/lib64/libglib-2.0.so.0.7000.3) ==421621== by 0x402449: main (test-tree.c:206) Signed-off-by: Victor Toso <victortoso@redhat.com>
* os: Fix leak of a GList *Victor Toso2022-02-151-0/+1
| | | | | | | | | | | | | | | | | | | | Just the cointainer is leaking. ==416264== 48 (24 direct, 24 indirect) bytes in 1 blocks are definitely lost in loss record 1,444 of 2,345 ==416264== at 0x484486F: malloc (vg_replace_malloc.c:381) ==416264== by 0x496E3D8: g_malloc (in /usr/lib64/libglib-2.0.so.0.7000.3) ==416264== by 0x4987024: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.7000.3) ==416264== by 0x495DDA9: g_list_prepend (in /usr/lib64/libglib-2.0.so.0.7000.3) ==416264== by 0x4958418: g_hash_table_get_values (in /usr/lib64/libglib-2.0.so.0.7000.3) ==416264== by 0x487A10F: osinfo_os_get_device_drivers_prioritized (osinfo_os.c:1248) ==416264== by 0x405835: test_device_driver_priority_helper (test-os.c:236) ==416264== by 0x4059E2: test_device_driver_prioritized_priority (test-os.c:267) ==416264== by 0x4992BD5: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==416264== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==416264== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==416264== by 0x49930A9: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7000.3) Signed-off-by: Victor Toso <victortoso@redhat.com>
* db: Fix leak of OsinfoInstallScriptList *Victor Toso2022-02-151-0/+1
| | | | | | | | | | | | | | | | | | | ==404438== 320 (48 direct, 272 indirect) bytes in 1 blocks are definitely lost in loss record 2,563 of 2,686 ==404438== at 0x48F3437: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==404438== by 0x48DAD4C: ??? (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==404438== by 0x48DC2C7: g_object_new_valist (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==404438== by 0x48DC7FC: g_object_new (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==404438== by 0x48763CA: osinfo_list_new_copy (osinfo_list.c:458) ==404438== by 0x487F24E: osinfo_media_get_install_script_list (osinfo_media.c:1841) ==404438== by 0x488690C: fill_media (osinfo_db.c:773) ==404438== by 0x488690C: osinfo_db_identify_media (osinfo_db.c:826) ==404438== by 0x406716: test_identify_media (test-db.c:502) ==404438== by 0x4992BD5: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==404438== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==404438== by 0x49930A9: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7000.3) ==404438== by 0x49930D0: g_test_run (in /usr/lib64/libglib-2.0.so.0.7000.3) Signed-off-by: Victor Toso <victortoso@redhat.com>
* image: Fix leaks in osinfo_image_get_os_variants()Victor Toso2022-02-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ==382381== 48 bytes in 2 blocks are definitely lost in loss record 1,441 of 2,342 ==382381== at 0x484486F: malloc (vg_replace_malloc.c:381) ==382381== by 0x496E3D8: g_malloc (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382381== by 0x4987024: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382381== by 0x4963A2A: g_list_copy_deep (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382381== by 0x4883EE5: osinfo_image_get_os_variants (osinfo_image.c:353) ==382381== by 0x402C6A: test_loaded (test-image.c:74) ==382381== by 0x4992BD5: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382381== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382381== by 0x49930A9: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382381== by 0x49930D0: g_test_run (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382381== by 0x402386: main (test-image.c:114) ==382381== ==382381== 686 (80 direct, 606 indirect) bytes in 2 blocks are definitely lost in loss record 2,316 of 2,342 ==382381== at 0x48F3437: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==382381== by 0x48DAD4C: ??? (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==382381== by 0x48DBD1C: g_object_new_with_properties (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==382381== by 0x48DC820: g_object_new (in /usr/lib64/libgobject-2.0.so.0.7000.3) ==382381== by 0x4883EED: osinfo_image_get_os_variants (osinfo_image.c:355) ==382381== by 0x402C6A: test_loaded (test-image.c:74) ==382381== by 0x4992BD5: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382381== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382381== by 0x49930A9: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382381== by 0x49930D0: g_test_run (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382381== by 0x402386: main (test-image.c:114) Signed-off-by: Victor Toso <victortoso@redhat.com>
* loader: clear pointer before using itVictor Toso2022-02-151-20/+14
| | | | | | | | | osinfo_loader_nodeset() expects xmlNodePtr ** to be NULL and it will set it to NULL if not already set. This can lead to memory leaks as seen in previous commit. Let's clear the pointer instead and add a guard to clarify the parameter's expectations. Signed-off-by: Victor Toso <victortoso@redhat.com>
* loader: Fix leak of xmlNodePtr *Victor Toso2022-02-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The pointer is used as output parameter of osinfo_loader_nodeset() which sets it to NULL before using it. The caller should free its contents before reusing it. ==382836== 104 bytes in 8 blocks are definitely lost in loss record 2,097 of 2,333 ==382836== at 0x4849464: calloc (vg_replace_malloc.c:1328) ==382836== by 0x496E510: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382836== by 0x4888DD7: osinfo_loader_nodeset (osinfo_loader.c:237) ==382836== by 0x488A98E: osinfo_loader_os (osinfo_loader.c:1661) ==382836== by 0x488A98E: osinfo_loader_root (osinfo_loader.c:1884) ==382836== by 0x488A98E: osinfo_loader_process_xml (osinfo_loader.c:1973) ==382836== by 0x488A98E: osinfo_loader_process_file_reg_xml (osinfo_loader.c:2182) ==382836== by 0x488D07A: osinfo_loader_process_list (osinfo_loader.c:2515) ==382836== by 0x488D27F: osinfo_loader_process_path (osinfo_loader.c:2587) ==382836== by 0x402A61: test_loaded (test-image.c:59) ==382836== by 0x4992BD5: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382836== by 0x49928FA: ??? (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382836== by 0x49930A9: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382836== by 0x49930D0: g_test_run (in /usr/lib64/libglib-2.0.so.0.7000.3) ==382836== by 0x402386: main (test-image.c:114) Signed-off-by: Victor Toso <victortoso@redhat.com>
* loader: work around lstat()/EACCES regression in _g_local_file_info_get()Laszlo Ersek2022-02-111-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In glib commit 71e7b5800a31 ("Handle MLS selinux policy better", 2010-07-08), which was made for <https://bugzilla.gnome.org/show_bug.cgi?id=623692>, an lstat() failure with error code EACCES was *masked* in function _g_local_file_info_get(). Consequently, if osinfo_loader_find_files() calls g_file_query_info() on a file that is inaccessible due to (e.g.) a missing "x" (search) permission on a leading directory, then g_file_query_info() succeeds, our "skipMissing" branch is dead, g_file_info_get_attribute_uint32() is reached, and it returns G_FILE_TYPE_UNKNOWN. As a consequence, the outer osinfo_loader_process_default_path() function can fail, even though it passes skipMissing=TRUE to osinfo_loader_process_list(). Example: > $ HOME=/root \ > OSINFO_SYSTEM_DIR=/usr/share/osinfo \ > build/tools/osinfo-query os > Error loading OS data: Can't read path /root/.config/osinfo Arguably, this situation should be handled by simply skipping the inaccessible path, as if all leading directories could be searched, and only the last pathname compontent (the filename entry) didn't exist in its direct parent directory. The glib regression was reported in 2017: https://bugzilla.gnome.org/show_bug.cgi?id=777187 and then migrated to gitlab: https://gitlab.gnome.org/GNOME/glib/-/issues/1237 but it's still not solved today. Work around the issue by honoring "skipMissing" on the G_FILE_TYPE_UNKNOWN branch. Demonstration: > $ HOME=/root \ > OSINFO_SYSTEM_DIR=/usr/share/osinfo \ > build/tools/osinfo-query os > > ** (osinfo-query:9924): WARNING **: 13:23:12.776: Can't read path /root/.config/osinfo > Short ID | Name | Version | ID > ----------------+------------------+---------+---------------------------------------- > alpinelinux3.5 | Alpine Linux 3.5 | 3.5 | http://alpinelinux.org/alpinelinux/3.5 > ... Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2051559 Signed-off-by: Laszlo Ersek <lersek@redhat.com>
* osinfo: add API for resolving multiple tree matchesDaniel P. Berrangé2022-02-043-0/+39
| | | | | | | | A provided tree object might match multiple entries from the database. Add an API that allows for this possibility to let applications decide how to handle it. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* osinfo: add API for resolving multiple media matchesDaniel P. Berrangé2022-02-043-0/+39
| | | | | | | | A provided media object might match multiple entries from the database. Add an API that allows for this possibility to let applications decide how to handle it. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* osinfo: allow tree matching code to report multiple entriesDaniel P. Berrangé2022-02-041-11/+59
| | | | | | | | | Refactor the tree matching code so that it can be told to return all matching entries, rather than only the first. The original behaviour can be requested to short-circuit matching if the caller only requires the first match. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* osinfo: allow media matching code to report multiple entriesDaniel P. Berrangé2022-02-041-12/+61
| | | | | | | | | Refactor the media matching code so that it can be told to return all matching entries, rather than only the first. The original behaviour can be requested to short-circuit matching if the caller only requires the first match. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* osinfo: honour tree architecture when matchingDaniel P. Berrangé2022-02-041-4/+10
| | | | | | | | | | | The tree matching code currently ignores the tree architecture which is generally ok, since osinfo_tree_create_from_location will leave it set to NULL. None the less, if an architecture is provided for the unknown tree, we should only return results that match this architecture. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* osinfo: honour media architecture when matchingDaniel P. Berrangé2022-02-041-4/+10
| | | | | | | | | | | The media matching code currently ignores the media architecture which is generally ok, since osinfo_media_create_from_location will leave it set to NULL. None the less, if an architecture is provided for the unknown media, we should only return results that match this architecture. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* guests: use a OsinfoTreeList when detecting tree matchesDaniel P. Berrangé2022-02-041-17/+15
| | | | | | | In preparation for returning multiple tree matches, pass a OsinfoTreeList object around. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* osinfo: don't set the 'os' property on matched treeDaniel P. Berrangé2022-02-041-1/+0
| | | | | | | We just got the OsinfoTee list from the OsinfoOs object, thus we know that it already has the 'os' property set. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* guests: use a OsinfoMediaList when detecting media matchesDaniel P. Berrangé2022-02-041-13/+20
| | | | | | | In preparation for returning multiple media matches, pass a OsinfoMediaList object around. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* osinfo: refactor tree guessing internal helperDaniel P. Berrangé2022-02-041-13/+23
| | | | | | | | We want the return value from the tree guessing helper to indicate whether any matches were used, and have the OsinfoOs as an output parameter which can now be optional. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* osinfo: refactor media guessing internal helperDaniel P. Berrangé2022-02-041-13/+23
| | | | | | | | We want the return value from the media guessing helper to indicate whether any matches were used, and have the OsinfoOs as an output parameter which can now be optional. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* osinfo: pull tree matching logic into public APIDaniel P. Berrangé2022-02-044-25/+47
| | | | | | | | The logic for matching an unidentified tree against a reference tree is potentially useful to applications and should be part of a public API, rather than hidden. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* osinfo: pull media matching logic into public APIDaniel P. Berrangé2022-02-044-31/+57
| | | | | | | | The logic for matching an unidentified media against a reference media is potentially useful to applications and should be part of a public API, rather than hidden. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* osinfo: add missing line break between methodsDaniel P. Berrangé2022-02-041-0/+1
| | | | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* osinfo: use consistent include syntax for public headersDaniel P. Berrangé2022-01-1836-36/+36
| | | | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* osinfo: switch to '#pragma once'Daniel P. Berrangé2022-01-1850-514/+361
| | | | | | | | | | | | | | | | The current include files use the pattern #ifndef __OOSINFO_BLAH_H__ # define __OOSINFO_BLAH_H__ #endif /* __OOSINFO_BLAH_H__ */ Since we already mandated GCC + CLang, we can replace this with a simpler incantation #pragma once Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* osinfo: fix bad preprocessor indentationDaniel P. Berrangé2022-01-181-4/+4
| | | | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* loader: add check for unknown file typeVictor Toso2021-11-291-0/+5
| | | | | | | | | | | | | | | | | | | | 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>
* os: Add `_get_complete_firmware_list()`Fabiano Fidêncio2021-11-243-0/+113
| | | | | | | | | | After realising the mistake of only returning **supported** firmwares on `_get_firmware_list()`, let's work that limitation around by adding a new function, `osinfo_os_get_complete_firmware_list()`, which returns the complete list of firmwares, including both supported and unsupported ones. Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
* os: _get_firmware_list() returns supported FWsFabiano Fidêncio2021-11-241-11/+11
| | | | | | | | | | | Let's make sure we document that `_get_firmware_list()` returns **only** supported firmwares, rather than returning **all** the firmwares avaiable for an OS. As part of the documentation change, let's also adapt the internal functions to reflect that. Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
* os: Add missing docs for _add_firmware()Fabiano Fidêncio2021-11-241-0/+9
| | | | | | | osinfo_os_add_firmware() has been added as part of 1.7.0 release but, somehow, its documentation has been missing. Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
* Skip over entity reference checks if loading failedDaniel P. Berrangé2021-10-101-2/+2
| | | | | | | | | | If we fail to parse one of the XML files, we abort loading the database. We then carry on to do an entity reference check which will almost certainly fail due to not having loaded many XML files. We need to skip over the entity reference check on failure to avoid spamming the user with bogus errors. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Warn about unexpected files in the databaseDaniel P. Berrangé2021-10-101-3/+12
| | | | | | | | | | | | | | | | To help remind users that files must end in .xml, warn about any unusually named files. There are a couple of files we should not warn about since we expect them to be present - VERSION - LICENSE The entire 'schema' sub-directory should be ignored. Common editor backups "~" and ".bak" should be ignored. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* Fix hiding of database entriesDaniel P. Berrangé2021-10-101-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* tree, media: Soup.Session.send_async now takes an IO priority argumentFelipe Borges2021-10-062-0/+6
| | | | | | See https://libsoup.org/libsoup-3.0/SoupSession.html#soup-session-send-async Signed-off-by: Felipe Borges <felipeborges@gnome.org>
* tree, media: SoupMessage is a private struct in libsoup3Felipe Borges2021-10-063-7/+12
| | | | | | | | | You can no longer directly access various structs such as SoupMessage. These are now accessed by getters and setters. See https://libsoup.org/libsoup-3.0/ch02.html Signed-off-by: Felipe Borges <felipeborges@gnome.org>
* tree, media: SOUP_SESSION_USER_AGENT isn't defined in libosup3Felipe Borges2021-10-062-2/+2
| | | | | | Let's use the literal "user-agent" instead. Signed-off-by: Felipe Borges <felipeborges@gnome.org>
* build: don't set glib version constraints for g-ir-scannerDaniel P. Berrangé2021-09-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | add_project_arguments() sets flags that apply to all invokations of the C compiler toolchain by meson. On the surface it sounds fine to use this for setting -DGLIB_VERSION_MIN_REQUIRED=VER -DGLIB_VERSION_MAX_ALLOWED=VER as we want all our code to be constrained by these declared glib versions to prevent us accidentally using APIS from newer glib by mistake. A subtle problem was revealed with the arrival of gobject-introspection version 1.70. The g-ir-scanner program auto-generates some glib code for handling introspection, and this generated code uses glib APIs that are newer than our declared version and this triggers compile failures tmp-introspectg6xadxkr/Libosinfo-1.0.c:251:3: error: ‘G_TYPE_FLAG_FINAL’ is deprecated: Not available before 2.70 [-Werror=deprecated-declarations] 251 | if (G_TYPE_IS_FINAL (type)) | ^~ In file included from /usr/include/glib-2.0/gobject/gobject.h:24, from /usr/include/glib-2.0/gobject/gbinding.h:29, from /usr/include/glib-2.0/glib-object.h:22, from tmp-introspectg6xadxkr/Libosinfo-1.0.c:30: /usr/include/glib-2.0/gobject/gtype.h:1050:3: note: declared here 1050 | G_TYPE_FLAG_FINAL GLIB_AVAILABLE_ENUMERATOR_IN_2_70 = (1 << 6) | ^~~~~~~~~~~~~~~~~ tmp-introspectg6xadxkr/Libosinfo-1.0.c:251:13: error: Not available before 2.70 [-Werror] 251 | if (G_TYPE_IS_FINAL (type)) | ^~~~~~~~~~~~~~~~~ This is actually harmless, because systems with an older glib will also have older g-ir-scanner and thus not be using these new APIs. We need to exclude the glib version constraints from code generated by glib tools, and thus means we have to stop using add_project_arguments() and set cflags explicitly on each target. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* install config: Rename a parameterTimm Bäder2021-01-082-4/+4
| | | | | | | 'timezone' is a global variable in time.h, so clang complains about that. Signed-off-by: Timm Bäder <tbaeder@redhat.com>
* loader: Print filename in libxml error stringCole Robinson2020-11-121-3/+11
| | | | | | | | | | This is how libvirt handles it. Would help debugging apparently random failures like these bugs: https://bugzilla.redhat.com/show_bug.cgi?id=1897356 https://bugzilla.redhat.com/show_bug.cgi?id=1651550 Signed-off-by: Cole Robinson <crobinso@redhat.com>
* Fix misspellingsRafael Fontenelle2020-07-287-13/+13
| | | | Signed-off-by: Rafael Fontenelle <rafaelff@gnome.org>
* Add "osinfo_macros.h" to the installed headersFabiano Fidêncio2020-04-151-1/+1
| | | | | | | | | | | | | | As the macros defined there are used in the public headers, this header must be installed, otherwise we'll face errors such as: ``` /home/valabot/gnome3/include/libosinfo-1.0/osinfo/osinfo_entity.h:26:11: fatal error: osinfo/osinfo_macros.h: No such file or directory 26 | # include "osinfo/osinfo_macros.h" | ^~~~~~~~~~~~~~~~~~~~~~~~ ``` Reported-by: Rico Tzschichholz <ricotz@ubuntu.com> Signed-off-by: Rico Tzschichholz <ricotz@ubuntu.com> Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
* osinfo_macros: mark inline functions as UNUSEDRafael Fonseca2020-04-131-5/+5
| | | | | | | | Fixes -Werror=unused-function with clang. See: https://gitlab.gnome.org/GNOME/glib/-/commit/90f93a64f26666b955fdafb56acab54e596f4cc5 Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
* osinfo_macros: auto-cleanup func for module classRafael Fonseca2020-04-131-0/+1
| | | | | | | | | This will allow to manage the ownership of the class when reffing it without having to cast it to GTypeClass. See: https://gitlab.gnome.org/GNOME/glib/-/commit/ab25fa42cc6906df31352877154bb7b07f39552f Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
* productfilter: Check productfilter in _clear_product_constraint{,s}Fabiano Fidêncio2020-04-131-0/+4
| | | | | | | Let's just add a safety check in the _clear_product_constraint() and _clear_product_constraints() functions. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
* devicelinkfilter: Check devicelinkfilter in _get_target_filter()Fabiano Fidêncio2020-04-131-0/+2
| | | | | | Let's just add a safety check in the _get_target_filter() function. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>