]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 2994: pt 1: Open *_port directives correctly in IPv4-only mode.
authorAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 30 Jul 2010 04:03:19 +0000 (22:03 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 30 Jul 2010 04:03:19 +0000 (22:03 -0600)
Was opening snmp_port, icp_port, htcp_port under the v4-mapping assumption.
This forces the ports both listening and outgoing to IPv4-only unless
v4-mapping is actually available in the system.

src/htcp.cc
src/icp_v2.cc
src/snmp_core.cc

index fd17a3270b9448279e781b17624c3649c49e3471..71f427526997f0277ee5bbc82094bd0fcbaca8f7 100644 (file)
@@ -37,6 +37,7 @@
 #include "htcp.h"
 #include "acl/FilledChecklist.h"
 #include "acl/Acl.h"
+#include "ip/tools.h"
 #include "SquidTime.h"
 #include "Store.h"
 #include "StoreClient.h"
@@ -1503,6 +1504,11 @@ htcpInit(void)
     Ip::Address incomingAddr = Config.Addrs.udp_incoming;
     incomingAddr.SetPort(Config.Port.htcp);
 
+    if (!Ip::EnableIpv6 && !incomingAddr.SetIPv4()) {
+        debugs(31, DBG_CRITICAL, "ERROR: IPv6 is disabled. " << incomingAddr << " is not an IPv4 address.");
+        fatal("HTCP port cannot be opened.");
+    }
+
     AsyncCall::Pointer call = asyncCall(31, 2,
                                         "htcpIncomingConnectionOpened",
                                         HtcpListeningStartedDialer(&htcpIncomingConnectionOpened));
@@ -1517,6 +1523,10 @@ htcpInit(void)
         Ip::Address outgoingAddr = Config.Addrs.udp_outgoing;
         outgoingAddr.SetPort(Config.Port.htcp);
 
+        if (!Ip::EnableIpv6 && !outgoingAddr.SetIPv4()) {
+            debugs(31, DBG_CRITICAL, "ERROR: IPv6 is disabled. " << outgoingAddr << " is not an IPv4 address.");
+            fatal("HTCP port cannot be opened.");
+        }
         enter_suid();
         htcpOutSocket = comm_open_listener(SOCK_DGRAM,
                                            IPPROTO_UDP,
index cb1e4cde5cbced6d37d664b0784347f0ed726c6b..781831e623679a7abf6b105ec44ca3f062dbb292 100644 (file)
@@ -48,6 +48,7 @@
 #include "SwapDir.h"
 #include "icmp/net_db.h"
 #include "ip/Address.h"
+#include "ip/tools.h"
 #include "ipc/StartListening.h"
 #include "rfc1738.h"
 
@@ -686,6 +687,11 @@ icpConnectionsOpen(void)
     addr = Config.Addrs.udp_incoming;
     addr.SetPort(port);
 
+    if (!Ip::EnableIpv6 && !addr.SetIPv4()) {
+        debugs(12, DBG_CRITICAL, "ERROR: IPv6 is disabled. " << addr << " is not an IPv4 address.");
+        fatal("ICP port cannot be opened.");
+    }
+
     AsyncCall::Pointer call = asyncCall(12, 2,
                                         "icpIncomingConnectionOpened",
                                         IcpListeningStartedDialer(&icpIncomingConnectionOpened, addr));
@@ -701,6 +707,12 @@ icpConnectionsOpen(void)
     if ( !addr.IsNoAddr() ) {
         enter_suid();
         addr.SetPort(port);
+
+        if (!Ip::EnableIpv6 && !addr.SetIPv4()) {
+            debugs(49, DBG_CRITICAL, "ERROR: IPv6 is disabled. " << addr << " is not an IPv4 address.");
+            fatal("ICP port cannot be opened.");
+        }
+
         theOutIcpConnection = comm_open_listener(SOCK_DGRAM,
                               IPPROTO_UDP,
                               addr,
index f68c7776c94466acb12200bb01c714fb2a1d6c2e..57a93a1ee59960f65dd3a4970bceb36eeff28424 100644 (file)
@@ -307,6 +307,10 @@ snmpConnectionOpen(void)
     if (Config.Port.snmp > 0) {
         Config.Addrs.snmp_incoming.SetPort(Config.Port.snmp);
 
+        if (!Ip::EnableIpv6 && !Config.Addrs.snmp_incoming.SetIPv4()) {
+            debugs(49, DBG_CRITICAL, "ERROR: IPv6 is disabled. " << Config.Addrs.snmp_incoming << " is not an IPv4 address.");
+            fatal("SNMP port cannot be opened.");
+        }
         AsyncCall::Pointer call = asyncCall(49, 2,
                                             "snmpIncomingConnectionOpened",
                                             SnmpListeningStartedDialer(&snmpIncomingConnectionOpened));
@@ -320,6 +324,10 @@ snmpConnectionOpen(void)
         if (!Config.Addrs.snmp_outgoing.IsNoAddr()) {
             Config.Addrs.snmp_outgoing.SetPort(Config.Port.snmp);
 
+            if (!Ip::EnableIpv6 && !Config.Addrs.snmp_outgoing.SetIPv4()) {
+                debugs(49, DBG_CRITICAL, "ERROR: IPv6 is disabled. " << Config.Addrs.snmp_outgoing << " is not an IPv4 address.");
+                fatal("SNMP port cannot be opened.");
+            }
             AsyncCall::Pointer call = asyncCall(49, 2,
                                                 "snmpOutgoingConnectionOpened",
                                                 SnmpListeningStartedDialer(&snmpOutgoingConnectionOpened));