Skip to content

Commit c1d8cd0

Browse files
committed
Atomic permissions during file copy
Temporary file is now set to promised permissions before replacing it with original during remote copy from. Ticket: ENT-13163 Changelog: Commit Signed-off-by: Lars Erik Wik <[email protected]>
1 parent 0338b4d commit c1d8cd0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cf-agent/verify_files_utils.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#include <override_fsattrs.h>
7272

7373
#include <cf-windows-functions.h>
74+
#include "cf3.defs.h"
7475

7576
#define CF_RECURSION_LIMIT 100
7677

@@ -1570,6 +1571,13 @@ bool CopyRegularFile(EvalContext *ctx, const char *source, const char *dest, con
15701571
}
15711572
mode &= 0777; /* Never preserve SUID bit */
15721573

1574+
/* If perms are promised for this file, use those instead */
1575+
if ((attr->perms.plus != CF_SAMEMODE) && (attr->perms.minus != CF_SAMEMODE))
1576+
{
1577+
mode |= attr->perms.plus;
1578+
mode &= ~(attr->perms.minus);
1579+
}
1580+
15731581
if (!CopyRegularFileNet(source, dest, ToChangesPath(new),
15741582
sstat->st_size, attr->copy.encrypt, conn, mode))
15751583
{

0 commit comments

Comments
 (0)