Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #5724: don't duplicate text blocks when inserting - refs #4650 #516

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rudder-agent/SOURCES/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ localdepends: ./initial-promises ./detect_os.sh ./files ./fusioninventory-agent
$(PATCH) -d ./cfengine-source -p1 < ./patches/cfengine/0006-openvz-support.patch
$(PATCH) -d ./cfengine-source -p1 < ./patches/cfengine/0007-no-runlog.patch
$(PATCH) -d ./cfengine-source -p1 < ./patches/cfengine/0008-fix-promise-evaluation.patch
$(PATCH) -d ./cfengine-source -p1 < ./patches/cfengine/0009-dont-duplicate-text-blocks.patch
# Bootstrap the package using autogen before compilation
cd cfengine-source && NO_CONFIGURE=1 ./autogen.sh

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
commit f13b2b61da12bc4368908b9eae19754ac44c291f
Author: Nicolas CHARLES <nicolas.charles@normation.com>
Date: Tue Nov 4 11:10:46 2014 +0100

Backporting commit 37065c7ac536a8147179eeb091d985abe62d887e from Volker Hilsheimer into CFEngine 3.6.0

diff --git a/cf-agent/files_editline.c b/cf-agent/files_editline.c
index 5ba21e2..6daa826 100644
--- a/cf-agent/files_editline.c
+++ b/cf-agent/files_editline.c
@@ -1650,9 +1650,11 @@ static int InsertCompoundLineAtLocation(EvalContext *ctx, char *chunk, Item **st
bool retval = false;
char buf[CF_EXPANDSIZE];
char *sp;
- int preserve_block = a.sourcetype && (strcmp(a.sourcetype, "preserve_all_lines") == 0 || strcmp(a.sourcetype, "preserve_block") == 0 || strcmp(a.sourcetype, "file_preserve_block") == 0);

- if (!preserve_block && MatchRegion(ctx, chunk, location, NULL, false))
+ int preserve_all_lines = a.sourcetype && strcmp(a.sourcetype, "preserve_all_lines") == 0;
+ int preserve_block = a.sourcetype && (preserve_all_lines || strcmp(a.sourcetype, "preserve_block") == 0 || strcmp(a.sourcetype, "file_preserve_block") == 0);
+
+ if (!preserve_all_lines && MatchRegion(ctx, chunk, location, NULL, false))
{
cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_NOOP, pp, a, "Promised chunk '%s' exists within selected region of %s (promise kept)", pp->promiser, edcontext->filename);
return false;