Skip to content

Commit

Permalink
test: assume priv ports start at 1024 if it can't be changed
Browse files Browse the repository at this point in the history
An update to test/parallel/test-cluster-bind-privileged-port.js
checks the lowest privileged port to ensure 42 is privileged
This only works on kernels > 4.1. On older kernels, this is
locked at 1024 so the check is not needed.

Fixes: #45838
PR-URL: #46536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
KrayzeeKev authored and danielleadams committed Apr 11, 2023
1 parent 73be4f8 commit 3fdcf7b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/parallel/test-cluster-bind-privileged-port.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ const net = require('net');
const { readFileSync } = require('fs');

if (common.isLinux) {
const unprivilegedPortStart = parseInt(readFileSync('/proc/sys/net/ipv4/ip_unprivileged_port_start'));
if (unprivilegedPortStart <= 42) {
common.skip('Port 42 is unprivileged');
try {
const unprivilegedPortStart = parseInt(readFileSync('/proc/sys/net/ipv4/ip_unprivileged_port_start'));
if (unprivilegedPortStart <= 42) {
common.skip('Port 42 is unprivileged');
}
} catch {
// Do nothing, feature doesn't exist, minimum is 1024 so 42 is usable.
// Continue...
}
}

Expand Down

0 comments on commit 3fdcf7b

Please sign in to comment.