summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lindbom <hi@davidlindbom.se>2022-01-17 19:14:21 +0100
committerAndreas Kling <kling@serenityos.org>2022-01-21 02:00:53 +0100
commit5c74e66f85223c5708a185c98578676c1886b579 (patch)
treea472fd0bab5bde152c300d4fa2465cf54aef28d5
parent2cf02c6f38622f91732b09d6d6f114a05198f077 (diff)
downloadserenity-5c74e66f85223c5708a185c98578676c1886b579.zip
aplay: Add unveil and pledge promises
-rw-r--r--Userland/Utilities/aplay.cpp9
1 files changed, 9 insertions, 0 deletions
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 <LibAudio/Loader.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/EventLoop.h>
+#include <LibCore/System.h>
#include <LibMain/Main.h>
#include <math.h>
#include <stdio.h>
@@ -20,6 +21,8 @@ constexpr size_t LOAD_CHUNK_SIZE = 128 * KiB;
ErrorOr<int> 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<int> 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<int> 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(),