-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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.access
is not reliable in windows7
#7700
Comments
From the documentation:
You probably want:
Good luck. |
@bnoordhuis , when switch to fs.access('C:/Windows/System32/drivers/etc/hosts', fs.W_OK, function(err) {
console.log('err', err); //err null
});
|
Node isn't aware of ACLs, it just looks at the file attributes. If the file doesn't have the read-only attribute set, it's considered writable. |
@bnoordhuis So, you mean there is no way to check |
Cause when i trying to write something into the var fs = require('fs');
fs.access('C:/Windows/System32/drivers/etc/hosts', fs.W_OK, function(err) {
console.log('err', err); //err null
});
fs.writeFile('C:/Windows/System32/drivers/etc/hosts', 'test', function(err) {
console.log(err);//error occurs
}); |
Not with node core. Maybe with a npm module.
That's how it should be. Look up 'TOCTOU'. Check-then-write is an anti-pattern. |
Thanks for your time |
v6.3.0
64-bit (Windows 7)
When performing following code:
I am pretty sure i don't have write permission to the
hosts
file. But it resolvesnull
toerr
.Am i wrong with the usage?
The text was updated successfully, but these errors were encountered: