Unix: Default to a users-specific temp directory for extracting single-file apps...
authorSwaroop Sridhar <Swaroop.Sridhar@microsoft.com>
Wed, 12 Feb 2020 02:24:44 +0000 (18:24 -0800)
committerGitHub <noreply@github.com>
Wed, 12 Feb 2020 02:24:44 +0000 (18:24 -0800)
commit9082716c105537346bd2d146d84aab671558db36
tree5bd181016a0a7a884c2e25bf115d6026948a72df
parent0cf87c61d15bac2702d2d647434ca8a75cb9037a
Unix: Default to a users-specific temp directory for extracting single-file apps (#2329)

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.

Issue #3846
src/installer/corehost/cli/apphost/bundle/extractor.cpp
src/installer/corehost/cli/hostmisc/pal.h
src/installer/corehost/cli/hostmisc/pal.unix.cpp
src/installer/corehost/cli/hostmisc/pal.windows.cpp