Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uplib: mask mode_t type of arguments with 0o777 #20636
Conversation
nodejs-github-bot
added
the
lib / src
label
May 9, 2018
joyeecheung
reviewed
May 9, 2018
| @@ -62,7 +62,7 @@ function closeSync() { | |||
| } | |||
|
|
|||
|
|
|||
| // On Windows chmod is only able to manipulate read-only bit | |||
This comment has been minimized.
This comment has been minimized.
joyeecheung
May 9, 2018
•
Author
Member
It feels pretty strange to talk about the read-only attribute on windows in this context (attempting to model the Windows permission model after the unix one) so I just changed this to write permission.
This comment has been minimized.
This comment has been minimized.
vsemozhetbyt
added
the
fs
label
May 9, 2018
joyeecheung
reviewed
May 9, 2018
| @@ -1089,6 +1089,9 @@ For example, the octal value `0o765` means: | |||
| * The group may read and write the file. | |||
| * Others may read and execute the file. | |||
|
|
|||
| Caveats: on Windows only the write permission can be changed, and there is | |||
This comment has been minimized.
This comment has been minimized.
joyeecheung
May 9, 2018
•
Author
Member
I have not tried all the combinations but I think on Windows effectively you can only change the permission to either 666 or 444 with our API
vsemozhetbyt
reviewed
May 9, 2018
| @@ -1987,7 +1990,7 @@ changes: | |||
| --> | |||
|
|
|||
| * `path` {string|Buffer|URL} | |||
| * `mode` {integer} **Default:** `0o777` | |||
| * `mode` {integer} **Default:** `0o777`. Not supported on Windows. | |||
This comment has been minimized.
This comment has been minimized.
vsemozhetbyt
May 9, 2018
•
Member
Nit: Default section usually goes last (and doctools expect it to be the last).
mscdex
reviewed
May 9, 2018
| } | ||
|
|
||
| if (typeof value === 'string') { | ||
| if (!octalReg.test(value)) { |
This comment has been minimized.
This comment has been minimized.
mscdex
May 9, 2018
Contributor
Why do we need this? If the number is not a parseable octal value, NaN will be returned, which we check for anyway.
This comment has been minimized.
This comment has been minimized.
targos
May 9, 2018
Member
parseInt will not return NaN for strings like '666abc'.
But I agree there seems to be redundancy. Could there be cases where the string passes the regex and the value cannot be parsed? I don't think so.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
joyeecheung
May 9, 2018
Author
Member
By the way, https://github.com/tc39/proposal-number-fromstring (currently in Stage 1) is designed for this situation
This comment has been minimized.
This comment has been minimized.
targos
May 9, 2018
Member
@joyeecheung what I meant is that the Number.isNaN(parsed) check can be removed. Unless I'm missing an edge case, it can never be true after the regex check.
mscdex
reviewed
May 9, 2018
|
|
||
| if (typeof value === 'number') { | ||
| if (!Number.isInteger(value)) { | ||
| throw new ERR_OUT_OF_RANGE(name, 'an integer', value); |
This comment has been minimized.
This comment has been minimized.
mscdex
May 9, 2018
Contributor
Should we really be using an out of range error type when it's a value type issue?
This comment has been minimized.
This comment has been minimized.
joyeecheung
May 9, 2018
Author
Member
@mscdex JavaScript only has one number type (at least for now) so it could be seen both ways. I went with ERR_OUT_OF_RANGE so this can still be semver-patch.
joyeecheung
changed the title
Mode validator
lib: mask mode_t type of arguments with 0o777
May 9, 2018
joyeecheung
force-pushed the
joyeecheung:mode-validator
branch
2 times, most recently
from
470ce3d
to
48f9e8a
May 14, 2018
This comment has been minimized.
This comment has been minimized.
|
Updated the docs to move the defaults to the end of the explanation of arguments and removed the abundant |
This comment has been minimized.
This comment has been minimized.
|
Doc LGTM) |
This comment has been minimized.
This comment has been minimized.
|
CI is green..can I have some reviews please? cc @nodejs/fs |
jasnell
approved these changes
May 16, 2018
apapirovski
approved these changes
May 16, 2018
This comment has been minimized.
This comment has been minimized.
|
CITGM just in case: master: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1414/ |
This comment has been minimized.
This comment has been minimized.
|
@joyeecheung Apart from CITGM, this is ready to land, right? |
This comment has been minimized.
This comment has been minimized.
|
@addaleax Yes |
This comment has been minimized.
This comment has been minimized.
|
CITGM failures looks irrelevant, two no space left on device failures, one rename with EPERM, and another known failures of thread-sleep |
joyeecheung
added some commits
May 9, 2018
This comment has been minimized.
This comment has been minimized.
|
#19811 added tests that expect mode > 0o777 to be rejected. Replaced to expect those operations not to fail. It could use some better coverage to make sure the chmod in fs promises actually work but those can be done in a later PR IMO, since it doesn't do that for 0o666 anyway. |
This comment has been minimized.
This comment has been minimized.
joyeecheung
force-pushed the
joyeecheung:mode-validator
branch
from
48f9e8a
to
37af759
May 17, 2018
This comment has been minimized.
This comment has been minimized.
|
Landed in 0d9500d...f9de6f5, thanks! |
joyeecheung commentedMay 9, 2018
•
edited
doc: document file mode caveats on Windows
manipulated, and there is no distinction among owner, group
or others (no implementation to model the ACL after UNIX permissions).
lib: mask mode_t type of arguments with 0o777
validateAndMaskModevalidator thatvalidates
mode_targuments and mask them with 0o777if they are 32-bit unsigned integer or octal string
to be more consistent with POSIX APIs.
consistency.
Fixes: #20498
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes