|
|
923a60 |
From 6e5117b83af5998359916f276a9b32f755c0e6f4 Mon Sep 17 00:00:00 2001
|
|
|
923a60 |
From: Jan Synacek <jsynacek@redhat.com>
|
|
|
923a60 |
Date: Fri, 20 May 2016 12:33:48 +0200
|
|
|
923a60 |
Subject: [PATCH] myhostname: fix timeout if ipv6 is disabled
|
|
|
923a60 |
|
|
|
923a60 |
rhel-only
|
|
|
923a60 |
Resolves: #1330973
|
|
|
923a60 |
---
|
|
|
923a60 |
src/nss-myhostname/nss-myhostname.c | 9 +++++++--
|
|
|
923a60 |
src/shared/socket-util.c | 10 ++++++++++
|
|
|
923a60 |
2 files changed, 17 insertions(+), 2 deletions(-)
|
|
|
923a60 |
|
|
|
923a60 |
diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c
|
|
|
923a60 |
index a939bb267c..e197cc752d 100644
|
|
|
923a60 |
--- a/src/nss-myhostname/nss-myhostname.c
|
|
|
923a60 |
+++ b/src/nss-myhostname/nss-myhostname.c
|
|
|
923a60 |
@@ -33,6 +33,7 @@
|
|
|
923a60 |
#include "local-addresses.h"
|
|
|
923a60 |
#include "macro.h"
|
|
|
923a60 |
#include "nss-util.h"
|
|
|
923a60 |
+#include "socket-util.h"
|
|
|
923a60 |
#include "util.h"
|
|
|
923a60 |
|
|
|
923a60 |
/* We use 127.0.0.2 as IPv4 address. This has the advantage over
|
|
|
923a60 |
@@ -380,9 +381,13 @@ enum nss_status _nss_myhostname_gethostbyname3_r(
|
|
|
923a60 |
return NSS_STATUS_NOTFOUND;
|
|
|
923a60 |
}
|
|
|
923a60 |
|
|
|
923a60 |
- n_addresses = local_addresses(NULL, 0, af, &addresses);
|
|
|
923a60 |
- if (n_addresses < 0)
|
|
|
923a60 |
+ if (af == AF_INET6 && !socket_ipv6_is_supported()) {
|
|
|
923a60 |
n_addresses = 0;
|
|
|
923a60 |
+ } else {
|
|
|
923a60 |
+ n_addresses = local_addresses(NULL, 0, af, &addresses);
|
|
|
923a60 |
+ if (n_addresses < 0)
|
|
|
923a60 |
+ n_addresses = 0;
|
|
|
923a60 |
+ }
|
|
|
923a60 |
|
|
|
923a60 |
canonical = hn;
|
|
|
923a60 |
additional = n_addresses <= 0 && af == AF_INET6 ? "localhost" : NULL;
|
|
|
923a60 |
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
|
|
|
923a60 |
index a212510146..79d1582d49 100644
|
|
|
923a60 |
--- a/src/shared/socket-util.c
|
|
|
923a60 |
+++ b/src/shared/socket-util.c
|
|
|
923a60 |
@@ -435,6 +435,16 @@ bool socket_ipv6_is_supported(void) {
|
|
|
923a60 |
return true;
|
|
|
923a60 |
|
|
|
923a60 |
/* If module was loaded with disable=1 no IPv6 available */
|
|
|
923a60 |
+ if (l[0] == '1')
|
|
|
923a60 |
+ return false;
|
|
|
923a60 |
+
|
|
|
923a60 |
+ free(l);
|
|
|
923a60 |
+ l = NULL;
|
|
|
923a60 |
+
|
|
|
923a60 |
+ if (read_one_line_file("/proc/sys/net/ipv6/conf/all/disable_ipv6", &l) < 0)
|
|
|
923a60 |
+ return true;
|
|
|
923a60 |
+
|
|
|
923a60 |
+ /* If IPv6 was disabled via sysctl during runtime */
|
|
|
923a60 |
return l[0] == '0';
|
|
|
923a60 |
}
|
|
|
923a60 |
|