ntpquery: Fix pledge and unveil invocations

This commit is contained in:
demostanis 2022-10-26 21:34:24 +02:00 committed by Linus Groh
parent b1c73b3605
commit 7015c40905
Notes: sideshowbarker 2024-07-17 16:23:55 +09:00

View file

@ -92,7 +92,10 @@ static String format_ntp_timestamp(NtpTimestamp ntp_timestamp)
}
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio inet unix settime"));
TRY(Core::System::pledge("stdio inet unix settime wpath rpath"));
TRY(Core::System::unveil("/tmp/portal/lookup", "rw"));
TRY(Core::System::unveil("/etc/timezone", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
bool adjust_time = false;
bool set_time = false;
@ -121,7 +124,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
if (!adjust_time && !set_time) {
TRY(Core::System::pledge("stdio inet unix"));
TRY(Core::System::pledge("stdio inet unix rpath"));
}
auto* hostent = gethostbyname(host);
@ -130,8 +133,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 1;
}
TRY(Core::System::pledge((adjust_time || set_time) ? "stdio inet settime"sv : "stdio inet"sv));
TRY(Core::System::unveil(nullptr, nullptr));
TRY(Core::System::pledge((adjust_time || set_time) ? "stdio inet settime wpath rpath"sv : "stdio inet rpath"sv));
int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (fd < 0) {