Skip to content

Commit 7f2aef6

Browse files
committed
OVAL/probes/sysctl: Gracefully handle non-hybrid offline mode
In case the probe for some reason is executed against an offline system image we won't want it to break the entire scan process but rather quietly not yield any results.
1 parent 616abda commit 7f2aef6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/OVAL/probes/unix/sysctl_probe.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include <ctype.h>
5454
#include <errno.h>
5555
#include <limits.h>
56+
#include <dirent.h>
5657
#include "oval_fts.h"
5758
#include "common/debug_priv.h"
5859

@@ -128,13 +129,22 @@ int sysctl_probe_main(probe_ctx *ctx, void *probe_arg)
128129
ofts = oval_fts_open_prefixed(prefix, path_entity, filename_entity, NULL, bh_entity, probe_ctx_getresult(ctx));
129130

130131
if (ofts == NULL) {
131-
dE("oval_fts_open_prefixed(%s, %s) (prefix: %s) failed", PROC_SYS_DIR, ".\\+", prefix);
132132
SEXP_free(path_entity);
133133
SEXP_free(filename_entity);
134134
SEXP_free(bh_entity);
135135
SEXP_free(name_entity);
136136

137-
return (PROBE_EFATAL);
137+
if (prefix != NULL) {
138+
DIR *d = opendir(prefix);
139+
if (d != NULL) {
140+
closedir(d);
141+
return PROBE_ESUCCESS;
142+
}
143+
dW("Can't open prefix directory '%s': %s", prefix, strerror(errno));
144+
}
145+
146+
dE("oval_fts_open_prefixed(%s, %s, %s, ...) failed", prefix, PROC_SYS_DIR, ".*");
147+
return PROBE_EFATAL;
138148
}
139149

140150
while ((ofts_ent = oval_fts_read(ofts)) != NULL) {

0 commit comments

Comments
 (0)