parse-helpers: allow port 0 for socket bind items
This patch adds a new parameter to parse_ip_port_range, giving callers the option to allow ranges to have their min be 0 instead of 1. This is then used by parse_ip_ports_token, intern used by parse_socket_bind_item to allow port 0 when restricting bind system calls with SocketBindDeny / SocketBindAllow. With this, users running server software written using the golang standard library will be able to effectively sandbox their software, albeit with a small loss in security protections by allowing the process to bind on a random port in the /proc/sys/net/ipv4/ip_local_port_range.
This commit is contained in:
committed by
Yu Watanabe
parent
9807ee19b0
commit
dcfac3a3f9
@@ -289,7 +289,7 @@ int config_parse_port_range(
|
||||
VxLan *v = ASSERT_PTR(userdata);
|
||||
int r;
|
||||
|
||||
r = parse_ip_port_range(rvalue, &v->port_range.low, &v->port_range.high);
|
||||
r = parse_ip_port_range(rvalue, &v->port_range.low, &v->port_range.high, /* allow_zero = */ false);
|
||||
if (r < 0)
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to parse VXLAN port range '%s'. Port should be greater than 0 and less than 65535.", rvalue);
|
||||
|
||||
@@ -1408,7 +1408,7 @@ int config_parse_routing_policy_rule_port_range(
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
r = parse_ip_port_range(rvalue, &low, &high);
|
||||
r = parse_ip_port_range(rvalue, &low, &high, /* allow_zero = */ false);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse routing policy rule port range '%s'", rvalue);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user