adamwill / rpms / openscap

Forked from rpms/openscap 3 years ago
Clone

Blame SOURCES/openscap-1.2.17-use-chroot-for-textfilecontent.patch

d67a77
From ff8e3a420f294339317f7d8d0e16f04a03511269 Mon Sep 17 00:00:00 2001
d67a77
From: Martin Preisler <mpreisle@redhat.com>
d67a77
Date: Wed, 18 Apr 2018 12:02:46 -0400
d67a77
Subject: [PATCH] Revert "Enables offline scan without chroot in
d67a77
 textfilecontent and textfilecontent54 probes"
d67a77
d67a77
This reverts commit 908d002c68e43a3d3c3bede128c535fbee815a10.
d67a77
---
d67a77
 src/OVAL/probes/independent/textfilecontent.c   | 20 ++------------------
d67a77
 src/OVAL/probes/independent/textfilecontent54.c | 21 ++-------------------
d67a77
 2 files changed, 4 insertions(+), 37 deletions(-)
d67a77
d67a77
diff --git a/src/OVAL/probes/independent/textfilecontent.c b/src/OVAL/probes/independent/textfilecontent.c
d67a77
index 2edba7a9b..961cd98cb 100644
d67a77
--- a/src/OVAL/probes/independent/textfilecontent.c
d67a77
+++ b/src/OVAL/probes/independent/textfilecontent.c
d67a77
@@ -327,13 +327,9 @@ static int process_file(const char *path, const char *filename, void *arg)
d67a77
 	return ret;
d67a77
 }
d67a77
 
d67a77
-void probe_offline_mode ()
d67a77
-{
d67a77
-	probe_setoption(PROBEOPT_OFFLINE_MODE_SUPPORTED, PROBE_OFFLINE_OWN);
d67a77
-}
d67a77
-
d67a77
 void *probe_init(void)
d67a77
 {
d67a77
+	probe_setoption(PROBEOPT_OFFLINE_MODE_SUPPORTED, PROBE_OFFLINE_CHROOT);
d67a77
 	return NULL;
d67a77
 }
d67a77
 
d67a77
@@ -341,8 +337,6 @@ int probe_main(probe_ctx *ctx, void *arg)
d67a77
 {
d67a77
 	SEXP_t *path_ent, *filename_ent, *line_ent, *behaviors_ent, *filepath_ent, *probe_in;
d67a77
 	char *pattern;
d67a77
-	char path_with_root[PATH_MAX + 1];
d67a77
-	unsigned int root_len = 0;
d67a77
 
d67a77
 	OVAL_FTS    *ofts;
d67a77
 	OVAL_FTSENT *ofts_ent;
d67a77
@@ -389,22 +383,12 @@ int probe_main(probe_ctx *ctx, void *arg)
d67a77
 	pfd.filename_ent = filename_ent;
d67a77
 	pfd.ctx = ctx;
d67a77
 
d67a77
-	path_with_root[PATH_MAX] = '\0';
d67a77
-	if (OSCAP_GSYM(offline_mode) & PROBE_OFFLINE_OWN) {
d67a77
-		strncpy(path_with_root, getenv("OSCAP_PROBE_ROOT"), PATH_MAX);
d67a77
-		root_len = strlen(path_with_root);
d67a77
-
d67a77
-		if (path_with_root[root_len - 1] == FILE_SEPARATOR)
d67a77
-			--root_len;
d67a77
-	}		
d67a77
-
d67a77
 	if ((ofts = oval_fts_open(path_ent, filename_ent, filepath_ent, behaviors_ent, probe_ctx_getresult(ctx))) != NULL) {
d67a77
 		while ((ofts_ent = oval_fts_read(ofts)) != NULL) {
d67a77
 			if (ofts_ent->fts_info == FTS_F
d67a77
 			    || ofts_ent->fts_info == FTS_SL) {
d67a77
-				strncpy(path_with_root + root_len, ofts_ent->path, PATH_MAX - root_len);
d67a77
 				// todo: handle return code
d67a77
-				process_file(path_with_root, ofts_ent->file, &pfd;;
d67a77
+				process_file(ofts_ent->path, ofts_ent->file, &pfd;;
d67a77
 			}
d67a77
 			oval_ftsent_free(ofts_ent);
d67a77
 		}
d67a77
diff --git a/src/OVAL/probes/independent/textfilecontent54.c b/src/OVAL/probes/independent/textfilecontent54.c
d67a77
index 1f76ee4e9..ecff6057b 100644
d67a77
--- a/src/OVAL/probes/independent/textfilecontent54.c
d67a77
+++ b/src/OVAL/probes/independent/textfilecontent54.c
d67a77
@@ -347,13 +347,9 @@ static int process_file(const char *path, const char *file, void *arg)
d67a77
 	return ret;
d67a77
 }
d67a77
 
d67a77
-void probe_offline_mode ()
d67a77
-{
d67a77
-	probe_setoption(PROBEOPT_OFFLINE_MODE_SUPPORTED, PROBE_OFFLINE_OWN);
d67a77
-}
d67a77
-
d67a77
 void *probe_init(void)
d67a77
 {
d67a77
+  probe_setoption(PROBEOPT_OFFLINE_MODE_SUPPORTED, PROBE_OFFLINE_CHROOT);
d67a77
   return NULL;
d67a77
 }
d67a77
 
d67a77
@@ -375,8 +371,6 @@ int probe_main(probe_ctx *ctx, void *arg)
d67a77
 #endif
d67a77
 	OVAL_FTS    *ofts;
d67a77
 	OVAL_FTSENT *ofts_ent;
d67a77
-	char path_with_root[PATH_MAX + 1];
d67a77
-	unsigned int root_len = 0;
d67a77
 
d67a77
         (void)arg;
d67a77
 
d67a77
@@ -504,23 +498,12 @@ int probe_main(probe_ctx *ctx, void *arg)
d67a77
 		goto cleanup;
d67a77
 	}
d67a77
 #endif
d67a77
-
d67a77
-	path_with_root[PATH_MAX] = '\0';
d67a77
-	if (OSCAP_GSYM(offline_mode) & PROBE_OFFLINE_OWN) {
d67a77
-		strncpy(path_with_root, getenv("OSCAP_PROBE_ROOT"), PATH_MAX);
d67a77
-		root_len = strlen(path_with_root);
d67a77
-
d67a77
-		if (path_with_root[root_len - 1] == FILE_SEPARATOR)
d67a77
-			--root_len;
d67a77
-	}
d67a77
-
d67a77
 	if ((ofts = oval_fts_open(path_ent, file_ent, filepath_ent, bh_ent, probe_ctx_getresult(ctx))) != NULL) {
d67a77
 		while ((ofts_ent = oval_fts_read(ofts)) != NULL) {
d67a77
 			if (ofts_ent->fts_info == FTS_F
d67a77
 			    || ofts_ent->fts_info == FTS_SL) {
d67a77
-				strncpy(path_with_root + root_len, ofts_ent->path, PATH_MAX - root_len);
d67a77
 				// todo: handle return code
d67a77
-				process_file(path_with_root, ofts_ent->file, &pfd;;
d67a77
+				process_file(ofts_ent->path, ofts_ent->file, &pfd;;
d67a77
 			}
d67a77
 			oval_ftsent_free(ofts_ent);
d67a77
 		}
d67a77
-- 
d67a77
2.14.3
d67a77