diff options
author | Maciej <sppmacd@pm.me> | 2022-05-26 19:28:45 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-05-26 21:49:52 +0100 |
commit | 7fba41321e44e596cbf57309265e644d2b36ec4a (patch) | |
tree | 7849a804614c388c5ce1a93de7067d9367d9acf5 /Userland/Utilities | |
parent | 238bed2f2447523ed619e3b97ed338a75f39c7f7 (diff) | |
download | serenity-7fba41321e44e596cbf57309265e644d2b36ec4a.zip |
netstat: Stop needing LookupServer for parsing arguments
Previously the netstat utility crashed when LookupServer wasn't running
because it tried to unveil nonexistent /tmp/portal/lookup socket. This
commit fixes that.
Diffstat (limited to 'Userland/Utilities')
-rw-r--r-- | Userland/Utilities/netstat.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Userland/Utilities/netstat.cpp b/Userland/Utilities/netstat.cpp index 778b503cc2..0ae7af7dd8 100644 --- a/Userland/Utilities/netstat.cpp +++ b/Userland/Utilities/netstat.cpp @@ -24,12 +24,6 @@ constexpr int max_formatted_address_length = 21; ErrorOr<int> serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath unix")); - TRY(Core::System::unveil("/proc/net", "r")); - TRY(Core::System::unveil("/proc/all", "r")); - TRY(Core::System::unveil("/etc/passwd", "r")); - TRY(Core::System::unveil("/etc/services", "r")); - TRY(Core::System::unveil("/tmp/portal/lookup", "rw")); - TRY(Core::System::unveil(nullptr, nullptr)); bool flag_all = false; bool flag_list = false; @@ -50,6 +44,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_option(flag_wide, "Do not truncate IP addresses by printing out the whole symbolic host", "wide", 'W'); args_parser.parse(arguments); + TRY(Core::System::unveil("/proc/net", "r")); + TRY(Core::System::unveil("/proc/all", "r")); + TRY(Core::System::unveil("/etc/passwd", "r")); + TRY(Core::System::unveil("/etc/services", "r")); + TRY(Core::System::unveil("/tmp/portal/lookup", "rw")); + TRY(Core::System::unveil(nullptr, nullptr)); + bool has_protocol_flag = (flag_tcp || flag_udp); uid_t current_uid = getuid(); |