Blame SOURCES/openscap-1.3.4-fix-environmentvariable58-regression.patch

788673
diff --git a/src/OVAL/probes/independent/environmentvariable58_probe.c b/src/OVAL/probes/independent/environmentvariable58_probe.c
788673
index 552ce6700..77233aeeb 100644
788673
--- a/src/OVAL/probes/independent/environmentvariable58_probe.c
788673
+++ b/src/OVAL/probes/independent/environmentvariable58_probe.c
788673
@@ -96,32 +96,32 @@ static int read_environment(SEXP_t *pid_ent, SEXP_t *name_ent, probe_ctx *ctx)
788673
 	ssize_t buffer_used;
788673
 	size_t buffer_size;
788673
 
788673
+	const char *extra_vars = getenv("OSCAP_CONTAINER_VARS");
788673
+	if (extra_vars && *extra_vars) {
788673
+		char *vars = strdup(extra_vars);
788673
+		char *tok, *eq_chr, *str, *strp;
788673
+
788673
+		for (str = vars; ; str = NULL) {
788673
+			tok = strtok_r(str, "\n", &strp;;
788673
+			if (tok == NULL)
788673
+				break;
788673
+			eq_chr = strchr(tok, '=');
788673
+			if (eq_chr == NULL)
788673
+				continue;
788673
+			PROBE_ENT_I32VAL(pid_ent, pid, pid = -1;, pid = 0;);
788673
+			collect_variable(tok, eq_chr - tok, pid, name_ent, ctx);
788673
+		}
788673
+
788673
+		free(vars);
788673
+		return 0;
788673
+	}
788673
+
788673
 	const char *prefix = getenv("OSCAP_PROBE_ROOT");
788673
 	snprintf(path, PATH_MAX, "%s/proc", prefix ? prefix : "");
788673
 	d = opendir(path);
788673
 	if (d == NULL) {
788673
-		const char *extra_vars = getenv("OSCAP_CONTAINER_VARS");
788673
-		if (!extra_vars) {
788673
-			dE("Can't read %s/proc: errno=%d, %s.", prefix ? prefix : "", errno, strerror(errno));
788673
-			return PROBE_EACCESS;
788673
-		} else {
788673
-			char *vars = strdup(extra_vars);
788673
-			char *tok, *eq_chr, *str, *strp;
788673
-
788673
-			for (str = vars; ; str = NULL) {
788673
-				tok = strtok_r(str, "\n", &strp;;
788673
-				if (tok == NULL)
788673
-					break;
788673
-				eq_chr = strchr(tok, '=');
788673
-				if (eq_chr == NULL)
788673
-					continue;
788673
-				PROBE_ENT_I32VAL(pid_ent, pid, pid = -1;, pid = 0;);
788673
-				collect_variable(tok, eq_chr - tok, pid, name_ent, ctx);
788673
-			}
788673
-
788673
-			free(vars);
788673
-			return 0;
788673
-		}
788673
+		dE("Can't read %s/proc: errno=%d, %s.", prefix ? prefix : "", errno, strerror(errno));
788673
+		return PROBE_EACCESS;
788673
 	}
788673
 
788673
 	if ((buffer = realloc(NULL, BUFFER_SIZE)) == NULL) {