summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-10-20 12:00:46 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2014-10-20 14:42:47 +0200
commit0d303f1764645284b33924c9be8bf29f0a32ca5c (patch)
treea8765da8d91f77762e62bdca1b11fc5c70bbb1d6 /test/integration
parent4fa34122cbe347d21b3a162ff2fa75dd2e73c3a8 (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/integration')
-rw-r--r--test/integration/framework4
-rwxr-xr-xtest/integration/test-bug-604401-files-are-directories2
2 files changed, 5 insertions, 1 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"