Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions test/parallel/test-cluster-bind-privileged-port.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ const net = require('net');
const { readFileSync } = require('fs');

if (common.isLinux) {
const unprivilegedPortStart = parseInt(readFileSync('/proc/sys/net/ipv4/ip_unprivileged_port_start'));
if (unprivilegedPortStart <= 42) {
common.skip('Port 42 is unprivileged');
try {
const sysctlOutput = execSync('sysctl net.ipv4.ip_unprivileged_port_start').toString();
Copy link
Copy Markdown
Member

@lpinca lpinca Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This basically reverts f69e84c. Can't you simply handle the error thrown by readFileSync('/proc/sys/net/ipv4/ip_unprivileged_port_start') when the file does not exist?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that is so embarrassing. I am doing this in v19 and v18 (the one I'm actually trying to deploy). Went back to the old one. Ignore this. Will fix in next few hours. ARGGHHH

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, fixed. Needed more coffee. Working in 3 places (v19 source, v18 source, my build).

const unprivilegedPortStart = parseInt(sysctlOutput.split(' ')[2], 10);
if (unprivilegedPortStart <= 42) {
common.skip('Port 42 is unprivileged');
}
} catch {
// Do nothing, feature doesn't exist, minimum is 1024 so 42 is usable.
// Continue...
}
}

Expand Down