Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Fix old TAP tests' method for selecting a valid PGPORT value.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 20 Nov 2018 01:01:35 +0000 (20:01 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 20 Nov 2018 01:01:35 +0000 (20:01 -0500)
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.

src/test/perl/TestLib.pm

index 8eb27df796ff9ef7f233ff593f3f9d19c37e6d67..35505afe0265fbb9883dffaf4b4f471b5e9982df 100644 (file)
@@ -100,7 +100,12 @@ if (!$ENV{PGPORT})
    $ENV{PGPORT} = 65432;
 }
 
-$ENV{PGPORT} = int($ENV{PGPORT}) % 65536;
+# Force a sane value of PGPORT
+$ENV{PGPORT} = int($ENV{PGPORT});
+if ($ENV{PGPORT} < 1024 || $ENV{PGPORT} > 65535)
+{
+   $ENV{PGPORT} = ($ENV{PGPORT} % 16384) + 49152;
+}
 
 
 #