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