The Wayback Machine - https://web.archive.org/web/20230202221035/https://github.com/nodejs/node/commit/896027c006
Skip to content
Permalink
Browse files
test: add fix so that test exits if port 42 is unprivileged
PR-URL: #45904
Fixes: #45838
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
7suyash7 authored and juanarbol committed Jan 31, 2023
1 parent a9db45e commit 896027c00620101db39c55b8eef5e213dec792ee
Showing 1 changed file with 12 additions and 4 deletions.
@@ -21,6 +21,18 @@

'use strict';
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const net = require('net');
const { execSync } = require('child_process');

if (common.isLinux) {
const sysctlOutput = execSync('sysctl net.ipv4.ip_unprivileged_port_start').toString();
const unprivilegedPortStart = parseInt(sysctlOutput.split(' ')[2], 10);
if (unprivilegedPortStart <= 42) {
common.skip('Port 42 is unprivileged');
}
}

// Skip on OS X Mojave. https://github.com/nodejs/node/issues/21679
if (common.isOSX)
@@ -35,10 +47,6 @@ if (common.isWindows)
if (process.getuid() === 0)
common.skip('Test is not supposed to be run as root.');

const assert = require('assert');
const cluster = require('cluster');
const net = require('net');

if (cluster.isPrimary) {
cluster.fork().on('exit', common.mustCall((exitCode) => {
assert.strictEqual(exitCode, 0);

0 comments on commit 896027c

Please sign in to comment.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.