From e3e22cd42e92e2044f29aacd8ad6c73585ef6633 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Thu, 23 Jan 2020 00:42:50 -0800 Subject: [PATCH] lspci: Use pledge() and unveil() --- Userland/lspci.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Userland/lspci.cpp b/Userland/lspci.cpp index a348343169..8800a887e5 100644 --- a/Userland/lspci.cpp +++ b/Userland/lspci.cpp @@ -36,6 +36,23 @@ int main(int argc, char** argv) UNUSED_PARAM(argc); UNUSED_PARAM(argv); + if (pledge("stdio rpath", nullptr) < 0) { + perror("pledge"); + return 1; + } + + if (unveil("/res/pci.ids", "r") < 0) { + perror("unveil"); + return 1; + } + + if (unveil("/proc/pci", "r") < 0) { + perror("unveil"); + return 1; + } + + unveil(nullptr, nullptr); + auto db = PCIDB::Database::open(); if (!db) fprintf(stderr, "Couldn't open PCI ID database\n"); @@ -46,6 +63,11 @@ int main(int argc, char** argv) return 1; } + if (pledge("stdio", nullptr) < 0) { + perror("pledge"); + return 1; + } + auto file_contents = proc_pci->read_all(); auto json = JsonValue::from_string(file_contents).as_array(); json.for_each([db](auto& value) {