diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/framework | 4 | ||||
-rwxr-xr-x | test/integration/test-bug-604401-files-are-directories | 2 | ||||
-rw-r--r-- | test/libapt/fileutl_test.cc | 10 |
3 files changed, 14 insertions, 2 deletions
diff --git a/test/integration/framework b/test/integration/framework index 9ce300d55..d576712e5 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -176,6 +176,10 @@ addtrap() { } setupenvironment() { + # privilege dropping and testing doesn't work if /tmp isn't world-writeable (as e.g. with libpam-tmpdir) + if [ -n "$TMPDIR" ] && [ "$(id -u)" = '0' ] && [ "$(stat --format '%a' "$TMPDIR")" != '1777' ]; then + unset TMPDIR + fi TMPWORKINGDIRECTORY=$(mktemp -d) addtrap "cd /; rm -rf $TMPWORKINGDIRECTORY;" msgninfo "Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… " diff --git a/test/integration/test-bug-604401-files-are-directories b/test/integration/test-bug-604401-files-are-directories index e6913edcf..fe0ccc783 100755 --- a/test/integration/test-bug-604401-files-are-directories +++ b/test/integration/test-bug-604401-files-are-directories @@ -57,7 +57,7 @@ echo 'Package: apt Pin: release a=now Pin-Value: 1000' > rootdir/etc/apt/good-link.pref ln -s rootdir/etc/apt/good-link.pref rootdir/etc/apt/preferences -test -n "$(aptcache policy | grep 1000)" && msgfail || msgpass +test -n "$(aptcache policy | grep '1000 ')" && msgfail || msgpass rm rootdir/etc/apt/preferences msgtest "Broken link instead of a file as preferences ignored" 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) |