components/openscap/patches/system_info5.c.patch
author Jacob Varughese <jacob.varughese@oracle.com>
Thu, 12 Feb 2015 10:24:12 -0800
changeset 3776 b70e2d3bcc71
permissions -rw-r--r--
20312342 compliance command fails when ipmp group is defined

This fix prevents the probe from reporting failure when it is not able
 to probe network interfaces, for e.g. on cluster machines with failover.
This patch has not been submitted upstream but will be by 2015-Feb-28.
--- openscap-1.2.0/src/OVAL/probes/independent/system_info.c.~4~	2015-02-06 10:38:01.670499365 -0800
+++ openscap-1.2.0/src/OVAL/probes/independent/system_info.c	2015-02-06 11:18:53.895244912 -0800
@@ -66,7 +66,29 @@
 #include <ctype.h>
 #include <errno.h>
 
-#if defined(__linux__)
+#undef OS_FREEBSD
+#undef OS_LINUX
+#undef OS_SOLARIS
+#undef OS_SUNOS
+#undef OS_WINDOWS
+
+#if defined(__FreeBSD__)
+# define OS_FREEBSD
+#elif defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)
+# define OS_LINUX
+#elif defined(sun) || defined(__sun)
+# if defined(__SVR4) || defined(__svr4__)
+#  define OS_SOLARIS
+# else
+#  define OS_SUNOS
+# endif
+#elif defined(_WIN32)
+# define OS_WINDOWS
+#else
+# error "Sorry, your OS isn't supported."
+#endif
+
+#if defined(OS_LINUX)
 #include <sys/socket.h>
 #include <ifaddrs.h>
 #include <netdb.h>
@@ -96,7 +118,7 @@
 
        return mac_buf;
 }
-#else if defined(__SVR4) && defined(__sun)
+#else if defined(OS_SOLARIS)
 #include <sys/socket.h>
 #include <ifaddrs.h>
 #include <netdb.h>
@@ -162,7 +184,7 @@
 }
 #endif
 
-#if defined(__linux__) || (defined(__SVR4) && defined(__sun))
+#if defined(OS_LINUX) || (defined(OS_SOLARIS))
 static int get_ifs(SEXP_t *item)
 {
        struct ifaddrs *ifaddr, *ifa;
@@ -170,7 +192,7 @@
        char host[NI_MAXHOST], *mac;
        SEXP_t *attrs;
        SEXP_t *r0, *r1, *r2;
-#if defined(__SVR4) && defined(__sun)
+#if defined(OS_SOLARIS)
        int item_added = 0;
 #endif
 
@@ -192,7 +214,7 @@
                         continue;
 
                 mac = get_mac(ifa);
-#if defined(__SVR4) && defined(__sun)
+#if defined(OS_SOLARIS)
 		if (mac == NULL) {
 			rc = 1;
 			goto leave2;
@@ -224,15 +246,15 @@
                                  r2 = SEXP_string_newf("%s", mac),
                                  NULL);
 	        probe_item_ent_add(item, "interface", attrs, NULL);
-#if defined(__SVR4) && defined(__sun)
+#if defined(OS_SOLARIS)
 		item_added = 1;
 #endif
         	SEXP_vfree(attrs, r0, r1, r2, NULL);
 	}
 leave2:
         close(fd);
-#if defined(__SVR4) && defined(__sun)
-	if (item_added == 0 && rc == 0) {
+#if defined(OS_SOLARIS)
+	if (item_added == 0) {
 		attrs = probe_attr_creat("name",
 					 r0 = SEXP_string_newf("dummy0"),
 					 "ip_address",
@@ -243,6 +265,9 @@
 		probe_item_ent_add(item, "interface", attrs, NULL);
 		SEXP_vfree(attrs, r0, r1, r2, NULL);
 	}
+ /* if not able to get info on interfaces, do not fail. */
+	if (rc > 0) 
+		rc = 0;
 #endif
 leave1:
         freeifaddrs(ifaddr);