From 5c74e66f85223c5708a185c98578676c1886b579 Mon Sep 17 00:00:00 2001 From: David Lindbom Date: Mon, 17 Jan 2022 19:14:21 +0100 Subject: [PATCH] aplay: Add unveil and pledge promises --- Userland/Utilities/aplay.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Userland/Utilities/aplay.cpp b/Userland/Utilities/aplay.cpp index aea5998ae4..37c82a19e2 100644 --- a/Userland/Utilities/aplay.cpp +++ b/Userland/Utilities/aplay.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -20,6 +21,8 @@ constexpr size_t LOAD_CHUNK_SIZE = 128 * KiB; ErrorOr serenity_main(Main::Arguments arguments) { + TRY(Core::System::pledge("stdio rpath sendfd unix")); + const char* path = nullptr; bool should_loop = false; bool show_sample_progress = false; @@ -30,6 +33,10 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_option(show_sample_progress, "Show playback progress in samples", "sample-progress", 's'); args_parser.parse(arguments); + TRY(Core::System::unveil(Core::File::absolute_path(path), "r")); + TRY(Core::System::unveil("/tmp/portal/audio", "rw")); + TRY(Core::System::unveil(nullptr, nullptr)); + Core::EventLoop loop; auto audio_client = TRY(Audio::ClientConnection::try_create()); @@ -40,6 +47,8 @@ ErrorOr serenity_main(Main::Arguments arguments) } auto loader = maybe_loader.release_value(); + TRY(Core::System::pledge("stdio sendfd")); + outln("\033[34;1m Playing\033[0m: {}", path); outln("\033[34;1m Format\033[0m: {} {} Hz, {}-bit, {}", loader->format_name(),