| 1 | /** |
| 2 | * @file uname_probe.c |
| 3 | * @brief uname probe |
| 4 | * @author "Steve Grubb" <[email protected]> |
| 5 | * |
| 6 | * 2010/06/13 [email protected] |
| 7 | * This probe is able to process an uname_object as defined in OVAL 5.4 and 5.5. |
| 8 | * |
| 9 | */ |
| 10 | |
| 11 | /* |
| 12 | * Copyright 2009 Red Hat Inc., Durham, North Carolina. |
| 13 | * All Rights Reserved. |
| 14 | * |
| 15 | * This library is free software; you can redistribute it and/or |
| 16 | * modify it under the terms of the GNU Lesser General Public |
| 17 | * License as published by the Free Software Foundation; either |
| 18 | * version 2.1 of the License, or (at your option) any later version. |
| 19 | * |
| 20 | * This library is distributed in the hope that it will be useful, |
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 23 | * Lesser General Public License for more details. |
| 24 | * |
| 25 | * You should have received a copy of the GNU Lesser General Public |
| 26 | * License along with this library; if not, write to the Free Software |
| 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 28 | * |
| 29 | * Authors: |
| 30 | * Steve Grubb <[email protected]> |
| 31 | */ |
| 32 | |
| 33 | /* |
| 34 | * uname probe: |
| 35 | * |
| 36 | * machine_class |
| 37 | * node_name |
| 38 | * os_name |
| 39 | * os_release |
| 40 | * os_version |
| 41 | * processor_type |
| 42 | */ |
| 43 | |
| 44 | #ifdef HAVE_CONFIG_H |
| 45 | #include <config.h> |
| 46 | #endif |
| 47 | |
| 48 | #ifdef HAVE_STDIO_EXT_H |
| 49 | # include <stdio_ext.h> |
| 50 | #endif |
| 51 | #include <string.h> |
| 52 | #include <sys/utsname.h> |
| 53 | #if defined HAVE_SYS_SYSTEMINFO_H && defined (OS_SOLARIS) |
| 54 | #include <sys/systeminfo.h> |
| 55 | #endif |
| 56 | |
| 57 | #include "_seap.h" |
| 58 | #include "probe-api.h" |
| 59 | #include "uname_probe.h" |
| 60 | |
| 61 | int uname_probe_main(probe_ctx *ctx, void *arg) |
| 62 | { |
| 63 | struct utsname buf; |
| 64 | SEXP_t *item; |
| 65 | #if defined (OS_SOLARIS) |
| 66 | char procbuf[SYS_NMLN]; |
| 67 | #endif |
| 68 | |
| 69 | // Collect the info |
| 70 | uname(&buf); |
| 71 | |
| 72 | #if defined (OS_SOLARIS) |
| 73 | if (sysinfo(SI_ARCHITECTURE, procbuf, sizeof(procbuf)) == -1) |
| 74 | return(PROBE_EFATAL); |
| 75 | #endif |
| 76 | item = probe_item_create(OVAL_UNIX_UNAME, NULL, |
| 77 | "machine_class", OVAL_DATATYPE_STRING, buf.machine, |
| 78 | "node_name", OVAL_DATATYPE_STRING, buf.nodename, |
| 79 | "os_name", OVAL_DATATYPE_STRING, buf.sysname, |
| 80 | "os_release", OVAL_DATATYPE_STRING, buf.release, |
| 81 | "os_version", OVAL_DATATYPE_STRING, buf.version, |
| 82 | #if defined (OS_SOLARIS) |
| 83 | "processor_type", OVAL_DATATYPE_STRING, procbuf, |
| 84 | #else |
| 85 | "processor_type", OVAL_DATATYPE_STRING, buf.machine, |
| 86 | #endif |
| 87 | NULL); |
| 88 | |
| 89 | probe_item_collect(ctx, item); |
| 90 | |
| 91 | return 0; |
| 92 | } |