diff options
author | David Kalnischkies <david@kalnischkies.de> | 2014-10-20 12:00:46 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2014-10-20 14:42:47 +0200 |
commit | 0d303f1764645284b33924c9be8bf29f0a32ca5c (patch) | |
tree | a8765da8d91f77762e62bdca1b11fc5c70bbb1d6 /test/libapt/fileutl_test.cc | |
parent | 4fa34122cbe347d21b3a162ff2fa75dd2e73c3a8 (diff) |
test if TMPDIR is accessible before using
Private temporary directories as created by e.g. libpam-tmpdir are nice,
but they are also very effective in preventing our priviledge dropping
to work as TMPDIR will be set to a directory only root has access to, so
working with it as _apt will fail. We circumvent this by extending our
check for a usable TMPDIR setting by checking access rights.
Closes: 765951
Diffstat (limited to 'test/libapt/fileutl_test.cc')
-rw-r--r-- | test/libapt/fileutl_test.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc index cdf7ea479..8d47c5098 100644 --- a/test/libapt/fileutl_test.cc +++ b/test/libapt/fileutl_test.cc @@ -217,8 +217,16 @@ TEST(FileUtlTest, GetTempDir) setenv("TMPDIR", "/not-there-no-really-not", 1); EXPECT_EQ("/tmp", GetTempDir()); + // here but not accessible for non-roots setenv("TMPDIR", "/usr", 1); - EXPECT_EQ("/usr", GetTempDir()); + EXPECT_EQ("/tmp", GetTempDir()); + + // files are no good for tmpdirs, too + setenv("TMPDIR", "/dev/null", 1); + EXPECT_EQ("/tmp", GetTempDir()); + + setenv("TMPDIR", "/var/tmp", 1); + EXPECT_EQ("/var/tmp", GetTempDir()); unsetenv("TMPDIR"); if (old_tmpdir.empty() == false) |