components/openscap/patches/system_info4.c.patch
author Jacob Varughese <jacob.varughese@oracle.com>
Tue, 07 Oct 2014 16:44:00 -0700
branchs11-update
changeset 3373 9de01e7a073b
permissions -rw-r--r--
19262735 The file probe needs to be zone aware 19173594 oscap crashes when compliance is run 19559867 compliance fails when no network interface are defined
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3373
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
     1
This patch fixes the issue, where the system_info probe fails on solaris,
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
     2
 when the network interfaces cannot be detected. Fix provides the default
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
     3
 loop back interface as default. The earlier patch was not a complete fix.
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
     4
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
     5
This patch has not been contributed upstream, but is planned to be done by
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
     6
 2014-Oct-15.
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
     7
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
     8
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
     9
--- openscap-1.0.0/src/OVAL/probes/independent/system_info.c.~3~	2014-09-18 11:08:42.983747329 -0700
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    10
+++ openscap-1.0.0/src/OVAL/probes/independent/system_info.c	2014-09-18 12:41:13.266535881 -0700
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    11
@@ -166,14 +166,16 @@
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    12
 static int get_ifs(SEXP_t *item)
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    13
 {
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    14
        struct ifaddrs *ifaddr, *ifa;
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    15
-       int family, rc=1;
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    16
+       int family, rc=0;
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    17
        char host[NI_MAXHOST], *mac;
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    18
        SEXP_t *attrs;
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    19
        SEXP_t *r0, *r1, *r2;
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    20
-	int item_added = 0;
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    21
+#if defined(__SVR4) && defined(__sun)
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    22
+       int item_added = 0;
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    23
+#endif
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    24
 
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    25
        if (getifaddrs(&ifaddr) == -1)
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    26
-               return rc;
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    27
+               return 1;
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    28
 
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    29
        fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    30
        if (fd < 0)
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    31
@@ -222,12 +224,15 @@
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    32
                                  r2 = SEXP_string_newf("%s", mac),
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    33
                                  NULL);
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    34
 	        probe_item_ent_add(item, "interface", attrs, NULL);
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    35
+#if defined(__SVR4) && defined(__sun)
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    36
 		item_added = 1;
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    37
+#endif
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    38
         	SEXP_vfree(attrs, r0, r1, r2, NULL);
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    39
 	}
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    40
 leave2:
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    41
         close(fd);
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    42
-	if (item_added == 0) {
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    43
+#if defined(__SVR4) && defined(__sun)
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    44
+	if (item_added == 0 && rc == 0) {
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    45
 		attrs = probe_attr_creat("name",
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    46
 					 r0 = SEXP_string_newf("dummy0"),
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    47
 					 "ip_address",
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    48
@@ -238,6 +243,7 @@
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    49
 		probe_item_ent_add(item, "interface", attrs, NULL);
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    50
 		SEXP_vfree(attrs, r0, r1, r2, NULL);
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    51
 	}
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    52
+#endif
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    53
 leave1:
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    54
         freeifaddrs(ifaddr);
9de01e7a073b 19262735 The file probe needs to be zone aware
Jacob Varughese <jacob.varughese@oracle.com>
parents:
diff changeset
    55
         return rc;