mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2025-02-27 05:10:43 +00:00
Respect the TMPDIR environment variable on Unix
On Mac, this is important as TMPDIR points to a user-specific temp dir which avoids a potential problem where an app bundle created in the temp dir running as User A cannot later be replaced by a copy of the updater running as User B. MD-19088 #time 30m Reviewed-by: Nicolas Esteves
This commit is contained in:
parent
16baf00ee6
commit
b60a7a7ba2
3 changed files with 14 additions and 1 deletions
|
@ -450,7 +450,12 @@ std::string FileUtils::toUnixPathSeparators(const std::string& str)
|
|||
std::string FileUtils::tempPath()
|
||||
{
|
||||
#ifdef PLATFORM_UNIX
|
||||
return "/tmp";
|
||||
std::string tmpDir(notNullString(getenv("TMPDIR")));
|
||||
if (tmpDir.empty())
|
||||
{
|
||||
tmpDir = "/tmp";
|
||||
}
|
||||
return tmpDir;
|
||||
#else
|
||||
char buffer[MAX_PATH+1];
|
||||
GetTempPath(MAX_PATH+1,buffer);
|
||||
|
|
|
@ -33,11 +33,18 @@ void TestFileUtils::testSymlinkFileExists()
|
|||
#endif
|
||||
}
|
||||
|
||||
void TestFileUtils::testStandardDirs()
|
||||
{
|
||||
std::string tmpDir = FileUtils::tempPath();
|
||||
TEST_COMPARE(FileUtils::fileExists(tmpDir.data()), true);
|
||||
}
|
||||
|
||||
int main(int,char**)
|
||||
{
|
||||
TestList<TestFileUtils> tests;
|
||||
tests.addTest(&TestFileUtils::testDirName);
|
||||
tests.addTest(&TestFileUtils::testIsRelative);
|
||||
tests.addTest(&TestFileUtils::testSymlinkFileExists);
|
||||
tests.addTest(&TestFileUtils::testStandardDirs);
|
||||
return TestUtils::runTest(tests);
|
||||
}
|
||||
|
|
|
@ -6,4 +6,5 @@ class TestFileUtils
|
|||
void testDirName();
|
||||
void testIsRelative();
|
||||
void testSymlinkFileExists();
|
||||
void testStandardDirs();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue