Skip to content

Commit 2eb869f

Browse files
Merge pull request #5870 from larsewi/race-3.21.x
ENT-13163: Atomic permissions during file copy (3.21.x)
2 parents 9d983ee + 7600629 commit 2eb869f

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
@@ -70,6 +70,7 @@
7070
#include <unix.h> /* GetGroupName(), GetUserName() */
7171

7272
#include <cf-windows-functions.h>
73+
#include "cf3.defs.h"
7374

7475
#define CF_RECURSION_LIMIT 100
7576

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

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

0 commit comments

Comments
 (0)