1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:47:44 +00:00

Utilities/lspci: Don't unveil /res/pci.ids if not asked to resolve IDs

I tested the grub image under VirtualBox and it appeared that the image
didn't have pci.ids file included in the /res directory. In that case it
would be expected that lspci can still function correctly if the -n
parameter is passed, but then the unveil syscall failed because the file
didn't exist.

To cope with this, we should allow lspci to work without the pci.ids
file being present at the filesystem, so let's not unveil this file if
the -n parameter is passed.
This commit is contained in:
Liav A 2022-07-15 14:30:39 +03:00 committed by Linus Groh
parent a857b6297a
commit cb900006b9
2 changed files with 10 additions and 3 deletions

View file

@ -45,9 +45,6 @@ static u32 convert_sysfs_value_to_uint(String const& value)
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath"));
TRY(Core::System::unveil("/res/pci.ids", "r"));
TRY(Core::System::unveil("/sys/bus/pci", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
Core::ArgsParser args_parser;
args_parser.set_general_help("List PCI devices.");
@ -55,6 +52,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_option(flag_verbose, "Show verbose info on devices", "verbose", 'v');
args_parser.parse(arguments);
if (!flag_show_numerical)
TRY(Core::System::unveil("/res/pci.ids", "r"));
TRY(Core::System::unveil("/sys/bus/pci", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto const format = flag_show_numerical ? format_numerical : format_textual;
RefPtr<PCIDB::Database> db;