Skip to content

Commit baf1c62

Browse files
committed
Rename attribute can now override immutable bit
The rename attribute of the files promise can now override the immutable bit. The disabled file will inherit the immutable trait of the original file. Ticket: ENT-10961, CFE-1840 Changelog: Commit Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 05c439d commit baf1c62

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cf-agent/verify_files_utils.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,10 +2182,10 @@ static PromiseResult VerifyName(EvalContext *ctx, char *path, const struct stat
21822182
{
21832183
if (!FileInRepository(newname))
21842184
{
2185-
if (rename(changes_path, changes_newname) == -1)
2185+
const bool override_immutable = EvalContextOverrideImmutableGet(ctx);
2186+
if (!OverrideImmutableRename(changes_path, changes_newname, override_immutable))
21862187
{
2187-
RecordFailure(ctx, pp, attr, "Error occurred while renaming '%s'. (rename: %s)",
2188-
path, GetErrorStr());
2188+
RecordFailure(ctx, pp, attr, "Error occurred while renaming '%s'", path);
21892189
result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);
21902190
}
21912191
else
@@ -2335,10 +2335,10 @@ static PromiseResult VerifyName(EvalContext *ctx, char *path, const struct stat
23352335

23362336
if (!FileInRepository(newname))
23372337
{
2338-
if (rename(changes_path, changes_newname) == -1)
2338+
const bool override_immutable = EvalContextOverrideImmutableGet(ctx);
2339+
if (!OverrideImmutableRename(changes_path, changes_newname, override_immutable))
23392340
{
2340-
RecordFailure(ctx, pp, attr, "Error occurred while renaming '%s'. (rename: %s)",
2341-
path, GetErrorStr());
2341+
RecordFailure(ctx, pp, attr, "Error occurred while renaming '%s'", path);
23422342
result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);
23432343
free(chrooted_path);
23442344
return result;

0 commit comments

Comments
 (0)