[Open-scap] patch for systeminfo probe for solaris

Šimon Lukašík slukasik at redhat.com
Fri Jun 19 13:05:29 UTC 2015


Jacob,

I have comment on assignments to 'rc' here. It is probably correct, but 
it takes time to read.

In OpenSCAP we often assign error value to return code, and only on 
specific success we assign 0 to return code. It is safer. And easier to 
maintain as there tends to be much more error case than success cases.

Would it be possible to leave 'rc=1' there?

What do you think?

Thank You,
~š.

On 06/17/2015 08:52 PM, Jacob Varughese wrote:
> -       int family, rc=1;
> +       int family, rc=0;
>          char host[NI_MAXHOST], *mac;
>          SEXP_t *attrs;
>          SEXP_t *r0, *r1, *r2;
> +#if defined(OS_SOLARIS)
> +       int item_added = 0;
> +#endif
>
>          if (getifaddrs(&ifaddr) == -1)
> -               return rc;
> +               return 1;
>
>          fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
>          if (fd < 0)
> @@ -123,6 +214,14 @@ static int get_ifs(SEXP_t *item)
>                           continue;
>
>                   mac = get_mac(ifa);
> +#if defined(OS_SOLARIS)
> +		if (mac == NULL) {
> +			rc = 1;
> +			goto leave2;
> +		}
> +		if (mac[0] == '\0')
> +			continue;
> +#endif
>   		if (family == AF_INET) {
>   			rc = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in),
>   				host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
> @@ -139,8 +238,6 @@ static int get_ifs(SEXP_t *item)
>   				goto leave2;
>   			}
>   		}
> -
> -
>   	        attrs = probe_attr_creat("name",
>                                    r0 = SEXP_string_newf("%s", ifa->ifa_name),
>                                    "ip_address",
> @@ -149,10 +246,29 @@ static int get_ifs(SEXP_t *item)
>                                    r2 = SEXP_string_newf("%s", mac),
>                                    NULL);
>   	        probe_item_ent_add(item, "interface", attrs, NULL);
> +#if defined(OS_SOLARIS)
> +		item_added = 1;
> +#endif
>           	SEXP_vfree(attrs, r0, r1, r2, NULL);
>   	}
>   leave2:
>           close(fd);
> +#if defined(OS_SOLARIS)
> +	if (item_added == 0) {
> +		attrs = probe_attr_creat("name",
> +					 r0 = SEXP_string_newf("dummy0"),
> +					 "ip_address",
> +					 r1 = SEXP_string_newf("127.0.0.1"),
> +					 "mac_address",
> +					 r2 = SEXP_string_newf("aa:bb:cc:dd:ee:ff"),
> +					 NULL);
> +		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




More information about the Open-scap-list mailing list