-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
repl: create history file with mode 0600. #3394
Conversation
3d57ee8
to
9ec50f0
Compare
@@ -88,7 +88,7 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) { | |||
var writing = false; | |||
var pending = false; | |||
repl.pause(); | |||
fs.open(historyPath, 'a+', oninit); | |||
fs.open(historyPath, 'a+', /* 0600 */ 384, oninit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use an octal literal: 0o0600
9ec50f0
to
4e6c697
Compare
LGTM if CI is happy. |
Fixes: #3392 |
Tried it on Windows, and the returned stat is 010666. I guess that's because Windows uses a different permission model; do you think it okay to skip this test on Windows? |
I think so but lets ask @nodejs/platform-windows |
I changed
To just this
So that it would report the actual value. Result is here. So, Windows is creating the file with mode 0666 rather than 0600. The question is: Is this a bug in the code that creates the file or is it a limitation of running the Node.js REPL on the Windows operating system? |
The code uses |
This comment in the
|
From docs of CreateFile:
So privacy on the history file relies on the user having a fine ACL in his/her home directory (which appers to be like |
Cool. LGTM if CI passes. |
All test failures are just the unrelated usual suspects and something weird with OS X such that it won't even build or something. In other words: 👍 Hopefully someone else can give it an LGTM too. |
|
||
const checkResults = common.mustCall(function(err, r) { | ||
if (err) | ||
throw err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use assert.ifError
instead of this if
block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see there are other tests writing if (err) throw err;
e.g. test-fs-write. Does the current style explicitly prefer assert.ifError
? If not I think this if
block is also okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use assert here, this is common practice.
Seems fine to me. |
@Fishrock123 Does that constitute an LGTM? |
stream.readable = stream.writable = true; | ||
|
||
common.refreshTmpDir(); | ||
const replHistoryPath = path.join(common.tmpDir, 'repl_history'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this consistent with the other test? '.node_repl_history'
@Fishrock123 file name changed, not rebasing. |
Please check this commit. Discovered we have |
Undefined. |
What's the status on this one? |
Seems like maintainers did not agree on the tests. Anyway there are no conflicts, a rebase is easy, so let me know if you want this landed. |
@nodejs/collaborators @nodejs/ctc ... does anyone have any further thoughts on this one? |
ci is green, I can't really make an informative opinion about this though |
|
Ok, LGTM then |
LGTM |
@@ -93,7 +93,7 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) { | |||
var writing = false; | |||
var pending = false; | |||
repl.pause(); | |||
fs.open(historyPath, 'a+', oninit); | |||
fs.open(historyPath, 'a+', 0o0600, oninit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Would you mind adding a quick code comment with a quick explanation here. Nothing complicated, just enough for someone scanning through to know why the flag was set to this.
Added a couple of comments that I'd like to see addressed before this lands. Otherwise LGTM |
What semver-iness would this be? I'm thinking just a patch (because I'd consider this a bug fix) but figured I'd ask. |
I don't think it would be major. |
Test code mostly written by Trott nodejs#3392 (comment).
Added, pointing to this PR and issue.
Me too, changed it to the masked version. |
LGTM if CI is green |
Set the mode bits on the history file to 0o600 instead of leaving it unspecified, which resulted in 0o755 on Unices. Test code mostly written by Trott: #3392 (comment). PR-URL: #3394 Fixes: #3392 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Thanks you! Landed in b72d048. |
Set the mode bits on the history file to 0o600 instead of leaving it unspecified, which resulted in 0o755 on Unices. Test code mostly written by Trott: #3392 (comment). PR-URL: #3394 Fixes: #3392 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Set the mode bits on the history file to 0o600 instead of leaving it unspecified, which resulted in 0o755 on Unices. Test code mostly written by Trott: #3392 (comment). PR-URL: #3394 Fixes: #3392 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Set the mode bits on the history file to 0o600 instead of leaving it unspecified, which resulted in 0o755 on Unices. Test code mostly written by Trott: #3392 (comment). PR-URL: #3394 Fixes: #3392 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Set the mode bits on the history file to 0o600 instead of leaving it unspecified, which resulted in 0o755 on Unices. Test code mostly written by Trott: #3392 (comment). PR-URL: #3394 Fixes: #3392 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Test code mostly written by Trott
#3392 (comment).