Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

use /tmp for mktmpdir #5043

Merged
merged 2 commits into from
Oct 5, 2016
Merged

use /tmp for mktmpdir #5043

merged 2 commits into from
Oct 5, 2016

Conversation

indirect
Copy link
Member

@indirect indirect commented Oct 3, 2016

As we noticed in #4519, we need to use a temporary directory to hold
compact index downloads so that multiple processes don't write to the
same files at the same time and break everything.

The fix for that was #4561, which added temporary directories to hold
all files as they download, and then uses the (atomic) FileUtils.cp to
move the completed downloads into place, so there is never a point where
multiple processes are trying to write into the file at once.

Unfortunately, using Dir.mktmpdir requires that the parent directory
be either world writable or sticky, but not both. Based on #4599, it
looks like it's common for home directories to be both world writable
and sticky. While that's a security problem by itself, it's not a big
concern for Bundler and the compact index. So we want to let users
continue to use Bundler, even with the compact index, without having to
change the permissions on their home directories.

This commit changes the mktmpdir call to create the temporary
directory inside the default OS tempdir, which is typically /tmp or
/var/tmp depending on distro. Since that directory is designed to hold
other temporary directories, that change should (theoretically) reduce
or eliminate the problem reported in #4599.

As we noticed in #4519, we need to use a temporary directory to hold
compact index downloads so that multiple processes don't write to the
same files at the same time and break everything.

The fix for that was #4561, which added temporary directories to hold
all files as they download, and then uses the (atomic) `FileUtils.cp` to
move the completed downloads into place, so there is never a point where
multiple processes are trying to write into the file at once.

Unfortunately, using `Dir.mktmpdir` requires that the parent directory
be _either_ world writable or sticky, but not both. Based on #4599, it
looks like it's common for home directories to be both world writable
and sticky. While that's a security problem by itself, it's not a big
concern for Bundler and the compact index. So we want to let users
continue to use Bundler, even with the compact index, without having to
change the permissions on their home directories.

This commit changes the `mktmpdir` call to create the temporary
directory inside the default OS tempdir, which is typically `/tmp` or
`/var/tmp` depending on distro. Since that directory is designed to hold
other temporary directories, that change should (theoretically) reduce
or eliminate the problem reported in #4599.
@segiddins
Copy link
Member

@indirect any chance for a test case on this?

@indirect
Copy link
Member Author

indirect commented Oct 4, 2016

@segiddins yeah, working on it

@indirect
Copy link
Member Author

indirect commented Oct 4, 2016

@segiddins test supplied, pls to review

@segiddins
Copy link
Member

did you confirm the test fails without the fix?

@indirect
Copy link
Member Author

indirect commented Oct 4, 2016

@segiddins yes, I wrote a failing test against master and then committed this test on the branch after ensuring it changed to green.

@segiddins
Copy link
Member

@homu r+

@homu
Copy link
Contributor

homu commented Oct 4, 2016

📌 Commit 0954697 has been approved by segiddins

homu added a commit that referenced this pull request Oct 4, 2016
use /tmp for mktmpdir

As we noticed in #4519, we need to use a temporary directory to hold
compact index downloads so that multiple processes don't write to the
same files at the same time and break everything.

The fix for that was #4561, which added temporary directories to hold
all files as they download, and then uses the (atomic) `FileUtils.cp` to
move the completed downloads into place, so there is never a point where
multiple processes are trying to write into the file at once.

Unfortunately, using `Dir.mktmpdir` requires that the parent directory
be _either_ world writable or sticky, but not both. Based on #4599, it
looks like it's common for home directories to be both world writable
and sticky. While that's a security problem by itself, it's not a big
concern for Bundler and the compact index. So we want to let users
continue to use Bundler, even with the compact index, without having to
change the permissions on their home directories.

This commit changes the `mktmpdir` call to create the temporary
directory inside the default OS tempdir, which is typically `/tmp` or
`/var/tmp` depending on distro. Since that directory is designed to hold
other temporary directories, that change should (theoretically) reduce
or eliminate the problem reported in #4599.
@homu
Copy link
Contributor

homu commented Oct 4, 2016

⌛ Testing commit 0954697 with merge b430c47...

@homu
Copy link
Contributor

homu commented Oct 4, 2016

💔 Test failed - status

@indirect
Copy link
Member Author

indirect commented Oct 5, 2016

restarted the 1.8.7 build, didn't think to check if I actually broke 1.8 until after the log was gone >_>

@homu
Copy link
Contributor

homu commented Oct 5, 2016

☀️ Test successful - status

@homu homu merged commit 0954697 into master Oct 5, 2016
@indirect indirect added this to the 1.13 - Release - Patch 1.13.3 milestone Oct 5, 2016
@indirect indirect deleted the aa-use-tmp branch October 5, 2016 01:03
indirect pushed a commit that referenced this pull request Oct 11, 2016
use /tmp for mktmpdir

As we noticed in #4519, we need to use a temporary directory to hold
compact index downloads so that multiple processes don't write to the
same files at the same time and break everything.

The fix for that was #4561, which added temporary directories to hold
all files as they download, and then uses the (atomic) `FileUtils.cp` to
move the completed downloads into place, so there is never a point where
multiple processes are trying to write into the file at once.

Unfortunately, using `Dir.mktmpdir` requires that the parent directory
be _either_ world writable or sticky, but not both. Based on #4599, it
looks like it's common for home directories to be both world writable
and sticky. While that's a security problem by itself, it's not a big
concern for Bundler and the compact index. So we want to let users
continue to use Bundler, even with the compact index, without having to
change the permissions on their home directories.

This commit changes the `mktmpdir` call to create the temporary
directory inside the default OS tempdir, which is typically `/tmp` or
`/var/tmp` depending on distro. Since that directory is designed to hold
other temporary directories, that change should (theoretically) reduce
or eliminate the problem reported in #4599.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants