Skip to content
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
2 changes: 0 additions & 2 deletions cf-agent/verify_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,6 @@ static PromiseResult VerifyFilePromise(EvalContext *ctx, char *path, const Promi

PromiseResult render_result = WriteContentFromString(ctx, path, &a, pp);
result = PromiseResultUpdate(result, render_result);

goto exit;
}

/* Phase 3b - content editing */
Expand Down
75 changes: 75 additions & 0 deletions tests/acceptance/10_files/unsafe/13_immutable.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
##############################################################################
#
# Test that fsattrs validation is not skipped when combining it with the
# content attribute (see CFE-4569).
#
##############################################################################

body common control
{
inputs => { "../../default.cf.sub" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

bundle agent global
{
vars:
"testfile"
string => "/tmp/13_immutable.txt";
}

body fsattrs immutable(value)
{
immutable => "$(value)";
}

bundle agent init
{
files:
"$(global.testfile)"
delete => tidy,
depends_on => { "testfile is not immutable" };

commands:
"chattr -i $(global.testfile)"
contain => in_shell,
if => fileexists("$(global.testfile)"),
handle => "testfile is not immutable";
}

bundle agent test
{
meta:
"description" -> { "CFE-4569" }
string => "Test that fsattrs validation is not skipped when combining it with the content attribute";

"test_skip_unsupported"
string => "hpux|aix|solaris|windows";

files:
"$(global.testfile)"
content => "You can't touch this",
fsattrs => immutable("true");
}

bundle agent check
{
methods:
"check"
usebundle => dcs_passif_output(".*Immutable.*", "", "lsattr -l $(global.testfile)", "$(this.promise_filename)");
}

bundle agent destroy
{
files:
"$(global.testfile)"
delete => tidy,
depends_on => { "testfile is no longer immutable" };

commands:
"chattr -i $(global.testfile)"
contain => in_shell,
if => fileexists("$(global.testfile)"),
handle => "testfile is no longer immutable";
}
Loading