Skip to content

Commit aa26cb1

Browse files
committed
copy_from attribute can now override immutable bit
The copy_from 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 0847f0f commit aa26cb1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cf-agent/verify_files_utils.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#include <known_dirs.h>
6868
#include <changes_chroot.h> /* PrepareChangesChroot(), RecordFileChangedInChroot() */
6969
#include <unix.h> /* GetGroupName(), GetUserName() */
70+
#include <override_fsattrs.h>
7071

7172
#include <cf-windows-functions.h>
7273

@@ -1925,7 +1926,8 @@ bool CopyRegularFile(EvalContext *ctx, const char *source, const char *dest, con
19251926
else
19261927
#endif
19271928
{
1928-
if (rename(changes_new, changes_dest) == 0)
1929+
bool override_immutable = EvalContextOverrideImmutableGet(ctx);
1930+
if (OverrideImmutableRename(changes_new, changes_dest, override_immutable))
19291931
{
19301932
RecordChange(ctx, pp, attr, "Moved '%s' to '%s'", new, dest);
19311933
*result = PromiseResultUpdate(*result, PROMISE_RESULT_CHANGE);
@@ -1937,7 +1939,7 @@ bool CopyRegularFile(EvalContext *ctx, const char *source, const char *dest, con
19371939
dest, GetErrorStr());
19381940
*result = PromiseResultUpdate(*result, PROMISE_RESULT_FAIL);
19391941

1940-
if (backupok && (rename(changes_backup, changes_dest) == 0))
1942+
if (backupok && OverrideImmutableRename(changes_backup, changes_dest, override_immutable))
19411943
{
19421944
RecordChange(ctx, pp, attr, "Restored '%s' from '%s'", dest, backup);
19431945
*result = PromiseResultUpdate(*result, PROMISE_RESULT_CHANGE);

0 commit comments

Comments
 (0)