-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Normalize permissions when extracting tarfiles #1490
Conversation
This addresses a few issues by ignoring the permissions in the input file: * files and directories the user can't read * world-writable files * inconsistent permissions It will leave group writable files/directories if the users umask allows that (such as umask 0002 or 0007), but it will never leave them world writable even with umask 0000. Fixes #1143, #961, #872, and #713
@@ -65,6 +65,13 @@ export default class TarballFetcher extends BaseFetcher { | |||
|
|||
extractorStream | |||
.pipe(untarStream) | |||
.on('entry', (entry) => { | |||
if (entry.type == 'Directory' || entry.props.mode & 0o100) { // eslint-disable-line no-bitwise | |||
entry.props.mode = 0o775; |
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 am not sure the correct thing to do here. Obviously we want to normalize but maybe we might want to limit to just the current user account.
related reading |
We prob should follow this approach also |
@samccone, what action do you think should be next? |
This needs more discussion before merging. |
npm 3.10.8 seems to fix the file permissions but leaves the user/group ownership untouched (or uses a pattern I cannot recognize). I have files owned by root:root root:$user and nobody:$user in /usr/lib/node_modues, when they are installed through |
Is there any chance this PR will be accepted? I'd love to be able to move to |
@neurotech, hardcoding a permission for all npm dependencies sounds a bit too invasive. |
Sorry, I forgot about this PR. What is the use case for having umask in the config, when the OS has umask support? If the user wants special permissions, they can be applied to the top level yarn cache directory. |
Just want to be on the safe side and not change the current default behavior. |
I believe the current behaviour is using "random" permissions set at packaging time from the user and program publishing to the registry, possibly including that persons umask, and then applying the end user umask on that. Or are we talking about npm behaviour? Anyway, if anyone would like to take over this PR, notify me and I can close this (unless github has a way of "handing over" a PR). |
I like this PR but would like to have this thing configurable. |
Summary
Tar-files from the registry might have unwanted file permissions, for example:
This addresses the issues by ignoring the permissions in the input file. It will leave group writable files/directories if the users umask allows that (such as umask 0002 or 0007), but it will never leave them world writable even with umask 0000.
Fixes #1143, #961, #872, and #713
For example, in #961 a tarball is missing access rights for a directory:
This is caused by incorrect permissions in the tarfile:
Test plan
I have verified that I can install @types/react-router@2.0.37 after the change:
I have also verified that umask is applied:
TODO