Closed mcollina closed 2 years ago
This test demonstrates how passing a mode doesn't always change to the expected permissions.
Testing fs.open in my local machine I was getting identical results.
On the other hand testing with fs.chmod changed the file permissions as expected, , so this seems to be the way fs.open works at the moment. https://github.com/pinojs/sonic-boom/pull/130#pullrequestreview-852853281
Given that setting permissions with fs.open
seems non-deterministic, and fs.chmod
means nothing in Windows (https://nodejs.org/dist/latest-v16.x/docs/api/fs.html#filehandlechmodmode), I vote we do not attempt to implement this. It puts us in the realm of being system administrators by trying to handle all of the various scenarios that can be devised around file permissions.
Instead, we should document that the use should take care to run their processes as unprivileged users and that any files created should be created in locations where the parent tree has appropriate permissions to deny access to other users.
Given that setting permissions with fs.open seems non-deterministic
Why is it non-deterministic?
Why is it non-deterministic?
The starting sentence of that quote:
This test demonstrates how passing a mode doesn't always change to the expected permissions.
If telling fs.open
to set a mode does not always set that mode, then what is the point?
If telling fs.open to set a mode does not always set that mode, then what is the point?
That's not correct for that test. The problem that is facing is that different OS run their processes with different umask
by default and that specific test is getting filtered by the umask.
I think that is further support for my argument.
Passing the option allows people to do what they like. It's a pass-through parameter to Node.js core for us and it should be documented as such. If people want to use it, that's up to them.
Files created by sonic-boom and pino have the default of
0o666
as every other file created by Node.js: https://nodejs.org/api/fs.html#fsopenpath-flags-mode-callback.We should support making this configurable.