diff --git a/cf-agent/verify_files_utils.c b/cf-agent/verify_files_utils.c index 440f7cd97c..91e81f64c5 100644 --- a/cf-agent/verify_files_utils.c +++ b/cf-agent/verify_files_utils.c @@ -70,6 +70,7 @@ #include /* GetGroupName(), GetUserName() */ #include +#include "cf3.defs.h" #define CF_RECURSION_LIMIT 100 @@ -1569,6 +1570,13 @@ bool CopyRegularFile(EvalContext *ctx, const char *source, const char *dest, con } mode &= 0777; /* Never preserve SUID bit */ + /* If perms are promised for this file, use those instead */ + if ((attr->perms.plus != CF_SAMEMODE) && (attr->perms.minus != CF_SAMEMODE)) + { + mode |= attr->perms.plus; + mode &= ~(attr->perms.minus); + } + if (!CopyRegularFileNet(source, ToChangesPath(new), sstat->st_size, attr->copy.encrypt, conn, mode)) {