Skip to content

Commit

Permalink
test: avoid trying to call sysctl directly
Browse files Browse the repository at this point in the history
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 <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
AdamMajer authored and juanarbol committed Mar 5, 2023
1 parent 919e581 commit d05b077
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions test/parallel/test-cluster-bind-privileged-port.js
Expand Up @@ -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');
}
Expand Down

0 comments on commit d05b077

Please sign in to comment.