Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion cf-agent/verify_files_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
included file COSL.txt.
*/

#include <sys/types.h>
#include <verify_files_utils.h>

#include <actuator.h>
Expand Down Expand Up @@ -1551,8 +1552,25 @@ bool CopyRegularFile(EvalContext *ctx, const char *source, const char *dest, con
return false;
}

/* Use perms from source file if preserve is true, otherwise use perms
* of destination file if it exists, otherwise use default perms. */
mode_t mode;
if (attr->copy.preserve)
{
mode = sstat->st_mode;
}
else if (dest_exists)
{
mode = dest_stat.st_mode;
}
else
{
mode = CF_PERMS_DEFAULT;
}
mode &= 0777; /* Never preserve SUID bit */

if (!CopyRegularFileNet(source, ToChangesPath(new),
sstat->st_size, attr->copy.encrypt, conn, sstat->st_mode))
sstat->st_size, attr->copy.encrypt, conn, mode))
{
RecordFailure(ctx, pp, attr, "Failed to copy file '%s' from '%s'",
source, conn->remoteip);
Expand Down
Loading