Skip to content

Commit b6d5f15

Browse files
committed
Transformer attribute can now override immutable bit
The transformer attribute of the files promise can now override the immutable bit. Ticket: ENT-10961, CFE-1840 Changelog: Commit Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent f197729 commit b6d5f15

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cf-agent/verify_files_utils.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2000,7 +2000,7 @@ static bool TransformFile(EvalContext *ctx, char *file, const Attributes *attr,
20002000

20012001
if (!IsExecutable(CommandArg0(BufferData(command))))
20022002
{
2003-
RecordFailure(ctx, pp, attr, "Transformer '%s' for file '%s' failed", attr->transformer, file);
2003+
RecordFailure(ctx, pp, attr, " '%s' for file '%s' failed", attr->transformer, file);
20042004
*result = PromiseResultUpdate(*result, PROMISE_RESULT_FAIL);
20052005
BufferDestroy(command);
20062006
return false;
@@ -2043,6 +2043,10 @@ static bool TransformFile(EvalContext *ctx, char *file, const Attributes *attr,
20432043
}
20442044
}
20452045

2046+
const bool override_immutable = EvalContextOverrideImmutableGet(ctx);
2047+
bool was_immutable = false;
2048+
FSAttrsResult res = TemporarilyClearImmutableBit(file, override_immutable, &was_immutable);
2049+
20462050
Log(LOG_LEVEL_INFO, "Transforming '%s' with '%s'", file, command_str);
20472051
if ((pop = cf_popen(changes_command, "r", true)) == NULL)
20482052
{
@@ -2086,6 +2090,8 @@ static bool TransformFile(EvalContext *ctx, char *file, const Attributes *attr,
20862090

20872091
transRetcode = cf_pclose(pop);
20882092

2093+
ResetTemporarilyClearedImmutableBit(file, override_immutable, res, was_immutable);
2094+
20892095
if (VerifyCommandRetcode(ctx, transRetcode, attr, pp, result))
20902096
{
20912097
Log(LOG_LEVEL_INFO, "Transformer '%s' => '%s' seemed to work ok", file, command_str);

0 commit comments

Comments
 (0)