mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:57:35 +00:00
Userland et al: Pledge sigaction when needed
* In some cases, we can first call sigaction()/signal(), then *not* pledge sigaction. * In other cases, we pledge sigaction at first, call sigaction()/signal() second, then pledge again, this time without sigaction. * In yet other cases, we keep the sigaction pledge. I suppose these could all be migrated to drop it or not pledge it at all, if somebody is interested in doing that.
This commit is contained in:
parent
cddaeb43d3
commit
4139838a93
9 changed files with 38 additions and 37 deletions
|
@ -173,7 +173,7 @@ void print_help()
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (pledge("stdio proc exec rpath tty", nullptr) < 0) {
|
if (pledge("stdio proc exec rpath tty sigaction", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ static int run_in_windowed_mode(RefPtr<Core::ConfigFile>, String initial_locatio
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (pledge("stdio thread shared_buffer accept unix cpath rpath wpath fattr proc exec", nullptr) < 0) {
|
if (pledge("stdio thread shared_buffer accept unix cpath rpath wpath fattr proc exec sigaction", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal)
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (pledge("stdio tty rpath accept cpath wpath shared_buffer proc exec unix fattr", nullptr) < 0) {
|
if (pledge("stdio tty rpath accept cpath wpath shared_buffer proc exec unix fattr sigaction", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ static void mount_all_filesystems()
|
||||||
|
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
if (pledge("stdio proc exec tty accept unix rpath wpath cpath chown fattr id", nullptr) < 0) {
|
if (pledge("stdio proc exec tty accept unix rpath wpath cpath chown fattr id sigaction", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,13 +32,18 @@
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (pledge("stdio shared_buffer accept proc exec rpath unix cpath fattr", nullptr) < 0) {
|
if (pledge("stdio shared_buffer accept proc exec rpath unix cpath fattr sigaction", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::Application app(argc, argv);
|
GUI::Application app(argc, argv);
|
||||||
|
|
||||||
|
signal(SIGCHLD, [](int signo) {
|
||||||
|
(void)signo;
|
||||||
|
wait(nullptr);
|
||||||
|
});
|
||||||
|
|
||||||
if (pledge("stdio shared_buffer accept proc exec rpath", nullptr) < 0) {
|
if (pledge("stdio shared_buffer accept proc exec rpath", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -47,10 +52,5 @@ int main(int argc, char** argv)
|
||||||
TaskbarWindow window;
|
TaskbarWindow window;
|
||||||
window.show();
|
window.show();
|
||||||
|
|
||||||
signal(SIGCHLD, [](int signo) {
|
|
||||||
(void)signo;
|
|
||||||
wait(nullptr);
|
|
||||||
});
|
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
if (pledge("stdio video thread shared_buffer accept rpath wpath cpath unix proc fattr", nullptr) < 0) {
|
if (pledge("stdio video thread shared_buffer accept rpath wpath cpath unix proc fattr sigaction", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,26 +59,6 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
Core::EventLoop loop;
|
Core::EventLoop loop;
|
||||||
|
|
||||||
if (pledge("stdio rpath wpath cpath proc exec tty accept", nullptr) < 0) {
|
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto shell = Shell::construct();
|
|
||||||
s_shell = shell.ptr();
|
|
||||||
|
|
||||||
editor.initialize();
|
|
||||||
shell->termios = editor.termios();
|
|
||||||
shell->default_termios = editor.default_termios();
|
|
||||||
|
|
||||||
editor.on_display_refresh = [&](auto& editor) {
|
|
||||||
editor.strip_styles();
|
|
||||||
shell->highlight(editor);
|
|
||||||
};
|
|
||||||
editor.on_tab_complete = [&](const Line::Editor& editor) {
|
|
||||||
return shell->complete(editor);
|
|
||||||
};
|
|
||||||
|
|
||||||
signal(SIGINT, [](int) {
|
signal(SIGINT, [](int) {
|
||||||
editor.interrupted();
|
editor.interrupted();
|
||||||
});
|
});
|
||||||
|
@ -107,6 +87,26 @@ int main(int argc, char** argv)
|
||||||
// Ignore SIGTSTP as the shell should not be suspended with ^Z.
|
// Ignore SIGTSTP as the shell should not be suspended with ^Z.
|
||||||
signal(SIGTSTP, [](auto) {});
|
signal(SIGTSTP, [](auto) {});
|
||||||
|
|
||||||
|
if (pledge("stdio rpath wpath cpath proc exec tty accept", nullptr) < 0) {
|
||||||
|
perror("pledge");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto shell = Shell::construct();
|
||||||
|
s_shell = shell.ptr();
|
||||||
|
|
||||||
|
editor.initialize();
|
||||||
|
shell->termios = editor.termios();
|
||||||
|
shell->default_termios = editor.default_termios();
|
||||||
|
|
||||||
|
editor.on_display_refresh = [&](auto& editor) {
|
||||||
|
editor.strip_styles();
|
||||||
|
shell->highlight(editor);
|
||||||
|
};
|
||||||
|
editor.on_tab_complete = [&](const Line::Editor& editor) {
|
||||||
|
return shell->complete(editor);
|
||||||
|
};
|
||||||
|
|
||||||
if (argc > 2 && !strcmp(argv[1], "-c")) {
|
if (argc > 2 && !strcmp(argv[1], "-c")) {
|
||||||
dbgprintf("sh -c '%s'\n", argv[2]);
|
dbgprintf("sh -c '%s'\n", argv[2]);
|
||||||
shell->run_command(argv[2]);
|
shell->run_command(argv[2]);
|
||||||
|
|
|
@ -110,7 +110,7 @@ NonnullOwnPtr<HashMap<void*, X86::Instruction>> instrument_code()
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (pledge("stdio proc exec rpath", nullptr) < 0) {
|
if (pledge("stdio proc exec rpath sigaction", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,6 @@ void handle_sigint(int)
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (pledge("stdio", nullptr) < 0) {
|
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int secs;
|
int secs;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
|
@ -51,6 +46,12 @@ int main(int argc, char** argv)
|
||||||
memset(&sa, 0, sizeof(struct sigaction));
|
memset(&sa, 0, sizeof(struct sigaction));
|
||||||
sa.sa_handler = handle_sigint;
|
sa.sa_handler = handle_sigint;
|
||||||
sigaction(SIGINT, &sa, nullptr);
|
sigaction(SIGINT, &sa, nullptr);
|
||||||
|
|
||||||
|
if (pledge("stdio", nullptr) < 0) {
|
||||||
|
perror("pledge");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned remaining = sleep(secs);
|
unsigned remaining = sleep(secs);
|
||||||
if (remaining) {
|
if (remaining) {
|
||||||
printf("Sleep interrupted with %u seconds remaining.\n", remaining);
|
printf("Sleep interrupted with %u seconds remaining.\n", remaining);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue