# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1222703637 25200
# Node ID 330a579be15c3967ea54158f89c85fe10363db02
# Parent 3c3b312723817f4a418658e68de19cf38d51fc4f
Add a bit more logic to check for FQDN.
Depending on how /etc/hosts is arranged, it's possible for gethostbyname() a non-FQDN.
This happens on F10 is /etc/hosts has something like:
hostname hostname.my.domain localhost
This bit a logic looks through the domains in h_aliases to see if a FQDN exists.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 3c3b31272381 -r 330a579be15c src/Virt_HostSystem.c
--- a/src/Virt_HostSystem.c Mon Sep 29 08:53:27 2008 -0700
+++ b/src/Virt_HostSystem.c Mon Sep 29 08:53:57 2008 -0700
@@ -41,6 +41,7 @@
static int resolve_host(char *host, char *buf, int size)
{
struct hostent *he;
+ int i;
he = gethostbyname(host);
if (he == NULL) {
@@ -48,6 +49,15 @@
return -1;
}
+ for (i = 0; he->h_aliases[i] != NULL; i++) {
+ if ((strchr(he->h_aliases[i], '.') != NULL) &&
+ (strstr(he->h_aliases[i], "localhost") == NULL)) {
+ strncpy(buf, he->h_aliases[i], size);
+ return 0;
+ }
+ }
+
+ CU_DEBUG("Unable to find FQDN, using hostname.");
strncpy(buf, he->h_name, size);
return 0;
Show replies by date