]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 358588: The sslbase's port is harcoded, but shouldn't (allow the port to be speci...
authorlpsolit%gmail.com <>
Thu, 27 Mar 2008 05:23:41 +0000 (05:23 +0000)
committerlpsolit%gmail.com <>
Thu, 27 Mar 2008 05:23:41 +0000 (05:23 +0000)
Bugzilla/Config/Common.pm

index f5f5a3fb264e4c747a02574990ba420b0133326b..e6f0398e311014d0f75d40e12ba5adddee871fe3 100644 (file)
@@ -101,17 +101,21 @@ sub check_sslbase {
             return "must be a legal URL, that starts with https and ends with a slash.";
         }
         my $host = $1;
-        if ($host =~ /:\d+$/) {
-            return "must not contain a port.";
+        # Fall back to port 443 if for some reason getservbyname() fails.
+        my $port = getservbyname('https', 'tcp') || 443;
+        if ($host =~ /^(.+):(\d+)$/) {
+            $host = $1;
+            $port = $2;
         }
         local *SOCK;
         my $proto = getprotobyname('tcp');
         socket(SOCK, PF_INET, SOCK_STREAM, $proto);
-        my $sin = sockaddr_in(443, inet_aton($host));
+        my $iaddr = inet_aton($host) || return "The host $host cannot be resolved";
+        my $sin = sockaddr_in($port, $iaddr);
         if (!connect(SOCK, $sin)) {
-            return "Failed to connect to " . html_quote($host) . 
-                   ":443, unable to enable SSL.";
+            return "Failed to connect to $host:$port; unable to enable SSL";
         }
+        close(SOCK);
     }
     return "";
 }