author | Jacob Varughese <jacob.varughese@oracle.com> |
Thu, 12 Feb 2015 10:24:12 -0800 | |
changeset 3776 | b70e2d3bcc71 |
permissions | -rw-r--r-- |
3776
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
1 |
This fix prevents the probe from reporting failure when it is not able |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
2 |
to probe network interfaces, for e.g. on cluster machines with failover. |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
3 |
This patch has not been submitted upstream but will be by 2015-Feb-28. |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
4 |
--- openscap-1.2.0/src/OVAL/probes/independent/system_info.c.~4~ 2015-02-06 10:38:01.670499365 -0800 |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
5 |
+++ openscap-1.2.0/src/OVAL/probes/independent/system_info.c 2015-02-06 11:18:53.895244912 -0800 |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
6 |
@@ -66,7 +66,29 @@ |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
7 |
#include <ctype.h> |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
8 |
#include <errno.h> |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
9 |
|
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
10 |
-#if defined(__linux__) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
11 |
+#undef OS_FREEBSD |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
12 |
+#undef OS_LINUX |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
13 |
+#undef OS_SOLARIS |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
14 |
+#undef OS_SUNOS |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
15 |
+#undef OS_WINDOWS |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
16 |
+ |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
17 |
+#if defined(__FreeBSD__) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
18 |
+# define OS_FREEBSD |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
19 |
+#elif defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
20 |
+# define OS_LINUX |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
21 |
+#elif defined(sun) || defined(__sun) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
22 |
+# if defined(__SVR4) || defined(__svr4__) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
23 |
+# define OS_SOLARIS |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
24 |
+# else |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
25 |
+# define OS_SUNOS |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
26 |
+# endif |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
27 |
+#elif defined(_WIN32) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
28 |
+# define OS_WINDOWS |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
29 |
+#else |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
30 |
+# error "Sorry, your OS isn't supported." |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
31 |
+#endif |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
32 |
+ |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
33 |
+#if defined(OS_LINUX) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
34 |
#include <sys/socket.h> |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
35 |
#include <ifaddrs.h> |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
36 |
#include <netdb.h> |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
37 |
@@ -96,7 +118,7 @@ |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
38 |
|
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
39 |
return mac_buf; |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
40 |
} |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
41 |
-#else if defined(__SVR4) && defined(__sun) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
42 |
+#else if defined(OS_SOLARIS) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
43 |
#include <sys/socket.h> |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
44 |
#include <ifaddrs.h> |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
45 |
#include <netdb.h> |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
46 |
@@ -162,7 +184,7 @@ |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
47 |
} |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
48 |
#endif |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
49 |
|
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
50 |
-#if defined(__linux__) || (defined(__SVR4) && defined(__sun)) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
51 |
+#if defined(OS_LINUX) || (defined(OS_SOLARIS)) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
52 |
static int get_ifs(SEXP_t *item) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
53 |
{ |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
54 |
struct ifaddrs *ifaddr, *ifa; |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
55 |
@@ -170,7 +192,7 @@ |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
56 |
char host[NI_MAXHOST], *mac; |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
57 |
SEXP_t *attrs; |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
58 |
SEXP_t *r0, *r1, *r2; |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
59 |
-#if defined(__SVR4) && defined(__sun) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
60 |
+#if defined(OS_SOLARIS) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
61 |
int item_added = 0; |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
62 |
#endif |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
63 |
|
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
64 |
@@ -192,7 +214,7 @@ |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
65 |
continue; |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
66 |
|
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
67 |
mac = get_mac(ifa); |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
68 |
-#if defined(__SVR4) && defined(__sun) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
69 |
+#if defined(OS_SOLARIS) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
70 |
if (mac == NULL) { |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
71 |
rc = 1; |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
72 |
goto leave2; |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
73 |
@@ -224,15 +246,15 @@ |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
74 |
r2 = SEXP_string_newf("%s", mac), |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
75 |
NULL); |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
76 |
probe_item_ent_add(item, "interface", attrs, NULL); |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
77 |
-#if defined(__SVR4) && defined(__sun) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
78 |
+#if defined(OS_SOLARIS) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
79 |
item_added = 1; |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
80 |
#endif |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
81 |
SEXP_vfree(attrs, r0, r1, r2, NULL); |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
82 |
} |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
83 |
leave2: |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
84 |
close(fd); |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
85 |
-#if defined(__SVR4) && defined(__sun) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
86 |
- if (item_added == 0 && rc == 0) { |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
87 |
+#if defined(OS_SOLARIS) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
88 |
+ if (item_added == 0) { |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
89 |
attrs = probe_attr_creat("name", |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
90 |
r0 = SEXP_string_newf("dummy0"), |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
91 |
"ip_address", |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
92 |
@@ -243,6 +265,9 @@ |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
93 |
probe_item_ent_add(item, "interface", attrs, NULL); |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
94 |
SEXP_vfree(attrs, r0, r1, r2, NULL); |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
95 |
} |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
96 |
+ /* if not able to get info on interfaces, do not fail. */ |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
97 |
+ if (rc > 0) |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
98 |
+ rc = 0; |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
99 |
#endif |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
100 |
leave1: |
b70e2d3bcc71
20312342 compliance command fails when ipmp group is defined
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff
changeset
|
101 |
freeifaddrs(ifaddr); |