summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaoimhe <caoimhebyrne06@gmail.com>2023-06-02 23:44:49 +0100
committerAndreas Kling <kling@serenityos.org>2023-06-03 05:52:16 +0200
commit13506a612e61a0455a61c2ec4bb19a43e0df32f4 (patch)
tree6e7f0c6f535abd6578155b47572e15a84a1fe0e5
parent2344bb6c5767bba3c4ab8f2097972acd0f489e33 (diff)
downloadserenity-13506a612e61a0455a61c2ec4bb19a43e0df32f4.zip
SpiceAgent: Don't pledge `cpath` or open SPICE_DEVICE as `rwc`
Core::File's new `DontCreate` open mode removes the need for these capabilities on SpiceAgent. We shouldn't have to create this file, as if it doesn't exist, QEMU never initiated a spice connection!
-rw-r--r--Userland/Services/SpiceAgent/SpiceAgent.cpp2
-rw-r--r--Userland/Services/SpiceAgent/main.cpp7
2 files changed, 3 insertions, 6 deletions
diff --git a/Userland/Services/SpiceAgent/SpiceAgent.cpp b/Userland/Services/SpiceAgent/SpiceAgent.cpp
index ff06168fef..2abbbef4e3 100644
--- a/Userland/Services/SpiceAgent/SpiceAgent.cpp
+++ b/Userland/Services/SpiceAgent/SpiceAgent.cpp
@@ -15,7 +15,7 @@ namespace SpiceAgent {
ErrorOr<NonnullOwnPtr<SpiceAgent>> SpiceAgent::create(StringView device_path)
{
- auto device = TRY(Core::File::open(device_path, Core::File::OpenMode::ReadWrite | Core::File::OpenMode::Nonblocking));
+ auto device = TRY(Core::File::open(device_path, Core::File::OpenMode::ReadWrite | Core::File::OpenMode::DontCreate | Core::File::OpenMode::Nonblocking));
return try_make<SpiceAgent>(move(device), Vector { Capability::ClipboardByDemand });
}
diff --git a/Userland/Services/SpiceAgent/main.cpp b/Userland/Services/SpiceAgent/main.cpp
index bb78cebdb8..111c6b78d3 100644
--- a/Userland/Services/SpiceAgent/main.cpp
+++ b/Userland/Services/SpiceAgent/main.cpp
@@ -26,11 +26,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Desktop::Launcher::add_allowed_url(URL::create_with_file_scheme(Core::StandardPaths::downloads_directory())));
TRY(Desktop::Launcher::seal_allowlist());
- // FIXME: Make Core::File support reading and writing, but without creating:
- // By default, Core::File opens the file descriptor with O_CREAT when using OpenMode::Write (and subsequently, OpenMode::ReadWrite).
- // To minimise confusion for people that have already used Core::File, we can probably just do `OpenMode::ReadWrite | OpenMode::DontCreate`.
- TRY(Core::System::pledge("unix rpath wpath stdio sendfd recvfd cpath"));
- TRY(Core::System::unveil(SPICE_DEVICE, "rwc"sv));
+ TRY(Core::System::pledge("unix rpath wpath stdio sendfd recvfd"));
+ TRY(Core::System::unveil(SPICE_DEVICE, "rw"sv));
TRY(Core::System::unveil(Core::StandardPaths::downloads_directory(), "rwc"sv));
TRY(Core::System::unveil(nullptr, nullptr));