Skip to content
Permalink
Browse files

sip_copy_proc: Avoid COPYFILE_CLONE

Apple broke the copyfile(3) interface with macOS 10.13.3 High Sierra as
there is no way any more to make it follow symlinks when COPYFILE_CLONE
is used. According to rdar://problem/36469208 this change was
intentional.

Instead of adding more conditionals to check whether the file to clone
is actually a symlink, just do not attempt to clone it at all but make
a normal copy. This will usually only take a few megabytes of disk space
anyway.

Closes: https://trac.macports.org/ticket/55575
(cherry picked from commit 995dde8)
  • Loading branch information
raimue committed Mar 10, 2018
1 parent 75878a8 commit b58d578a8e1aed0fa186ca059c337589a588e0af
Showing with 5 additions and 7 deletions.
  1. +5 −7 src/pextlib1.0/sip_copy_proc.c
@@ -339,13 +339,11 @@ static char *lazy_copy(const char *path, struct stat *in_st) {
goto lazy_copy_out;
}

// copyfile(3)/clonefile(2) will not preserve SF_RESTRICTED,
// we can safely clone the source file with all metadata
copyfile_flags_t flags = COPYFILE_ALL;
#ifdef COPYFILE_CLONE
flags = COPYFILE_CLONE;
#endif
if (copyfile(path, target_path_temp, NULL, flags) != 0) {
// copyfile(3) will not preserve SF_RESTRICTED,
// we can safely copy the source file with all metadata.
// This cannot use COPYFILE_CLONE as it does not follow symlinks,
// see https://trac.macports.org/ticket/55575
if (copyfile(path, target_path_temp, NULL, COPYFILE_ALL) != 0) {
fprintf(stderr, "sip_copy_proc: copyfile(%s, %s): %s\n", path, target_path_temp, strerror(errno));
goto lazy_copy_out;
}

0 comments on commit b58d578

Please sign in to comment.
You can’t perform that action at this time.