-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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.copyFile on Mac OS does not respect permissions #26936
Comments
I'm able to replicate this bug on Mojave. Seems like libuv is somehow running |
Confirmed with Node.js 8.x, 10.x, 11.x, and current master branch. ( |
I tried adding this to libuv's // Turn off unlinking of the destination file.
// Refs: https://github.com/nodejs/node/issues/26936
flags &= ~(1 << 21); /* COPYFILE_UNLINK */ (Of course, it's entirely likely I'm doing the bit math wrong or something simple like that.....) |
I'm not a macOS person, but being able to bypass file permissions sounds like an OS bug. |
This seems to be related to permissions and probably not a bug we can control. I'm also seeing no error by default, but if I run with |
Yeah, definitely agree after playing around with different |
|
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)
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
I had recently noticed this behavior divergence also, as it can occur in the context of symlinks (hard or soft): libuv/libuv#2199 (comment). Turning that into an issue has been on my TODO list (and providing analysis on what it seems like it should do), but I think this should already address it. I was actually a bit surprised by that the proposed behavior here is the desired choice, since it means that a But it seems that what libuv does on unix is the explicit choice for the C++17 standard for Shell test script:
|
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>
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>
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>
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>
This was fixed by #27241. |
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>
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>
v11.2.0
Darwin iMac.local 18.2.0 Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64 x86_64
When setting a file mode to
444
usingchmodSync
, then trying to copy another file over it, on Windows and on Linux,copyFile
will throw an error, but on a Mac it does not, and it will override the filei even check the
stat.mode
usingparseInt(fs.statSync(dest).mode.toString(8), 10)
and it does in fact say100444
This is a sample when everything is working well
https://repl.it/repls/CylindricalGlisteningCondition
However, when i run it on my mac, I get this
Thanks
The text was updated successfully, but these errors were encountered: