Skip to content

Commit 2cdee22

Browse files
Merge pull request #5868 from larsewi/race
ENT-13163: Atomic permissions during file copy
2 parents 0338b4d + c1d8cd0 commit 2cdee22

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)