Blame SOURCES/0506-myhostname-don-t-return-any-ipv6-entries-when-ipv6-i.patch

17b0f1
From 624fcda36dd376707e3af088b592fe3764b99acf Mon Sep 17 00:00:00 2001
17b0f1
From: Jan Synacek <jsynacek@redhat.com>
17b0f1
Date: Tue, 2 May 2017 14:34:17 +0200
17b0f1
Subject: [PATCH] myhostname: don't return any ipv6 entries when ipv6 is
17b0f1
 disabled
17b0f1
17b0f1
This commit amends the rhel-only 6e5117b83af5998359916f276a9b32f755c0e6f4.
17b0f1
17b0f1
Resolves: #1444824
17b0f1
---
17b0f1
 src/nss-myhostname/nss-myhostname.c | 10 ++++------
17b0f1
 1 file changed, 4 insertions(+), 6 deletions(-)
17b0f1
17b0f1
diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c
17b0f1
index e197cc752d..144c831719 100644
17b0f1
--- a/src/nss-myhostname/nss-myhostname.c
17b0f1
+++ b/src/nss-myhostname/nss-myhostname.c
17b0f1
@@ -351,6 +351,8 @@ enum nss_status _nss_myhostname_gethostbyname3_r(
17b0f1
                 *h_errnop = NO_DATA;
17b0f1
                 return NSS_STATUS_UNAVAIL;
17b0f1
         }
17b0f1
+        if (af == AF_INET6 && !socket_ipv6_is_supported())
17b0f1
+                return NSS_STATUS_UNAVAIL;
17b0f1
 
17b0f1
         if (is_localhost(name)) {
17b0f1
                 canonical = "localhost";
17b0f1
@@ -381,13 +383,9 @@ enum nss_status _nss_myhostname_gethostbyname3_r(
17b0f1
                         return NSS_STATUS_NOTFOUND;
17b0f1
                 }
17b0f1
 
17b0f1
-                if (af == AF_INET6 && !socket_ipv6_is_supported()) {
17b0f1
+                n_addresses = local_addresses(NULL, 0, af, &addresses);
17b0f1
+                if (n_addresses < 0)
17b0f1
                         n_addresses = 0;
17b0f1
-                } else {
17b0f1
-                        n_addresses = local_addresses(NULL, 0, af, &addresses);
17b0f1
-                        if (n_addresses < 0)
17b0f1
-                                n_addresses = 0;
17b0f1
-                }
17b0f1
 
17b0f1
                 canonical = hn;
17b0f1
                 additional = n_addresses <= 0 && af == AF_INET6 ? "localhost" : NULL;