Hello Dan,

Can you try applying the attached patch to release 7.0.0 and see if it
fixes the problem with the tls-test?  I am not 100% convinced that it
will, but at least the code is much tighter now and will not store any
address if it is not either IPv4 or IPv6 and if IPv6 is not configured
and it resolves an IPv6 address, it will not be used.

Best regards,
Kern

On 03/31/2014 03:44 PM, Dan Langille wrote:
> On 2014-03-31 09:01 AM, Dan Langille wrote:
>> On 2014-03-31 07:36 AM, Kern Sibbald wrote:
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>>  Hash: SHA1
>>>
>>>  Hello Dan,
>>>
>>>  I have to admit that I haven't run a Dart test for a very long time.
>>> The plugin-test should be removed from it, which I have done. I've
>>> pushed the patch to the git repo.
>>>
>>>  Concerning the tls-test: that is a problem. Can you tell me what
>>> TCP/IP protocol 28 is on FreeBSD?
>> Nothing, that I see:
>>
>> $ grep 28 /etc/services  | head
>> gss-xlicen   128/tcp    #GSS X License Verification
>> gss-xlicen   128/udp    #GSS X License Verification
>> http-mgmt    280/tcp
>> http-mgmt    280/udp
>> personal-link        281/tcp
>> personal-link        281/udp
>> cableport-ax 282/tcp    #cable port a/x
>> cableport-ax 282/udp    #cable port a/x
>> rescap               283/tcp
>> rescap               283/udp
> Ouch.  That's port numbers, not protocols.
>
> The protocols are defined in /usr/include/sys/socket.h and the URL I 
> posted below should help.
>
>>> This test runs perfectly here, and
>>> we have made some significant networking changes. This protocol should
>>> be the sa_family member and should normally be AF_INET for IPv4.
>>> However, now Bacula handles IPv6 much better than previous versions,
>>> and apparently there is a problem or difference with the FreeBSD IP
>>> definitions. For IPv6 this value should be AF_INET6. Those are the
>>> only two values that Bacula understands.
>> FYI, there is no IPv6 on the regression testing machine in question.
>>
>>>  Note for Linux: AF_INET == 2 AF_INET6 = 10, so 28 is something
>>> different and doesn't even exist on Linux.
>> Guess what, you're right.  See:
>>
>> https://www.freebsd.org/doc/en/books/developers-handbook/sockets-essential-functions.html
>>
>> #define      AF_INET6 28
>>
>>
>>>  Best regards,
>>>  Kern
>>>
>>>  On 03/31/2014 04:04 AM, Dan Langille wrote:
>>>  > On Mar 30, 2014, at 4:44 PM, Dan Langille <d...@langille.org> wrote:
>>>  >
>>>  >> I tried some regression tests for Bacula 7 tonight. I found what I
>>> think may be a configure issue.
>>>  >
>>>  > The test finished, two errors:
>>>  >
>>>  > http://regress.bacula.org/buildSummary.php?buildid=24125 [1]
>>>  >
>>>  >
>>>  >
>>>  >
>>> ------------------------------------------------------------------------------
>>>  >
>>>  >
>>>  > _______________________________________________
>>>  > Bacula-devel mailing list
>>>  > Bacula-devel@lists.sourceforge.net
>>>  > https://lists.sourceforge.net/lists/listinfo/bacula-devel [2]
>>>
>>>  -----BEGIN PGP SIGNATURE-----
>>>  Version: GnuPG v1.4.11 (GNU/Linux)
>>>  Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ [3]
>>>
>>>  iEYEARECAAYFAlM5U0gACgkQNgfoSvWqwEi0CwCg3o5/4r1t4c4t+GhBroPBGUzN
>>>  9DEAoIdsqFwiAqHGJOyvzSsEc/5uENOh
>>>  =R++t
>>>  -----END PGP SIGNATURE-----
>>>
>>>
>>>
>>> Links:
>>> ------
>>> [1] http://regress.bacula.org/buildSummary.php?buildid=24125
>>> [2] https://lists.sourceforge.net/lists/listinfo/bacula-devel
>>> [3] http://www.enigmail.net/

diff --git a/bacula/src/lib/address_conf.c b/bacula/src/lib/address_conf.c
index c5ef4ca..0d5fb07 100644
--- a/bacula/src/lib/address_conf.c
+++ b/bacula/src/lib/address_conf.c
@@ -65,7 +65,7 @@ IPADDR::IPADDR(int af) : type(R_EMPTY)
      saddr4->sin_port = 0xffff;
   }
 #ifdef HAVE_IPV6
-  else {
+  else if (af  == AF_INET6) {
      saddr6->sin6_port = 0xffff;
   }
 #endif
@@ -96,11 +96,11 @@ unsigned short IPADDR::get_port_net_order() const
       port = saddr4->sin_port;
    }
 #ifdef HAVE_IPV6
-   else {
+   else if (saddr->sa_family == AF_INET6) {
       port = saddr6->sin6_port;
    }
 #endif
-    return port;
+   return port;
 }
 
 void IPADDR::set_port_net(unsigned short port)
@@ -109,7 +109,7 @@ void IPADDR::set_port_net(unsigned short port)
       saddr4->sin_port = port;
    }
 #ifdef HAVE_IPV6
-   else {
+   else if (saddr->sa_family == AF_INET6) {
       saddr6->sin6_port = port;
    }
 #endif
@@ -201,10 +201,11 @@ const char *IPADDR::get_address(char *outputbuf, int outlen)
 const char *IPADDR::build_address_str(char *buf, int blen)
 {
    char tmp[1024];
+   *buf = 0;
    if (get_family() == AF_INET) {
       bsnprintf(buf, blen, "%s:%hu ",
                 get_address(tmp, sizeof(tmp) - 1), get_port_host_order());
-   } else {
+   } else if (get_family() == AF_INET6) {
       bsnprintf(buf, blen, "[%s]:%hu ",
                 get_address(tmp, sizeof(tmp) - 1), get_port_host_order());
    }
@@ -574,7 +575,7 @@ int sockaddr_get_port_net_order(const struct sockaddr *client_addr)
       return ((struct sockaddr_in *)client_addr)->sin_port;
    }
 #ifdef HAVE_IPV6
-   else {
+   else if (client_addr->sa_family == AF_INET6) {
       return ((struct sockaddr_in6 *)client_addr)->sin6_port;
    }
 #endif
@@ -587,7 +588,7 @@ int sockaddr_get_port(const struct sockaddr *client_addr)
       return ntohs(((struct sockaddr_in *)client_addr)->sin_port);
    }
 #ifdef HAVE_IPV6
-   else {
+   else if (client_addr->sa_family == AF_INET6) {
       return ntohs(((struct sockaddr_in6 *)client_addr)->sin6_port);
    }
 #endif
diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c
index 91fd397..f61929f 100644
--- a/bacula/src/lib/bnet.c
+++ b/bacula/src/lib/bnet.c
@@ -439,14 +439,15 @@ static const char *resolv_host(int family, const char *host, dlist * addr_list)
          IPADDR *addr =  New(IPADDR(hp->h_addrtype));
          addr->set_type(IPADDR::R_MULTIPLE);
          if (addr->get_family() == AF_INET) {
-             addr->set_addr4((struct in_addr*)*p);
+            addr->set_addr4((struct in_addr*)*p);
+            addr_list->append(addr);
          }
 #ifdef HAVE_IPV6
-         else {
-             addr->set_addr6((struct in6_addr*)*p);
+         else if (addr->get_family() == AF_INET6) {
+            addr->set_addr6((struct in6_addr*)*p);
+            addr_list->append(addr);
          }
 #endif
-         addr_list->append(addr);
       }
       V(ip_mutex);
    }
------------------------------------------------------------------------------
_______________________________________________
Bacula-devel mailing list
Bacula-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-devel

Reply via email to