Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs: remove macOS-specific copyfile(3) #2233

Closed
wants to merge 4 commits into from
Closed

Conversation

Trott
Copy link
Contributor

@Trott Trott commented Mar 27, 2019

Using copyfile(3) on macOS apparently results in situations where file
permissions are ignored. Using the same code for other UNIX-like
operating systems seems to fix the issue.

Refs: nodejs/node#26936 (comment)

@cjihrig

Using copyfile(3) on macOS apparently results in situations where file
permissions are ignored. Using the same code for other UNIX-like
operating systems seems to fix the issue.

Refs: nodejs/node#26936 (comment)
@Trott Trott marked this pull request as ready for review March 27, 2019 06:19
Trott added a commit to Trott/io.js that referenced this pull request Mar 27, 2019
On macOS, fs.copyFile() may not respect file permissions. There is a PR
for libuv that should fix this, but until it lands and we can either
float a patch or upgrade libuv, have a known_issues test.

Ref: nodejs#26936
Ref: libuv/libuv#2233
@Trott
Copy link
Contributor Author

Trott commented Mar 27, 2019

(Seems like this should get a test, but I don't know enough about libuv's tests to write one quickly so I'm going to sleep now. If someone else writes the test or leaves me hints or links, awesome. I do have an open PR to add a test to Node.js for this. If that's sufficient, great.) EDIT: Actually, the test setup looks straightforward. 👍

@cjihrig
Copy link
Contributor

cjihrig commented Mar 27, 2019

Please add a test case in test/test-fs-copyfile.c with the reproduction from the Node issue. It should fail using the macOS code and pass with your changes.

@thefourtheye
Copy link
Contributor

Do we generally report these sort of bugs to the respective projects?

Add test to test-fs-copyfile.c to check that uv_fs_copyfile() respects
destination file permissions. Previously, in macOS, it did not.
@Trott
Copy link
Contributor Author

Trott commented Mar 27, 2019

Test added. PTAL.

@Trott
Copy link
Contributor Author

Trott commented Mar 27, 2019

(The test fails for me on Mojave with current libuv src but passes with the changes in this PR.)

@Trott
Copy link
Contributor Author

Trott commented Mar 27, 2019

Not sure if this is the right way to run CI on libuv, but it seems like it probably is?: https://ci.nodejs.org/view/libuv/job/libuv-test-pipeline/49/

@cjihrig
Copy link
Contributor

cjihrig commented Mar 27, 2019

Not sure if this is the right way to run CI on libuv

I generally use https://ci.nodejs.org/view/libuv/job/libuv-test-commit/. And, if you want to test in the context of Node's test suite: https://ci.nodejs.org/view/libuv/job/libuv-in-node/

@Trott
Copy link
Contributor Author

Trott commented Mar 27, 2019

CI: https://ci.nodejs.org/view/libuv/job/libuv-test-commit/1329/
Other CI: https://ci.nodejs.org/view/libuv/job/libuv-in-node/86/

Looks like my test doesn't compile on Windows?

@cjihrig
Copy link
Contributor

cjihrig commented Mar 27, 2019

Looks like my test doesn't compile on Windows?

Hi! Welcome to libuv 👋

On a more serious note, I think you can #ifdef the test out on Windows (this is done in other tests like test/test-pipe-set-fchmod.c) because the permissions don't really transfer over there.

@Trott
Copy link
Contributor Author

Trott commented Mar 27, 2019

OK, used #ifndef to skip the test on Windows. CI runs again:

https://ci.nodejs.org/view/libuv/job/libuv-test-commit/1330/
https://ci.nodejs.org/view/libuv/job/libuv-in-node/87/

@cjihrig
Copy link
Contributor

cjihrig commented Mar 27, 2019

The libuv CI is OK. The failures are #2234. The failures in the Node CI seem unrelated, although it would be preferable if macOS passed there.

@Trott
Copy link
Contributor Author

Trott commented Mar 27, 2019

The failures in the Node CI seem unrelated, although it would be preferable if macOS passed there.

Couldn't figure out how to quickly/easily rebuild just macOS, so here's a full re-run to see what happens:

https://ci.nodejs.org/view/libuv/job/libuv-in-node/89/

@Trott
Copy link
Contributor Author

Trott commented Mar 28, 2019

(CI re-run is yellow, which I imagine is close-enough to green.)

Trott added a commit to Trott/io.js that referenced this pull request Mar 30, 2019
On macOS, fs.copyFile() may not respect file permissions. There is a PR
for libuv that should fix this, but until it lands and we can either
float a patch or upgrade libuv, have a known_issues test.

Ref: nodejs#26936
Ref: libuv/libuv#2233

PR-URL: nodejs#26939
Refs: nodejs#26936
Refs: libuv/libuv#2233
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
@cjihrig
Copy link
Contributor

cjihrig commented Mar 31, 2019

Now that nodejs/node#26939 landed in Node, I ran the libuv+Node integration CI again. I would expect the new test in that PR, test/known_issues/test-fs-copyfile-respect-permissions.js, to fail on macOS when built with this PR. That's not what I'm seeing though.

Here is the new CI run https://ci.nodejs.org/view/libuv/job/libuv-in-node/90/ where macOS comes back green.

@cjihrig
Copy link
Contributor

cjihrig commented Mar 31, 2019

I think nodejs/node#27024 addresses the issue, meaning this is still 👍

BethGriggs pushed a commit to nodejs/node that referenced this pull request Apr 5, 2019
On macOS, fs.copyFile() may not respect file permissions. There is a PR
for libuv that should fix this, but until it lands and we can either
float a patch or upgrade libuv, have a known_issues test.

Ref: #26936
Ref: libuv/libuv#2233

PR-URL: #26939
Refs: #26936
Refs: libuv/libuv#2233
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
@Trott
Copy link
Contributor Author

Trott commented Apr 5, 2019

Anything more for me to do before this is merge-able?

BethGriggs pushed a commit to nodejs/node that referenced this pull request Apr 8, 2019
On macOS, fs.copyFile() may not respect file permissions. There is a PR
for libuv that should fix this, but until it lands and we can either
float a patch or upgrade libuv, have a known_issues test.

Ref: #26936
Ref: libuv/libuv#2233

PR-URL: #26939
Refs: #26936
Refs: libuv/libuv#2233
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
@cjihrig
Copy link
Contributor

cjihrig commented Apr 9, 2019

I don't think there is anything left to do, but I'm going to run the Node integration CI once more: https://ci.nodejs.org/view/libuv/job/libuv-in-node/91/

@cjihrig
Copy link
Contributor

cjihrig commented Apr 9, 2019

The integration CI looks good. The only failure was test/known_issues/test-fs-copyfile-respect-permissions.js, which is expected because it's a known issue that gets fixed by this PR. I'll move that test once I update Node with the new libuv release.

cjihrig pushed a commit that referenced this pull request Apr 11, 2019
Using copyfile(3) on macOS apparently results in situations where file
permissions are ignored. Using the same code for other UNIX-like
operating systems seems to fix the issue.

Refs: nodejs/node#26936 (comment)
PR-URL: #2233
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
cjihrig pushed a commit that referenced this pull request Apr 11, 2019
Add test to test-fs-copyfile.c to check that uv_fs_copyfile() respects
destination file permissions. Previously, in macOS, it did not.

PR-URL: #2233
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
@cjihrig
Copy link
Contributor

cjihrig commented Apr 11, 2019

Landed in d0fb86c...c7b87b0. Thanks, and congrats on your first commit(s).

@devongovett
Copy link

This seems to remove support for COPYFILE_FICLONE and COPYFILE_FICLONE_FORCE on macOS. I get an ENOSYS error when using the later in node 12. Would be nice to be able to optionally use copy on write for fast copying without shelling out to cp -c.

MylesBorins pushed a commit to nodejs/node that referenced this pull request May 16, 2019
On macOS, fs.copyFile() may not respect file permissions. There is a PR
for libuv that should fix this, but until it lands and we can either
float a patch or upgrade libuv, have a known_issues test.

Ref: #26936
Ref: libuv/libuv#2233

PR-URL: #26939
Refs: #26936
Refs: libuv/libuv#2233
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
MylesBorins pushed a commit to nodejs/node that referenced this pull request May 16, 2019
On macOS, fs.copyFile() may not respect file permissions. There is a PR
for libuv that should fix this, but until it lands and we can either
float a patch or upgrade libuv, have a known_issues test.

Ref: #26936
Ref: libuv/libuv#2233

PR-URL: #26939
Refs: #26936
Refs: libuv/libuv#2233
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
@Artoria2e5
Copy link
Contributor

@devongovett I agree that this change may be regressive. Since we are doing the chmod stuff anyways on the normal path, maybe I can try restoring it. As long as the test passes we are in the clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants