From a53749bc9dcad98a6102550a069108e53db59fd1 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Mon, 31 Oct 2022 15:46:51 -0400 Subject: [PATCH] ntpquery: Unveil paths after parsing arguments This allows running `ntpquery --help` in environments that do not have the LookupServer service running, e.g. when generating man pages. The same was done for netstat in commit 7fba413. --- Userland/Utilities/ntpquery.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Userland/Utilities/ntpquery.cpp b/Userland/Utilities/ntpquery.cpp index d3aff6049a..1cc94ac374 100644 --- a/Userland/Utilities/ntpquery.cpp +++ b/Userland/Utilities/ntpquery.cpp @@ -93,9 +93,6 @@ static String format_ntp_timestamp(NtpTimestamp ntp_timestamp) ErrorOr serenity_main(Main::Arguments arguments) { 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; @@ -118,6 +115,10 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(host, "NTP server", "host", Core::ArgsParser::Required::No); args_parser.parse(arguments); + TRY(Core::System::unveil("/tmp/portal/lookup", "rw")); + TRY(Core::System::unveil("/etc/timezone", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); + if (adjust_time && set_time) { warnln("-a and -s are mutually exclusive"); return 1;