Skip to content

Commit e1d8f18

Browse files
committed
Fix old TAP tests' method for selecting a valid PGPORT value.
This code was trying to be paranoid, but it wasn't paranoid enough. It only ensured that the selected port is in 0..65535, while most Unix systems will refuse unprivileged attempts to use TCP port numbers below 1024. Change it to allow specification of ports 1024..65535, while if the port is outside that range, map it into 49152..65535 which is the port range used by our later branches. The main reason we've not noticed this up to now is that it's not important when testing over Unix-socket connections, only TCP, and most of our test code deliberately prevents the postmaster from opening any TCP ports. However, the SSL tests do open up a TCP port, and I believe this explains why buildfarm member chipmunk has been failing the SSL tests in 9.5: it's picking a reserved port number. Patch in 9.5 and 9.4. Later branches do not use this code.
1 parent 7c86b94 commit e1d8f18

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/test/perl/TestLib.pm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ if (!$ENV{PGPORT})
100100
$ENV{PGPORT} = 65432;
101101
}
102102

103-
$ENV{PGPORT} = int($ENV{PGPORT}) % 65536;
103+
# Force a sane value of PGPORT
104+
$ENV{PGPORT} = int($ENV{PGPORT});
105+
if ($ENV{PGPORT} < 1024 || $ENV{PGPORT} > 65535)
106+
{
107+
$ENV{PGPORT} = ($ENV{PGPORT} % 16384) + 49152;
108+
}
104109

105110

106111
#

0 commit comments

Comments
 (0)