# HG changeset patch
# User Kaitlin Rupert<karupert(a)us.ibm.com>
# Date 1250034843 25200
# Node ID c7fa7f2f08f01abe23da18e3ed3a22efbae718af
# Parent bf7220c52d7afecf85d7c2a6b11d9ba0f45052f9
Ensure hostname always returns a value.
Signed-off-by: Kaitlin Rupert<karupert(a)us.ibm.com>
diff -r bf7220c52d7a -r c7fa7f2f08f0 src/Virt_HostSystem.c
--- a/src/Virt_HostSystem.c Tue Aug 11 14:15:34 2009 -0600
+++ b/src/Virt_HostSystem.c Tue Aug 11 16:54:03 2009 -0700
@@ -58,7 +58,20 @@
}
CU_DEBUG("Unable to find FQDN, using hostname.");
- strncpy(buf, he->h_name, size);
+
+ /* FIXME: An ugly hack to ensure we return something for the hostname,
+ but also be sure the value isn't empty and that it doesn't
+ contain "localhost" */
+ if ((he->h_name != NULL)&& (!STREQC(he->h_name,
""))&&
+ (strstr(he->h_name, "localhost") == NULL))
+ strncpy(buf, he->h_name, size);
+ else if ((host != NULL)&& (!STREQC(host, ""))&&
+ (strstr(host, "localhost") == NULL))
+ strncpy(buf, host, size);
+ else {
+ CU_DEBUG("Unable to find valid hostname value.");
+ return -1;
+ }
return 0;
}
@@ -78,7 +91,7 @@
else
ret = resolve_host(host, buf, size);
- return 0;
+ return ret;
}
static int set_host_system_properties(CMPIInstance *instance)
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim
--
Richard Maciel, MSc
IBM Linux Technology Center
rmaciel(a)linux.vnet.ibm.com