-
Notifications
You must be signed in to change notification settings - Fork 246
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
fix(kernel): tarball unpacking does not behave like 'npm install' #1766
Conversation
In it's wisdom, `npm install` does override the process' `umask` to `0o022` before unpackging the tarball, to ensure the produced install has the kind of permissions that one would expect, regardless of the system-configured `umask`. Because `@jsii/kernel` did not reproduce this behavior, loaded libraries could be unpacked with unexpectedly tight permissions, leading to weird issues when those files were used in contexts that required those permissions. For example, this is the cause of aws/aws-cdk#8233. Fixes #1765
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.
Test
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
const originalUmask = process.umask(0o022); | ||
try { | ||
// untar the archive to its final location | ||
tar.extract({ |
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 should use the built-in support in the tar
library.
One of these options should help:
portable
Omit metadata that is system-specific: ctime, atime, uid, gid, uname, gname, dev, ino, and nlink. Note that mtime is still included, because this is necessary for other time-based operations. Additionally, mode is set to a "reasonable default" for most unix systems, based on a umask value of 0o22.mode
The mode to set on the created file archive
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 feel portable
is the right one to use here.
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.
Those options are specific to the create
operation and this is the extract
operation.
The only "built-in" option available is the umask
option to tar.extract
, however that is "internal" (and not exposed in the d.ts
which is why I decided against using that).
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.
Okay sorry my mistake.
Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it! |
Merging (with squash)... |
In it's wisdom,
npm install
does override the process'umask
to0o022
before unpackging the tarball, to ensure the produced installhas the kind of permissions that one would expect, regardless of the
system-configured
umask
.Because
@jsii/kernel
did not reproduce this behavior, loaded librariescould be unpacked with unexpectedly tight permissions, leading to weird
issues when those files were used in contexts that required those
permissions. For example, this is the cause of aws/aws-cdk#8233.
Fixes #1765
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.