-
Notifications
You must be signed in to change notification settings - Fork 30k
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 fails with "EPERM" for CIFS destination #31170
Comments
I'm also in trouble with copyFile in some Android devices. I can't reproduce the error but a lot of errors as above are reported. |
The relevant bits from the strace log:
Libuv tries to change the destination file's permissions with fchmod() to match the source file but it's rejected by the kernel. I postulate CIFS doesn't like that we're passing in the S_IFREG flag ( diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c
index be256bfca6..2324cb67b6 100644
--- a/deps/uv/src/unix/fs.c
+++ b/deps/uv/src/unix/fs.c
@@ -1092,6 +1092,8 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) {
goto out;
}
+ /* Only use bits 0-11: user/group/other rwx + sticky + sgid + suid. */
+ src_statsbuf.st_mode &= 4095;
dst_flags = O_WRONLY | O_CREAT | O_TRUNC;
if (req->flags & UV_FS_COPYFILE_EXCL) |
I've never built node before, but our sysadmin gave me a RHEL7 and root access so I'll give it a shot and keep you posted. |
Ok, so today has been an adventure. Relevant parts of the stack trace should be below.
|
Thanks for testing that out. I dug through fs/cifs in the linux kernel source tree and it looks like chmod() and fchmod() will always error unless you mount the CIFS share with I suppose that makes sense because UNIX-style permissions don't have a Windows counterpart. Libuv can probably detect this particular condition. I've opened libuv/libuv#2596 to discuss. |
Wow, well that's an easy fix (for getting me up and running). I can confirm that when the CIFS share is mounted with "noperm" copyFile() works like a charm through node. |
uv_fs_copyfile() calls fchmod() to change the target file's permissions to the source file's permissions but that operation errors with EPERM on CIFS shares unless they are mounted with the "noperm" option. Since UNIX-style permissions don't make sense for CIFS anyway, let's handle the error in libuv by recognizing that it's a CIFS share and continuing when that is the case. The same logic probably applies to (a subset of) FUSE file systems but those haven't been whitelisted yet. Fixes: libuv#2596 Refs: nodejs/node#31170
uv_fs_copyfile() calls fchmod() to change the target file's permissions to the source file's permissions but that operation errors with EPERM on CIFS shares unless they are mounted with the "noperm" option. Since UNIX-style permissions don't make sense for CIFS anyway, let's handle the error in libuv by recognizing that it's a CIFS share and continuing when that is the case. The same logic probably applies to (a subset of) FUSE file systems but those haven't been whitelisted yet. Fixes: #2596 Refs: nodejs/node#31170 PR-URL: #2597 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Notable changes: - uv_fs_copyfile() now supports CIFS share destinations. - isatty() now works on IBMi - TTYs are opened with the O_NOCTTY flag. Fixes: nodejs#31170
Notable changes: - uv_fs_copyfile() now supports CIFS share destinations. - isatty() now works on IBMi - TTYs are opened with the O_NOCTTY flag. Fixes: #31170 PR-URL: #31332 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Notable changes: - uv_fs_copyfile() now supports CIFS share destinations. - isatty() now works on IBMi - TTYs are opened with the O_NOCTTY flag. Fixes: nodejs#31170 PR-URL: nodejs#31332 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Notable changes: - uv_fs_copyfile() now supports CIFS share destinations. - isatty() now works on IBMi - TTYs are opened with the O_NOCTTY flag. Fixes: #31170 PR-URL: #31332 Backport-PR-URL: #31969 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Notable changes: - uv_fs_copyfile() now supports CIFS share destinations. - isatty() now works on IBMi - TTYs are opened with the O_NOCTTY flag. Fixes: #31170 PR-URL: #31332 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Notable changes: - uv_fs_copyfile() now supports CIFS share destinations. - isatty() now works on IBMi - TTYs are opened with the O_NOCTTY flag. Fixes: #31170 PR-URL: #31332 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Notable changes: - uv_fs_copyfile() now supports CIFS share destinations. - isatty() now works on IBMi - TTYs are opened with the O_NOCTTY flag. Fixes: nodejs/node#31170 PR-URL: nodejs/node#31332 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Notable changes: - uv_fs_copyfile() now supports CIFS share destinations. - isatty() now works on IBMi - TTYs are opened with the O_NOCTTY flag. Fixes: nodejs/node#31170 PR-URL: nodejs/node#31332 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Notable changes: - uv_fs_copyfile() now supports CIFS share destinations. - isatty() now works on IBMi - TTYs are opened with the O_NOCTTY flag. Fixes: nodejs/node#31170 PR-URL: nodejs/node#31332 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Notable changes: - uv_fs_copyfile() now supports CIFS share destinations. - isatty() now works on IBMi - TTYs are opened with the O_NOCTTY flag. Fixes: nodejs/node#31170 PR-URL: nodejs/node#31332 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
require("fs").copyFile("/local/home/dim/testcopy/test.txt","/transfer/repository/Temp/test2.txt", (err) => { if (err) throw err; console.log('source.txt was copied to destination.txt'); } );
strace: https://gist.github.com/likwidoxigen/54a9f34c82772a84ae0a274994ef2774
The EPERM Error is at line 789, I don't know what else may be relevant so I didn't trim anything.
Using "cp" command works with no problem.
The copy fails if source path is on local system or CIFS share as long as destination path is on the CIFS share.
When files are copied or created on that share they are owned by a different user. So files are being copied as user "dim" and the owner that gets automatically set on the share is "cloudxfer".
If I run the script as the "cloudxfer" user, it all runs fine and everything is great, but if I can copy the file from the command line as "dim" I should be able to use copyFile.
The text was updated successfully, but these errors were encountered: