Skip to content

Commit 66679f0

Browse files
committed
Print environment variables
If OpenSCAP is executed with verbosity level INFO or DEVEL all environment variable values that can affect OpenSCAP behavior will be listed at the beginning of the log. Fixes: #2063
1 parent 3222734 commit 66679f0

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

docs/manual/manual.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,9 @@ not considered local by the scanner:
16361636

16371637
== List of accepted environment variables
16381638

1639+
OpenSCAP accepts the following environment variables.
1640+
If OpenSCAP is executed with verbosity level INFO or DEVEL their runtime values will be listed at the beginning of the log.
1641+
16391642
* `OSCAP_CHECK_ENGINE_PLUGIN_DIR` - Defines path to a directory that contains plug-in libraries implementing additional check engines, eg. SCE.
16401643
* `OSCAP_CONTAINER_VARS` - Additional environment variables read by environmentvariable58_probe. The variables are separated by `\n`. It is used by `oscap-podman` and `oscap-docker` scripts during container scanning.
16411644
* `OSCAP_EVALUATION_TARGET` - Change value of target facts `urn:xccdf:fact:identifier` and `urn:xccdf:fact:asset:identifier:ein` in XCCDF results. Used during offline scanning to pass the name of the target system.

src/common/debug.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,27 @@ void __oscap_debuglog_object (const char *file, const char *fn, size_t line, int
295295
debug_message_devel_metadata(file, fn, line);
296296
debug_message_end();
297297
}
298+
299+
void oscap_print_env_vars()
300+
{
301+
const char *known_env_vars[] = {
302+
"OSCAP_CHECK_ENGINE_PLUGIN_DIR",
303+
"OSCAP_CONTAINER_VARS",
304+
"OSCAP_EVALUATION_TARGET",
305+
"OSCAP_FULL_VALIDATION",
306+
"OSCAP_OVAL_COMMAND_OPTIONS",
307+
"OSCAP_PCRE_EXEC_RECURSION_LIMIT",
308+
"OSCAP_PROBE_ROOT",
309+
"SEXP_VALIDATE_DISABLE",
310+
"SOURCE_DATE_EPOCH",
311+
"OSCAP_PROBE_MEMORY_USAGE_RATIO",
312+
"OSCAP_PROBE_MAX_COLLECTED_ITEMS",
313+
"OSCAP_PROBE_IGNORE_PATHS",
314+
NULL
315+
};
316+
dI("Using environment variables:");
317+
for (int i = 0; known_env_vars[i]; i++) {
318+
char *env_var_val = getenv(known_env_vars[i]);
319+
dI("%s='%s'", known_env_vars[i], env_var_val ? env_var_val : "");
320+
}
321+
}

src/common/public/oscap_debug.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ OSCAP_API bool oscap_set_verbose(const char *verbosity_level, const char *filena
6262
*/
6363
OSCAP_API oscap_verbosity_levels oscap_verbosity_level_from_cstr(const char *level_name);
6464

65+
/**
66+
* Print an informational message (verbose level INFO) listing the values
67+
* of all environment variables known by oscap.
68+
* See the "List of accepted environment variables" section of the OpenSCAP User Manual.
69+
*/
70+
OSCAP_API void oscap_print_env_vars(void);
71+
6572
#if defined(_WIN32)
6673
int setenv(const char *name, const char *value, int overwrite);
6774
#endif

utils/oscap-tool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ int oscap_module_process(struct oscap_module *module, int argc, char **argv)
386386
if (!oscap_set_verbose(action.verbosity_level, action.f_verbose_log)) {
387387
goto cleanup;
388388
}
389+
oscap_print_env_vars();
389390
ret = oscap_module_call(&action);
390391
goto cleanup;
391392
}

0 commit comments

Comments
 (0)