- **Version**: v6.3.0 - **Platform**: 64-bit (Windows 7) When performing following code: ``` javascript var fs = require('fs'); fs.access('C:/Windows/System32/drivers/etc/hosts', fs.F_OK, function(err) { console.log('err', err); //err null }); ``` I am pretty sure i don't have write permission to the `hosts` file. But it resolves `null` to `err`. Am i wrong with the usage?
Activity
bnoordhuis commentedon Jul 13, 2016
From the documentation:
You probably want:
Good luck.
leftstick commentedon Jul 13, 2016
@bnoordhuis , when switch to
fs.W_OK, still have nothing toerrbnoordhuis commentedon Jul 13, 2016
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.
leftstick commentedon Jul 13, 2016
@bnoordhuis So, you mean there is no way to check
ACLon windows? A stable way?leftstick commentedon Jul 13, 2016
Cause when i trying to write something into the
hostsfile, error thrown:bnoordhuis commentedon Jul 13, 2016
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.
leftstick commentedon Jul 13, 2016
Thanks for your time