From 3fdcf7bef43f5a6f66d4e0e468715b21e41bb818 Mon Sep 17 00:00:00 2001 From: KrayzeeKev Date: Thu, 2 Mar 2023 19:42:56 +1100 Subject: [PATCH] test: assume priv ports start at 1024 if it can't be changed 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: https://github.com/nodejs/node/issues/45838 PR-URL: https://github.com/nodejs/node/pull/46536 Reviewed-By: Luigi Pinca --- test/parallel/test-cluster-bind-privileged-port.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-cluster-bind-privileged-port.js b/test/parallel/test-cluster-bind-privileged-port.js index 11a8aa6659335e..c971b7656f1221 100644 --- a/test/parallel/test-cluster-bind-privileged-port.js +++ b/test/parallel/test-cluster-bind-privileged-port.js @@ -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... } }