mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 23:41:53 +00:00
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.
This commit is contained in:
parent
238bed2f24
commit
7fba41321e
Notes:
sideshowbarker
2024-07-17 10:37:47 +09:00
Author: https://github.com/sppmacd
Commit: 7fba41321e
Pull-request: https://github.com/SerenityOS/serenity/pull/14107
1 changed files with 7 additions and 6 deletions
|
@ -24,12 +24,6 @@ constexpr int max_formatted_address_length = 21;
|
||||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
TRY(Core::System::pledge("stdio rpath unix"));
|
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_all = false;
|
||||||
bool flag_list = 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.add_option(flag_wide, "Do not truncate IP addresses by printing out the whole symbolic host", "wide", 'W');
|
||||||
args_parser.parse(arguments);
|
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);
|
bool has_protocol_flag = (flag_tcp || flag_udp);
|
||||||
|
|
||||||
uid_t current_uid = getuid();
|
uid_t current_uid = getuid();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue