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

Applications: Use pledge and unveil

This commit is contained in:
Brendan Coles 2020-11-02 21:34:29 +00:00 committed by Andreas Kling
parent 9efcb5d290
commit ed5469c1c2
5 changed files with 84 additions and 7 deletions

View file

@ -26,6 +26,7 @@
#include "IRCAppWindow.h" #include "IRCAppWindow.h"
#include "IRCClient.h" #include "IRCClient.h"
#include <LibCore/StandardPaths.h>
#include <LibGUI/Application.h> #include <LibGUI/Application.h>
#include <LibGUI/MessageBox.h> #include <LibGUI/MessageBox.h>
#include <stdio.h> #include <stdio.h>
@ -49,6 +50,36 @@ int main(int argc, char** argv)
return 1; return 1;
} }
if (unveil("/tmp/portal/lookup", "rw") < 0) {
perror("unveil");
return 1;
}
if (unveil("/tmp/portal/notify", "rw") < 0) {
perror("unveil");
return 1;
}
if (unveil("/etc/passwd", "r") < 0) {
perror("unveil");
return 1;
}
if (unveil(Core::StandardPaths::home_directory().characters(), "rwc") < 0) {
perror("unveil");
return 1;
}
if (unveil("/res", "r") < 0) {
perror("unveil");
return 1;
}
if (unveil(nullptr, nullptr) < 0) {
perror("unveil");
return 1;
}
URL url = ""; URL url = "";
if (app->args().size() >= 1) { if (app->args().size() >= 1) {
url = URL::create_with_url_or_path(app->args()[0]); url = URL::create_with_url_or_path(app->args()[0]);

View file

@ -41,8 +41,18 @@ int main(int argc, char** argv)
args_parser.add_positional_argument(path, "Keyboard character mapping file.", "file", Core::ArgsParser::Required::No); args_parser.add_positional_argument(path, "Keyboard character mapping file.", "file", Core::ArgsParser::Required::No);
args_parser.parse(argc, argv); args_parser.parse(argc, argv);
if (pledge("stdio thread rpath accept cpath wpath shared_buffer unix fattr", nullptr) < 0) {
perror("pledge");
return 1;
}
auto app = GUI::Application::construct(argc, argv); auto app = GUI::Application::construct(argc, argv);
if (pledge("stdio thread rpath accept cpath wpath shared_buffer", nullptr) < 0) {
perror("pledge");
return 1;
}
auto app_icon = GUI::Icon::default_icon("app-keyboard-mapper"); auto app_icon = GUI::Icon::default_icon("app-keyboard-mapper");
auto window = GUI::Window::construct(); auto window = GUI::Window::construct();

View file

@ -45,8 +45,18 @@
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
if (pledge("stdio thread rpath accept cpath wpath shared_buffer unix fattr", nullptr) < 0) {
perror("pledge");
return 1;
}
auto app = GUI::Application::construct(argc, argv); auto app = GUI::Application::construct(argc, argv);
if (pledge("stdio thread rpath accept cpath wpath shared_buffer unix", nullptr) < 0) {
perror("pledge");
return 1;
}
auto audio_client = Audio::ClientConnection::construct(); auto audio_client = Audio::ClientConnection::construct();
audio_client->handshake(); audio_client->handshake();

View file

@ -40,6 +40,18 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
if (pledge("stdio shared_buffer accept rpath unix cpath wpath fattr thread", nullptr) < 0) {
perror("pledge");
return 1;
}
auto app = GUI::Application::construct(argc, argv);
if (pledge("stdio thread rpath accept cpath wpath shared_buffer unix", nullptr) < 0) {
perror("pledge");
return 1;
}
const char* filename = nullptr; const char* filename = nullptr;
Core::ArgsParser args_parser; Core::ArgsParser args_parser;
@ -54,13 +66,6 @@ int main(int argc, char* argv[])
} }
} }
auto app = GUI::Application::construct(argc, argv);
if (pledge("stdio thread rpath accept cpath wpath shared_buffer unix", nullptr) < 0) {
perror("pledge");
return 1;
}
if (unveil("/tmp/portal/webcontent", "rw") < 0) { if (unveil("/tmp/portal/webcontent", "rw") < 0) {
perror("unveil"); perror("unveil");
return 1; return 1;

View file

@ -66,8 +66,29 @@ private:
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
if (pledge("stdio thread rpath accept cpath wpath shared_buffer unix fattr", nullptr) < 0) {
perror("pledge");
return 1;
}
auto app = GUI::Application::construct(argc, argv); auto app = GUI::Application::construct(argc, argv);
if (pledge("stdio thread rpath accept shared_buffer", nullptr) < 0) {
perror("pledge");
return 1;
}
if (unveil("/res", "r") < 0) {
perror("unveil");
return 1;
}
if (unveil(nullptr, nullptr) < 0) {
perror("unveil");
return 1;
}
auto app_icon = GUI::Icon::default_icon("app-theme-editor"); auto app_icon = GUI::Icon::default_icon("app-theme-editor");
Gfx::Palette preview_palette = app->palette(); Gfx::Palette preview_palette = app->palette();