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