[BZ 24816] Fix nss/tst-nss-files-hosts-long.c when there is no IPv6 support

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[BZ 24816] Fix nss/tst-nss-files-hosts-long.c when there is no IPv6 support

Romain Geissler
Hi,

Here is a small patch to fix BZ 24816 (details are in the bug report).

Tested on Linux x64.

PS: I don't have a copyright assignment, and the diff while trivial, is bigger than 15 lines. Is this still ok or not ?

Cheers,
Romain


2019-07-17  Romain Geissler  <[hidden email]>

        [BZ #24816]
        * nss/tst-nss-files-hosts-long.c: Include <ifaddrs.h>.
        (supports_inet_family): Define.
        (do_test): Use supports_inet_family for AF_INET and AF_INET6.


From 5c57c2ead3684a26924a87b8f2dd43b75470ab9b Mon Sep 17 00:00:00 2001
From: Romain Geissler <[hidden email]>
Date: Wed, 17 Jul 2019 12:29:21 +0000
Subject: [PATCH] [BZ 24816] Fix nss/tst-nss-files-hosts-long.c when there is
 no IPv6 support.

---
 nss/tst-nss-files-hosts-long.c | 47 ++++++++++++++++++++++++++++------
 1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/nss/tst-nss-files-hosts-long.c b/nss/tst-nss-files-hosts-long.c
index 32f849e481b..aa79b88e41a 100644
--- a/nss/tst-nss-files-hosts-long.c
+++ b/nss/tst-nss-files-hosts-long.c
@@ -22,6 +22,31 @@
 #include <stdlib.h>
 #include <nss.h>
 #include <support/check.h>
+#include <ifaddrs.h>
+
+static int
+supports_inet_family(int family)
+{
+  struct ifaddrs *ifaddr, *ifa;
+  int ret = 0;
+
+  if (getifaddrs(&ifaddr) == -1)
+    FAIL_EXIT1("getifaddrs failed");
+
+  for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
+    if (ifa->ifa_addr == NULL)
+      continue;
+
+    if (ifa->ifa_addr->sa_family == family) {
+      ret = 1;
+      break;
+    }
+  }
+
+  freeifaddrs(ifaddr);
+
+  return ret;
+}

 static int
 do_test (void)
@@ -30,14 +55,20 @@ do_test (void)

   /* Run getent to fetch the IPv4 address for host test4.
      This forces /etc/hosts to be parsed.  */
-  ret = system("getent ahostsv4 test4");
-  if (ret != 0)
-    FAIL_EXIT1("ahostsv4 failed");
-
-  /* Likewise for IPv6.  */
-  ret = system("getent ahostsv6 test6");
-  if (ret != 0)
-    FAIL_EXIT1("ahostsv6 failed");
+  if (supports_inet_family(AF_INET))
+  {
+    ret = system("getent ahostsv4 test4");
+    if (ret != 0)
+      FAIL_EXIT1("ahostsv4 failed");
+  }
+
+    /* Likewise for IPv6.  */
+  if (supports_inet_family(AF_INET6))
+  {
+    ret = system("getent ahostsv6 test6");
+    if (ret != 0)
+      FAIL_EXIT1("ahostsv6 failed");
+  }

   exit (0);
 }
--
2.17.1

Reply | Threaded
Open this post in threaded view
|

Re: [BZ 24816] Fix nss/tst-nss-files-hosts-long.c when there is no IPv6 support

Florian Weimer-5
* Romain Geissler:

> PS: I don't have a copyright assignment, and the diff while trivial,
> is bigger than 15 lines. Is this still ok or not ?

Do you plan to contribute more in the future?  Then the FSF will need a
copyright assignment from your employer (or one from you and a copyright
disclaimer from your employer).

You can start the process by sending this form to <[hidden email]>:

<http://git.savannah.gnu.org/cgit/gnulib.git/plain/doc/Copyright/request-assign.future>

These days, the process is pretty lightweight (unless changes to the
contract are needed).

Thanks,
Florian
Reply | Threaded
Open this post in threaded view
|

Re: [BZ 24816] Fix nss/tst-nss-files-hosts-long.c when there is no IPv6 support

Romain Geissler
On Thu, 18 Jul 2019, Florian Weimer wrote:

> * Romain Geissler:
>
> > PS: I don't have a copyright assignment, and the diff while trivial,
> > is bigger than 15 lines. Is this still ok or not ?
>
> Do you plan to contribute more in the future?  Then the FSF will need a
> copyright assignment from your employer (or one from you and a copyright
> disclaimer from your employer).
>
> You can start the process by sending this form to <[hidden email]>:
>
> <https://clicktime.symantec.com/3WTbPcwnFmA9W7V3gxYdCWE6H2?u=http%3A%2F%2Fgit.savannah.gnu.org%2Fcgit%2Fgnulib.git%2Fplain%2Fdoc%2FCopyright%2Frequest-assign.future>
>
> These days, the process is pretty lightweight (unless changes to the
> contract are needed).
>

Hi,

I have no foreseeable plans to contribute more. So far my contributions
have always been totally small and trivial (basically, making the GNU
toolchain component build and their corresponding test suite work
internally in Amadeus).

I haven't understood all the details, but discussions between layers
from FSF and Amadeus did happen earlier this year, and no so far we
haven't signed anything. However I was told from the Amadeus layers that
it's not over for contributions, we can have case by case specific
agreement that would suit both Amadeus and the FSF. Do you consider this
patch goes beyond the notion of "trivial" and requires me to start the
procedure on my side to get everything legally set up correctly ?

Cheers,
Romain
Reply | Threaded
Open this post in threaded view
|

Re: [BZ 24816] Fix nss/tst-nss-files-hosts-long.c when there is no IPv6 support

Carlos O'Donell-6
On 7/18/19 8:18 AM, Romain Geissler wrote:

> I have no foreseeable plans to contribute more. So far my contributions
> have always been totally small and trivial (basically, making the GNU
> toolchain component build and their corresponding test suite work
> internally in Amadeus).
>
> I haven't understood all the details, but discussions between layers
> from FSF and Amadeus did happen earlier this year, and no so far we
> haven't signed anything. However I was told from the Amadeus layers that
> it's not over for contributions, we can have case by case specific
> agreement that would suit both Amadeus and the FSF. Do you consider this
> patch goes beyond the notion of "trivial" and requires me to start the
> procedure on my side to get everything legally set up correctly ?

Romain,

I would love nothing more than to just be able to accept patches from
you without any hassle :-)

The most straight forward way to do this is to kick off another discussion
with Amadenus and the FSF.

You start by filling out this form:
http://git.savannah.gnu.org/cgit/gnulib.git/plain/doc/Copyright/request-assign.future

You would list that Amadeus has claims to your changes, and then the
FSF lawyers and Amadeus lawyers may need to talk.

Please tell me if I can help.

--
Cheers,
Carlos.