GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: add fix so that test exits if port 42 is unprivileged · nodejs/node@4f491d3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-cluster-bind-privileged-port.js
Expand file treeCollapse file tree
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)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.