Debian Codegraph @

src/OVAL/probes/unix/sysctl_probe.c

raw symbols SCIP
1 /**
2 * @file sysctl_probe.c
3 * @brief implementation of the sysctl_object
4 * @author "Daniel Kopecek" <[email protected]>
5 */
6
7 /*
8 * Copyright 2011 Red Hat Inc., Durham, North Carolina.
9 * All Rights Reserved.
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 *
25 * Authors:
26 * "Daniel Kopecek" <[email protected]>
27 */
28
29 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
30 #include <config.h>cxx . . $ `<file>/build/config.h`/
31 #endif
32
33 #include <probe/probe.h>cxx . . $ `<file>/src/OVAL/probes/probe/probe.h`/
34 #include "probe-api.h"cxx . . $ `<file>/src/OVAL/probes/public/probe-api.h`/
35 #include "probe/entcmp.h"cxx . . $ `<file>/src/OVAL/probes/probe/entcmp.h`/
36 #include "sysctl_probe.h"cxx . . $ `<file>/src/OVAL/probes/unix/sysctl_probe.h`/
37
38 #if defined(OS_FREEBSD)
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <limits.h>
42 #include <string.h>
43
44 #include "common/debug_priv.h"
45
46 #define SYSCTL_CMD "/sbin/sysctl -ae"
47 #endif
48
49 #if defined(OS_LINUXcxx . . $ `compat/oscap_platforms.h:38:10`!)
50
51 #include <stdio.h>
52 #include <string.h>
53 #include <ctype.h>
54 #include <errno.h>
55 #include <limits.h>
56 #include <dirent.h>
57 #include "oval_fts.h"cxx . . $ `<file>/src/OVAL/probes/oval_fts.h`/
58 #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/
59
60 #define PROC_SYS_DIRcxx . . $ `src/OVAL/probes/unix/sysctl_probe.c:60:9`! "/proc/sys"
61 #define PROC_SYS_MAXDEPTHcxx . . $ `src/OVAL/probes/unix/sysctl_probe.c:61:9`! 7
62
63 int sysctl_probe_offline_mode_supportedcxx . . $ sysctl_probe_offline_mode_supported(b126dc7c1de90089).(void)
64 {
65 return PROBE_OFFLINE_OWNcxx . . $ PROBE_OFFLINE_OWN.;
66 }
67
68 int sysctl_probe_maincxx . . $ sysctl_probe_main(470536d3ffacaf10).(probe_ctxcxx . . $ probe_ctx# *ctx, void *probe_arg)
69 {
70 OVAL_FTScxx . . $ OVAL_FTS# *ofts;
71 OVAL_FTSENTcxx . . $ OVAL_FTSENT# *ofts_ent;
72
73 SEXP_tcxx . . $ SEXP_t# *name_entity, *probe_in;
74 SEXP_tcxx . . $ SEXP_t# *r0, *r1, *r2, *r3;
75 SEXP_tcxx . . $ SEXP_t# *ent_attrs, *bh_entity, *path_entity, *filename_entity;
76 oval_schema_version_tcxx . . $ oval_schema_version_t# over;
77 int over_cmp;
78
79 const char *ipv6_conf_path = "/proc/sys/net/ipv6/conf/";
80 size_t ipv6_conf_path_len = strlencxx . . $ strlen(751346f8406fd082).(ipv6_conf_path);
81
82 probe_in = probe_ctx_getobjectcxx . . $ probe_ctx_getobject(4299b6b53fa804a5).(ctx);
83 name_entity = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "name", 1);
84 over = probe_obj_get_platform_schema_versioncxx . . $ probe_obj_get_platform_schema_version(5bacca80194debea).(probe_in);
85 over_cmp = oval_schema_version_cmpcxx . . $ oval_schema_version_cmp(b4d0c2bfb97f274f).(over, OVAL_SCHEMA_VERSIONcxx . . $ `src/OVAL/public/oval_schema_version.h:39:9`!(5.10));
86
87 if (name_entity == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
88 dEcxx . . $ `src/common/debug_priv.h:63:9`!("Missing \"name\" entity in the input object");
89 return (PROBE_ENOENTcxx . . $ `src/OVAL/probes/public/probe-api.h:433:9`!);
90 }
91
92 /*
93 * prepare behaviors
94 */
95 ent_attrs = probe_attr_creatcxx . . $ probe_attr_creat(5e3fef9c42f0315b).("max_depth", r0 = SEXP_string_newfcxx . . $ SEXP_string_newf(b2137ed863725962).("%d", PROC_SYS_MAXDEPTHcxx . . $ `src/OVAL/probes/unix/sysctl_probe.c:61:9`!),
96 "recurse_direction", r1 = SEXP_string_newcxx . . $ SEXP_string_new(a588a58d7514eee2).("down", 4),
97 "recurse_file_system", r2 = SEXP_string_newcxx . . $ SEXP_string_new(a588a58d7514eee2).("all", 3),
98 "recurse", r3 = SEXP_string_newcxx . . $ SEXP_string_new(a588a58d7514eee2).("symlinks and directories", 24),
99 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
100 bh_entity = probe_ent_creat1cxx . . $ probe_ent_creat1(84b3695e4a0e659a).("behaviors", ent_attrs, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
101 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r0);
102 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r1);
103 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r2);
104 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r3);
105 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(ent_attrs);
106
107 /*
108 * prepare path, filename
109 */
110 ent_attrs = probe_attr_creatcxx . . $ probe_attr_creat(5e3fef9c42f0315b).("operation", r0 = SEXP_number_newicxx . . $ `src/OVAL/probes/SEAP/public/sexp-manip.h:103:9`!(OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.),
111 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
112 path_entity = probe_ent_creat1cxx . . $ probe_ent_creat1(84b3695e4a0e659a).("path", ent_attrs, r1 = SEXP_string_newcxx . . $ SEXP_string_new(a588a58d7514eee2).(PROC_SYS_DIRcxx . . $ `src/OVAL/probes/unix/sysctl_probe.c:60:9`!, strlencxx . . $ strlen(751346f8406fd082).(PROC_SYS_DIRcxx . . $ `src/OVAL/probes/unix/sysctl_probe.c:60:9`!)));
113 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r0);
114 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r1);
115 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(ent_attrs);
116
117 ent_attrs = probe_attr_creatcxx . . $ probe_attr_creat(5e3fef9c42f0315b).("operation", r0 = SEXP_number_newicxx . . $ `src/OVAL/probes/SEAP/public/sexp-manip.h:103:9`!(OVAL_OPERATION_PATTERN_MATCHcxx . . $ OVAL_OPERATION_PATTERN_MATCH.),
118 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
119 filename_entity = probe_ent_creat1cxx . . $ probe_ent_creat1(84b3695e4a0e659a).("filename", ent_attrs, r1 = SEXP_string_newcxx . . $ SEXP_string_new(a588a58d7514eee2).(".*", 2));
120 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r0);
121 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r1);
122 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(ent_attrs);
123
124 /*
125 * collect sysctls
126 * XXX: use direct access for the "equals" op
127 */
128 const char *prefix = getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_PROBE_ROOT");
129 ofts = oval_fts_open_prefixedcxx . . $ oval_fts_open_prefixed(d2d91f0fe545c5d7).(prefix, path_entity, filename_entity, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, bh_entity, probe_ctx_getresultcxx . . $ probe_ctx_getresult(4299b6b53fa804a5).(ctx));
130
131 if (ofts == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
132 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(path_entity);
133 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(filename_entity);
134 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(bh_entity);
135 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(name_entity);
136
137 if (prefix != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
138 DIRcxx . . $ DIR# *d = opendircxx . . $ opendir(f465d4b65cec8dd2).(prefix);
139 if (d != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
140 closedircxx . . $ closedir(ac30a447bc7c2f80).(d);
141 return PROBE_ESUCCESScxx . . $ `src/OVAL/probes/public/probe-common.h:7:9`!;
142 }
143 dWcxx . . $ `src/common/debug_priv.h:62:9`!("Can't open prefix directory '%s': %s", prefix, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
144 }
145
146 dEcxx . . $ `src/common/debug_priv.h:63:9`!("oval_fts_open_prefixed(%s, %s, %s, ...) failed", prefix, PROC_SYS_DIRcxx . . $ `src/OVAL/probes/unix/sysctl_probe.c:60:9`!, ".*");
147 return PROBE_EFATALcxx . . $ `src/OVAL/probes/public/probe-api.h:437:9`!;
148 }
149
150 while ((ofts_ent = oval_fts_readcxx . . $ oval_fts_read(592d87f37bbdbe51).(ofts)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
151 SEXP_tcxx . . $ SEXP_t# *se_mib;
152 char mibpath[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!], *mib;
153 size_t miblen, mibstart;
154 struct statcxx . . $ stat# file_stat;
155
156 if (prefix != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
157 snprintfcxx . . $ snprintf(ea502d73e74c754c).(mibpath, sizeof mibpath, "%s/%s/%s", prefix, ofts_ent->pathcxx . . $ $anonymous_type_ebdee0feb58b991e_1#path., ofts_ent->filecxx . . $ $anonymous_type_ebdee0feb58b991e_1#file.);
158 } else {
159 snprintfcxx . . $ snprintf(ea502d73e74c754c).(mibpath, sizeof mibpath, "%s/%s", ofts_ent->pathcxx . . $ $anonymous_type_ebdee0feb58b991e_1#path., ofts_ent->filecxx . . $ $anonymous_type_ebdee0feb58b991e_1#file.);
160 }
161
162 /* Skip write-only files, eg. /proc/sys/net/ipv4/route/flush */
163 if (statcxx . . $ stat(a9cd1e23e96f423c).(mibpath, &file_stat) == -1) {
164 dEcxx . . $ `src/common/debug_priv.h:63:9`!("Stat failed on %s: %u, %s", mibpath, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
165 oval_ftsent_freecxx . . $ oval_ftsent_free(7e09326da17d8ab0).(ofts_ent);
166 continue;
167 }
168 /* the sysctl utility uses same condition in sysctl.c in ReadSetting() */
169 if ((file_stat.st_modecxx . . $ stat#st_mode. & S_IRUSRcxx . . $ `<external>/531885356569766532/stat.h:168:9`!) == 0) {
170 dDcxx . . $ `src/common/debug_priv.h:64:9`!("Skipping write-only file %s", mibpath);
171 oval_ftsent_freecxx . . $ oval_ftsent_free(7e09326da17d8ab0).(ofts_ent);
172 continue;
173 }
174
175 mibstart = 0;
176 mibstart += prefix != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? strlencxx . . $ strlen(751346f8406fd082).(prefix)+1 : 0;
177 mibstart += strlencxx . . $ strlen(751346f8406fd082).(PROC_SYS_DIRcxx . . $ `src/OVAL/probes/unix/sysctl_probe.c:60:9`!)+1;
178 mib = strdupcxx . . $ strdup(a8b8e32347182212).(mibpath + mibstart);
179 miblen = strlencxx . . $ strlen(751346f8406fd082).(mib);
180
181 while (miblen > 0) {
182 if(mib[miblen - 1] == '/')
183 mib[miblen - 1] = '.';
184 --miblen;
185 }
186
187 dDcxx . . $ `src/common/debug_priv.h:64:9`!("MIB: %s", mib);
188 se_mib = SEXP_string_newcxx . . $ SEXP_string_new(a588a58d7514eee2).(mib, strlencxx . . $ strlen(751346f8406fd082).(mib));
189 freecxx . . $ free(5d22bdacc48458e8).(mib);
190
191 if (probe_entobj_cmpcxx . . $ probe_entobj_cmp(e245451a1311e799).(name_entity, se_mib) == OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE.) {
192 FILEcxx . . $ FILE# *fp;
193 SEXP_tcxx . . $ SEXP_t# *item;
194 char sysval[8192];
195 char *sysvals[512];
196 long i, l;
197 size_t s;
198
199 dDcxx . . $ `src/common/debug_priv.h:64:9`!("MIB match");
200
201 /*
202 * read sysctl value
203 */
204 fp = fopencxx . . $ fopen(82ec0787cd37e0a3).(mibpath, "r");
205
206 if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
207 dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't read sysctl value from \"%s\": %u, %s",
208 mibpath, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
209 goto fail_item;
210 }
211
212 l = freadcxx . . $ fread(738fc8ac1d711e58).(sysval, 1, sizeof sysval - 1, fp);
213
214 if (ferrorcxx . . $ ferror(89bc1efcdac0ca22).(fp)) {
215 /* Linux 4.1.0 introduced a per-NIC IPv6 stable_secret file.
216 * The stable_secret file cannot be read until it is set,
217 * so we skip it when it is not readable. Otherwise we collect it.
218 */
219 if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).(ofts_ent->pathcxx . . $ $anonymous_type_ebdee0feb58b991e_1#path., ipv6_conf_path, ipv6_conf_path_len) == 0 &&
220 strcmpcxx . . $ strcmp(5ae29d726ae57f88).(ofts_ent->filecxx . . $ $anonymous_type_ebdee0feb58b991e_1#file., "stable_secret") == 0) {
221 dDcxx . . $ `src/common/debug_priv.h:64:9`!("Skipping file %s", mibpath);
222 oval_ftsent_freecxx . . $ oval_ftsent_free(7e09326da17d8ab0).(ofts_ent);
223 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(se_mib);
224 fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp);
225 continue;
226 } else {
227 dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error occurred when reading from \"%s\" (fp=%p): l=%ld, %u, %s",
228 mibpath, fp, l, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
229 goto fail_item;
230 }
231 }
232
233 fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp);
234
235 /* Skip empty values as sysctl tool does.
236 * See https://bugzilla.redhat.com/show_bug.cgi?id=1473207
237 */
238 if (l == 0) {
239 dDcxx . . $ `src/common/debug_priv.h:64:9`!("Skipping file '%s' because it has no value.", mibpath);
240 oval_ftsent_freecxx . . $ oval_ftsent_free(7e09326da17d8ab0).(ofts_ent);
241 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(se_mib);
242 continue;
243 }
244
245 /*
246 * sanitize the value
247 * - only printable and whitespace chars allowed
248 * - remove the last '\n'
249 */
250 sysvals[0] = sysval;
251
252 for(s = 0, i = 0; i < l && s < sizeof sysvals/sizeof(char *) - 1; ++i) {
253 if ((!isprintcxx . . $ `<external>/17904084882347303253/ctype.h:195:10`!(sysval[i]) && !isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(sysval[i]))
254 || (over_cmp >= 0 && sysval[i] == '\n' /* OVAL 5.10 and above */))
255 {
256 sysval[i] = '\0';
257 sysvals[++s] = sysval + i + 1;
258 }
259 }
260
261 if (sysval[l - 1] == '\n')
262 sysval[l - 1] = '\0';
263 else
264 sysval[l] = '\0';
265
266 if (strlencxx . . $ strlen(751346f8406fd082).(sysvals[s]) == 0)
267 sysvals[s] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
268 else
269 sysvals[++s] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
270
271 if (over_cmp >= 0) {
272 /* Only in OVAL 5.10 and above */
273 item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_UNIX_SYSCTLcxx . . $ OVAL_UNIX_SYSCTL., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
274 "name", OVAL_DATATYPE_SEXPcxx . . $ OVAL_DATATYPE_SEXP., se_mib,
275 "value", OVAL_DATATYPE_STRING_Mcxx . . $ OVAL_DATATYPE_STRING_M., sysvals,
276 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
277 } else {
278 item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_UNIX_SYSCTLcxx . . $ OVAL_UNIX_SYSCTL., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
279 "name", OVAL_DATATYPE_SEXPcxx . . $ OVAL_DATATYPE_SEXP., se_mib,
280 "value", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., sysval,
281 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
282 }
283
284 goto add_item;
285 fail_item:
286 if (fp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
287 fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp);
288
289 item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_UNIX_SYSCTLcxx . . $ OVAL_UNIX_SYSCTL., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
290 probe_item_setstatuscxx . . $ probe_item_setstatus(112b785eb420e6c0).(item, SYSCHAR_STATUS_ERRORcxx . . $ SYSCHAR_STATUS_ERROR.);
291 add_item:
292 probe_item_collectcxx . . $ probe_item_collect(11bb80e0c30650d7).(ctx, item);
293 }
294
295 oval_ftsent_freecxx . . $ oval_ftsent_free(7e09326da17d8ab0).(ofts_ent);
296 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(se_mib);
297 }
298
299 oval_fts_closecxx . . $ oval_fts_close(cd898f79c195c42c).(ofts);
300 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(path_entity);
301 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(filename_entity);
302 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(bh_entity);
303 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(name_entity);
304
305 return (0);
306 }
307
308 #elif defined(OS_FREEBSD)
309
310 int sysctl_probe_offline_mode_supported(void)
311 {
312 return PROBE_OFFLINE_NONE;
313 }
314
315 int sysctl_probe_main(probe_ctx *ctx, void *probe_arg)
316 {
317 FILE *fp;
318 char output[LINE_MAX];
319 const char* SEP = "=";
320 char* mib;
321 char* sysval;
322 SEXP_t *se_mib;
323 SEXP_t *name_entity, *probe_in;
324
325 probe_in = probe_ctx_getobject(ctx);
326 name_entity = probe_obj_getent(probe_in, "name", 1);
327
328 if (name_entity == NULL) {
329 dE("Missing \"name\" entity in the input object");
330 return (PROBE_ENOENT);
331 }
332
333 /* FreeBSD's sysctl(8) uses undocumented, and potentially unstable,
334 * kernel interfaces to obtain the list of system properties and values.
335 * Hence we call the executable and parse its output rather than
336 * implement the functionality ourselves which risks breakage if/when
337 * the interfaces change.
338 */
339 fp = popen(SYSCTL_CMD, "r");
340
341 if (!fp) {
342 dE("Failed to open output of %s", SYSCTL_CMD);
343 return (PROBE_EFATAL);
344 }
345
346 while (fgets(output, sizeof(output), fp)) {
347 char *strp;
348 mib = strtok_r(output, SEP, &strp);
349 sysval = strtok_r(NULL, SEP, &strp);
350
351 if (!mib)
352 continue;
353
354 if (!sysval)
355 continue;
356
357 se_mib = SEXP_string_new(mib, strlen(mib));
358
359 if (!se_mib) {
360 dE("Failed to allocate new SEXP_string for se_mib");
361 pclose(fp);
362 return (PROBE_ENOENT);
363 }
364
365 /* Remove newline */
366 sysval[strlen(sysval)-1] = '\0';
367
368 if (probe_entobj_cmp(name_entity, se_mib) == OVAL_RESULT_TRUE) {
369 SEXP_t *item;
370
371 item = probe_item_create(OVAL_UNIX_SYSCTL, NULL,
372 "name", OVAL_DATATYPE_SEXP, se_mib,
373 "value", OVAL_DATATYPE_STRING, sysval,
374 NULL);
375
376 if (!item) {
377 dE("probe_item_create() returned a null item");
378 pclose(fp);
379 SEXP_free(se_mib);
380 return (PROBE_ENOENT);
381 }
382
383 probe_item_collect(ctx, item);
384 }
385
386 SEXP_free(se_mib);
387 }
388
389 pclose(fp);
390 return (0);
391 }
392
393 #else
394
395 int sysctl_probe_offline_mode_supported(void)
396 {
397 return PROBE_OFFLINE_NONE;
398 }
399
400 int sysctl_probe_main(probe_ctx *ctx, void *probe_arg)
401 {
402 return(PROBE_EOPNOTSUPP);
403 }
404
405 #endif