-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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.stat() and fs.lstat() cannot read the stats of a file with denied permissions on Windows #35853
Comments
I am not a Windows expert, but I just noticed that your command will also make a |
I succeeded in reading the read-only file stats in Windows 10. First, I unset all inherited file permissions, then set file to read-only using these commands:
It makes our file only readable without any other inherited permissions. Then read the file stats using:
|
@mmomtchev hmm, for me the The default file managers (File Explorer on Windows and Files on Ubuntu) can still read the attributes of a file that has all permissions denied for Everyone (all users, even for the admin). I'm specifically trying to remove all permissions from a file for all users to protect it form editing / modification / renaming / deletion. But the problem is, when I do that, Node.js can no longer read the stats of the file on Windows specifically. On Ubuntu it works properly - even if all permissions denied for all users (even admin) - Node.js can still read the stats:
|
@peZhmanParsaee for some reason. your solution doesn't work for me - if I remove all permissions except READ, Node still cannot read the stats on Windows (even though, on Ubuntu it can): 1. Protect file from modification:
2. Try to read protected file's stats:
3. Grant read permissions and try to read stats again (same result):
4. Give the file all permissions back and try to read stats again (only now it can read it):
|
(Not all of us are guys. Consider using everyone, people, friends, folks, or something like that.) I imagine this would need to be solved by in libuv.
Short of finding a fix for |
@nodejs/platform-windows @nodejs/libuv |
@Trott thanks for the reply. I will open an issue there.
Sorry, I thought "guys" was a gender neutral word, I'm not a native English speaker. |
Is there a workaround? I am hitting the same issue when using Shelljs's rm on Windows to delete some tmp files running on Node 20 https://github.com/zeromq/zeromq.js/actions/runs/11680287554/job/32522968243 > zeromq@6.1.1 clean.temp D:\a\zeromq.js\zeromq.js
> shx rm -rf ./tmp && shx mkdir -p ./tmp
D:\a\zeromq.js\zeromq.js\node_modules\.pnpm\shelljs@0.8.5\node_modules\shelljs\src\common.js:399
throw e;
^
Error [ShellJSInternalError]: EACCES: permission denied, lstat 'D:\a\zeromq.js\zeromq.js\tmp\ipc-5008'
at Object.lstatSync (node:fs:1641:25)
at Object.statNoFollowLinks (D:\a\zeromq.js\zeromq.js\node_modules\.pnpm\shelljs@0.8.5\node_modules\shelljs\src\common.js:290:23)
at rmdirSyncRecursive (D:\a\zeromq.js\zeromq.js\node_modules\.pnpm\shelljs@0.8.5\node_modules\shelljs\src\rm.js:28:27)
at handleDirectory (D:\a\zeromq.js\zeromq.js\node_modules\.pnpm\shelljs@0.8.5\node_modules\shelljs\src\rm.js:110:5)
at D:\a\zeromq.js\zeromq.js\node_modules\.pnpm\shelljs@0.8.5\node_modules\shelljs\src\rm.js:192:7
at Array.forEach (<anonymous>)
at _rm (D:\a\zeromq.js\zeromq.js\node_modules\.pnpm\shelljs@0.8.5\node_modules\shelljs\src\rm.js:1[73](https://github.com/zeromq/zeromq.js/actions/runs/11680287554/job/32522968243#step:20:74):9)
at D:\a\zeromq.js\zeromq.js\node_modules\.pnpm\shelljs@0.8.5\node_modules\shelljs\src\common.js:384:25
at shx (D:\a\zeromq.js\zeromq.js\node_modules\.pnpm\shx@0.3.4\node_modules\shx\lib\shx.js:132:37)
at run (D:\a\zeromq.js\zeromq.js\node_modules\.pnpm\shx@0.3.4\node_modules\shx\lib\cli.js:20:31) {
errno: -4092,
code: 'EACCES',
syscall: 'lstat',
path: 'D:\\a\\zeromq.js\\zeromq.js\\tmp\\ipc-5008'
} |
What is the expected behavior?
A similar issue #22577 has been closed 2 years ago, but the issue hasn't been fixed.
Node.js cannot read the
stats
of immutable files (files with all permissions denied) on Windows. I'm not talking about the contents, just the stats.Example:
After you deny all permissions to a file (to protect it from being deleted or modified), the default Windows File Explorer can still read the file's stats (name, size, etc) but Node.js throws
EPERM: operation not permitted, lstat
:This command effectively denies all modification permissions (delete, rename, write) for Everyone (
*S-1-1-0
).What do you see instead?
Windows 10:
Linux ubuntu 20.01:
MacOS:
Haven't tested
The text was updated successfully, but these errors were encountered: