Skip to content

Commit

Permalink
Fail if regular file pre-exists in copy_tree()
Browse files Browse the repository at this point in the history
Similar to the default behavior of mkdir(2), symlink(2), link(2) and
mknod(2).
  • Loading branch information
cgzones authored and hallyn committed Aug 17, 2022
1 parent dab764d commit 1d28127
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libmisc/copydir.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ static int copy_file (const char *src, const char *dst,
return -1;
}
#endif /* WITH_SELINUX */
ofd = open (dst, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW, statp->st_mode & 07777);
ofd = open (dst, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC | O_NOFOLLOW | O_CLOEXEC, statp->st_mode & 07777);
if ( (ofd < 0)
|| (fchown_if_needed (ofd, statp,
old_uid, new_uid, old_gid, new_gid) != 0)
Expand Down

0 comments on commit 1d28127

Please sign in to comment.