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

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