From b3bc8a88967f964881e9c80aaed7e4fa37ff2f49 Mon Sep 17 00:00:00 2001 From: Jochen Kupperschmidt Date: Fri, 25 Oct 2019 00:47:24 +0200 Subject: [PATCH] Do not attempt to serve on "well-known" ports (#824) --- components/utils/src/net.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/utils/src/net.rs b/components/utils/src/net.rs index bb09d663..314ec8e9 100644 --- a/components/utils/src/net.rs +++ b/components/utils/src/net.rs @@ -1,7 +1,9 @@ use std::net::TcpListener; pub fn get_available_port(avoid: u16) -> Option { - (1000..9000).find(|port| *port != avoid && port_is_available(*port)) + // Start after "well-known" ports (0–1023) as they require superuser + // privileges on UNIX-like operating systems. + (1024..9000).find(|port| *port != avoid && port_is_available(*port)) } pub fn port_is_available(port: u16) -> bool {