Skip to content

Commit d05b077

Browse files
AdamMajerjuanarbol
authored andcommitted
test: avoid trying to call sysctl directly
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: #46366 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 919e581 commit d05b077

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

test/parallel/test-cluster-bind-privileged-port.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ const common = require('../common');
2424
const assert = require('assert');
2525
const cluster = require('cluster');
2626
const net = require('net');
27-
const { execSync } = require('child_process');
27+
const { readFileSync } = require('fs');
2828

2929
if (common.isLinux) {
30-
const sysctlOutput = execSync('sysctl net.ipv4.ip_unprivileged_port_start').toString();
31-
const unprivilegedPortStart = parseInt(sysctlOutput.split(' ')[2], 10);
30+
const unprivilegedPortStart = parseInt(readFileSync('/proc/sys/net/ipv4/ip_unprivileged_port_start'));
3231
if (unprivilegedPortStart <= 42) {
3332
common.skip('Port 42 is unprivileged');
3433
}

0 commit comments

Comments
 (0)