From 01c7724a4f1de4e93e0040fcc07297491ebac856 Mon Sep 17 00:00:00 2001 From: RedYetiDev <38299977+RedYetiDev@users.noreply.github.com> Date: Sun, 13 Oct 2024 14:10:36 -0400 Subject: [PATCH 1/3] test: deflake `test-cluster-shared-handle-bind-privileged-port` --- ...st-cluster-shared-handle-bind-privileged-port.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js index 8bdde0a3320e44..8164b35630c458 100644 --- a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js +++ b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js @@ -21,6 +21,7 @@ 'use strict'; const common = require('../common'); +const { readFileSync } = require('fs'); // Skip on macOS Mojave. https://github.com/nodejs/node/issues/21679 if (common.isMacOS) @@ -35,6 +36,18 @@ if (common.isWindows) if (process.getuid() === 0) common.skip('as this test should not be run as `root`'); +if (common.isLinux) { + 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... + } +} + const assert = require('assert'); const cluster = require('cluster'); const net = require('net'); From e85d06417845a7b5c377cf4e203d06aa318cd007 Mon Sep 17 00:00:00 2001 From: Aviv Keller Date: Sun, 13 Oct 2024 14:50:16 -0400 Subject: [PATCH 2/3] fixup! add comments --- .../parallel/test-cluster-shared-handle-bind-privileged-port.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js index 8164b35630c458..861aa58ea030b6 100644 --- a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js +++ b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js @@ -36,6 +36,8 @@ if (common.isWindows) if (process.getuid() === 0) common.skip('as this test should not be run as `root`'); +// Some systems won't have port 42 set as a privileged port, in that +// case, skip the test. if (common.isLinux) { try { const unprivilegedPortStart = parseInt(readFileSync('/proc/sys/net/ipv4/ip_unprivileged_port_start')); From 4da9010ec8577695f2344e155e25d75e15f3ef0d Mon Sep 17 00:00:00 2001 From: RedYetiDev <38299977+RedYetiDev@users.noreply.github.com> Date: Mon, 14 Oct 2024 17:17:27 -0400 Subject: [PATCH 3/3] fixup! fixup! add comments --- .../test-cluster-shared-handle-bind-privileged-port.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js index 861aa58ea030b6..5e04c8eea1a899 100644 --- a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js +++ b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js @@ -21,7 +21,6 @@ 'use strict'; const common = require('../common'); -const { readFileSync } = require('fs'); // Skip on macOS Mojave. https://github.com/nodejs/node/issues/21679 if (common.isMacOS) @@ -39,6 +38,8 @@ if (process.getuid() === 0) // Some systems won't have port 42 set as a privileged port, in that // case, skip the test. if (common.isLinux) { + const { readFileSync } = require('fs'); + try { const unprivilegedPortStart = parseInt(readFileSync('/proc/sys/net/ipv4/ip_unprivileged_port_start')); if (unprivilegedPortStart <= 42) {