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