-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Unix: Default to a users-specific temp directory for extracting single-file apps #2329
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
Conversation
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'd also set S_ISVTX (01000) in these two mkdir() calls in addition to their access permissions. This is the sticky bit.
With this bit set, only the owner of extraction_dir can rename or delete that directory. (Otherwise, there's a potential race condition here: while you can only remove empty directories -- and need to recursively delete files from a directory -- a malicious process can remove the directory even before we were able to start extracting the files there.)
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.
Thanks @lpereira, I've fixed this on the extraction_dir, per our discussion.
92dd76f to
fb3de95
Compare
|
@lpereira I've addressed your comments about |
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.
What happens if you run a program with $TMPDIR/.net already created, but with the permissions different than the one you set with chmod() because someone went there and changed them?
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.
That would be too bad. We just provide the $TPMDIR/.net/$UID as the default for $DOTNET_BUNDLE_EXTRACTION_BASE_DIR. If the default directory is not available/accessible on a system, then the user should set DOTNET_BUNDLE_EXTRACTION_BASE_DIR to an alternate location.
|
Hello @lpereira! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
…e-file apps In .net core 3, single file apps run by extracting the bundled contents to a temp directory. The extraction directory is machine specific, and can be set through DOTNET_BUNDLE_EXTRACT_BASE_DIR environment variable. When this setting is not configured, the host tries to use certain default directories. On windows, extraction is within %TMPDIR%, which is user specific. On Unix systems $TMPDIR/.net if set, which may be user specific (ex: MAC) Otherwise, the extraction directory is within /var/tmp/ or /tmp/ which is common to all users, and may be locked by a specific user on first creation. Therefore, this change fixes this issue by defaulting the extraction base directory in Unix systems to `<temp-dir>/.net/<user-ID>` , where `<temp-dir>/.net/` has permission 0777, and `<temp-dir>/.net/<user-ID>/` has permission 01700. This fix will be migrated to coreclr/3.1 branch for servicing. Testing: Manual testing on Unix/Mac systems, since we don't have the setup to add automated tests with multiple users. Fixes https://github.com/dotnet/core-setup/issues/8882
…tory dotnet/runtime#3846 On some Unix systems, multiple users cannot use single-file apps on the same machine. In .net core 3, single file apps run by extracting the bundled contents to a temp directory. The extraction directory is machine specific, and can be set through DOTNET_BUNDLE_EXTRACT_BASE_DIR environment variable. When this setting is not configured, the host tries to use certain default directories. On windows, extraction is within %TMPDIR%, which is user specific. On Unix systems $TMPDIR/.net if set, which may be user specific (ex: MAC) Otherwise, the extraction directory is within /var/tmp/ or /tmp/ which is common to all users, and may be locked by a specific user on first creation. This change fixes this issue by defaulting the extraction base directory in Unix systems to <temp-dir>/.net/<user-ID> , where <temp-dir>/.net/ has permission 0777, and <temp-dir>/.net/<user-ID>/ has permission 0700. Low, scenario is contained, change is small. dotnet/runtime#2329
…tory dotnet/runtime#3846 On some Unix systems, multiple users cannot use single-file apps on the same machine. In .net core 3, single file apps run by extracting the bundled contents to a temp directory. The extraction directory is machine specific, and can be set through DOTNET_BUNDLE_EXTRACT_BASE_DIR environment variable. When this setting is not configured, the host tries to use certain default directories. On windows, extraction is within %TMPDIR%, which is user specific. On Unix systems $TMPDIR/.net if set, which may be user specific (ex: MAC) Otherwise, the extraction directory is within /var/tmp/ or /tmp/ which is common to all users, and may be locked by a specific user on first creation. This change fixes this issue by defaulting the extraction base directory in Unix systems to <temp-dir>/.net/<user-ID> , where <temp-dir>/.net/ has permission 0777, and <temp-dir>/.net/<user-ID>/ has permission 0700. Low, scenario is contained, change is small. dotnet/runtime#2329
…tory ** Issue dotnet/runtime#3846 ** Customer Scenario On some Unix systems, multiple users cannot use single-file apps on the same machine. ** Problem In .net core 3, single file apps run by extracting the bundled contents to a temp directory. The extraction directory is machine specific, and can be set through DOTNET_BUNDLE_EXTRACT_BASE_DIR environment variable. When this setting is not configured, the host tries to use certain default directories. On windows, extraction is within %TMPDIR%, which is user specific. On Unix systems $TMPDIR/.net if set, which may be user specific (ex: MAC) Otherwise, the extraction directory is within /var/tmp/ or /tmp/ which is common to all users, and may be locked by a specific user on first creation. ** Solution This change fixes this issue by defaulting the extraction base directory in Unix systems to <temp-dir>/.net/<user-ID> , where <temp-dir>/.net/ has permission 0777, and <temp-dir>/.net/<user-ID>/ has permission 0700. ** Risk Low, scenario is contained, change is small. ** Master Branch dotnet/runtime#2329
…tory (#9011) ** Issue dotnet/runtime#3846 ** Customer Scenario On some Unix systems, multiple users cannot use single-file apps on the same machine. ** Problem In .net core 3, single file apps run by extracting the bundled contents to a temp directory. The extraction directory is machine specific, and can be set through DOTNET_BUNDLE_EXTRACT_BASE_DIR environment variable. When this setting is not configured, the host tries to use certain default directories. On windows, extraction is within %TMPDIR%, which is user specific. On Unix systems $TMPDIR/.net if set, which may be user specific (ex: MAC) Otherwise, the extraction directory is within /var/tmp/ or /tmp/ which is common to all users, and may be locked by a specific user on first creation. ** Solution This change fixes this issue by defaulting the extraction base directory in Unix systems to <temp-dir>/.net/<user-ID> , where <temp-dir>/.net/ has permission 0777, and <temp-dir>/.net/<user-ID>/ has permission 0700. ** Risk Low, scenario is contained, change is small. ** Master Branch dotnet/runtime#2329
|
Can you help me understand why we are using an error prone approach where Also, most recent distributions treat |
|
@omajid might be best to open a new issue so folks see it. |
In .net core 3, single file apps run by extracting the bundled contents to a temp directory.
The extraction directory is machine specific, and can be set through DOTNET_BUNDLE_EXTRACT_BASE_DIR environment variable.
When this setting is not configured, the host tries to use certain default directories.
On windows, extraction is within %TMPDIR%, which is user specific.
On Unix systems $TMPDIR/.net if set, which may be user specific (ex: MAC)
Otherwise, the extraction directory is within /var/tmp/ or /tmp/ which is common to all users, and may be locked by a specific user on first creation.
Therefore, this change fixes this issue by defaulting the extraction base directory in Unix systems to
<temp-dir>/.net/<user-ID>, where<temp-dir>/.net/has permission 0777, and<temp-dir>/.net/<user-ID>/has permission 0700.This fix will be migrated to coreclr/3.1 branch for servicing.
Testing: Manual testing on Unix/Mac systems, since we don't have the setup to add automated tests with multiple users.
Fixes https://github.com/dotnet/core-setup/issues/8882