From d05b0771be4ad148ffb5bd20e2262632e7f27457 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Sat, 28 Jan 2023 12:43:13 +0100 Subject: [PATCH] test: avoid trying to call sysctl directly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sysctl is often installed in /usr/sbin, which is not conveniently accessible to non-root. Secondly, the setting can just be read directly from the standard location and does not need to be parsed in any special fashion. PR-URL: https://github.com/nodejs/node/pull/46366 Reviewed-By: Luigi Pinca Reviewed-By: Tobias Nießen Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig --- test/parallel/test-cluster-bind-privileged-port.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-cluster-bind-privileged-port.js b/test/parallel/test-cluster-bind-privileged-port.js index 1249230177d2ec..11a8aa6659335e 100644 --- a/test/parallel/test-cluster-bind-privileged-port.js +++ b/test/parallel/test-cluster-bind-privileged-port.js @@ -24,11 +24,10 @@ const common = require('../common'); const assert = require('assert'); const cluster = require('cluster'); const net = require('net'); -const { execSync } = require('child_process'); +const { readFileSync } = require('fs'); if (common.isLinux) { - const sysctlOutput = execSync('sysctl net.ipv4.ip_unprivileged_port_start').toString(); - const unprivilegedPortStart = parseInt(sysctlOutput.split(' ')[2], 10); + const unprivilegedPortStart = parseInt(readFileSync('/proc/sys/net/ipv4/ip_unprivileged_port_start')); if (unprivilegedPortStart <= 42) { common.skip('Port 42 is unprivileged'); }