Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 896027c

Browse filesBrowse files
7suyash7juanarbol
authored andcommitted
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>
1 parent a9db45e commit 896027c
Copy full SHA for 896027c

File tree

Expand file treeCollapse file tree

1 file changed

+12
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-4
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-cluster-bind-privileged-port.js
+12-4Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@
2121

2222
'use strict';
2323
const common = require('../common');
24+
const assert = require('assert');
25+
const cluster = require('cluster');
26+
const net = require('net');
27+
const { execSync } = require('child_process');
28+
29+
if (common.isLinux) {
30+
const sysctlOutput = execSync('sysctl net.ipv4.ip_unprivileged_port_start').toString();
31+
const unprivilegedPortStart = parseInt(sysctlOutput.split(' ')[2], 10);
32+
if (unprivilegedPortStart <= 42) {
33+
common.skip('Port 42 is unprivileged');
34+
}
35+
}
2436

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

38-
const assert = require('assert');
39-
const cluster = require('cluster');
40-
const net = require('net');
41-
4250
if (cluster.isPrimary) {
4351
cluster.fork().on('exit', common.mustCall((exitCode) => {
4452
assert.strictEqual(exitCode, 0);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.