summaryrefslogtreecommitdiff
path: root/test/integration/test-bug-818628-unreadable-source
blob: cddc793989448c3a00a615bfc1dd9c10a2f344cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh
set -e

TESTDIR="$(readlink -f "$(dirname "$0")")"
. "$TESTDIR/framework"
setupenvironment
configarchitecture 'amd64'

if [ "$(id -u)" = '0' ]; then
    msgskip 'Tests for unreadable files do not work as root'
    exit 0
fi

insertinstalledpackage 'foo' 'amd64' '1'
insertpackage 'unstable' 'foo' 'amd64' '2'

setupaptarchive --no-update

touch rootdir/etc/apt/apt.conf.d/unreadable.conf
touch rootdir/etc/apt/preferences.d/unreadable.pref

addtrap 'prefix' "chmod -R +r '$(escape_shell "$TMPWORKINGDIRECTORY")/rootdir/etc/apt';"
chmod -r rootdir/etc/apt/trusted.gpg.d
testfailure apt update
chmod +r rootdir/etc/apt/trusted.gpg.d
testsuccess apt update
testsuccess apt policy foo
testsuccess apt search foo
testsuccessequal "Listing...
foo/unstable 2 amd64 [upgradable from: 1]
N: There is 1 additional version. Please use the '-a' switch to see it" apt list --upgradable

runthemall() {
	local ERR1="$1"
	local ERR2="$1$2"
	testfailureequal "$ERR1" aptcache policy
	testfailureequal "$ERR1" aptcache policy foo
	testfailureequal "$ERR2" aptcache depends foo
	testfailureequal "$ERR2" aptcache rdepends foo
	testfailureequal "$ERR2" aptcache search foo
	testfailureequal "$ERR1" apt policy
	testfailureequal "$ERR1" apt policy foo
	testfailureequal "$ERR2" apt depends foo
	testfailureequal "$ERR2" apt rdepends foo
	testfailureequal "$ERR2" apt search foo
	testfailureequal "$ERR2" apt list --upgradable
	testfailureequal "$ERR2" apt show foo
	testfailureequal "$ERR2" aptcache show foo --no-all-versions
	testfailureequal "$ERR2" aptmark auto foo
	testfailureequal "$ERR2" aptmark manual foo
	testfailureequal "$ERR2" aptmark auto foo
}
echo 'Apt::Cmd::Disable-Script-Warning "true";' >> aptconfig.conf

msgmsg 'Unreadable sources file'
chmod -r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list
runthemall "E: Opening $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list - ifstream::ifstream (13: Permission denied)
E: The list of sources could not be read."
chmod +r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list

msgmsg 'Unreadable config file'
chmod -r rootdir/etc/apt/apt.conf.d/unreadable.conf
runthemall "E: Opening configuration file ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/unreadable.conf - ifstream::ifstream (13: Permission denied)"
chmod +r rootdir/etc/apt/apt.conf.d/unreadable.conf

msgmsg 'Unreadable preferences file'
chmod -r rootdir/etc/apt/preferences.d/unreadable.pref
runthemall "E: Could not open file ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/preferences.d/unreadable.pref - open (13: Permission denied)"
chmod +r rootdir/etc/apt/preferences.d/unreadable.pref

msgmsg 'Unreadable sources directory'
chmod -r rootdir/etc/apt/sources.list.d
runthemall "E: Unable to read $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/ - opendir (13: Permission denied)" "
W: You may want to run apt-get update to correct these problems
E: The package cache file is corrupted"
chmod +r rootdir/etc/apt/sources.list.d

msgmsg 'Unreadable config directory'
chmod -r rootdir/etc/apt/apt.conf.d
runthemall "E: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/ - opendir (13: Permission denied)"
chmod +r rootdir/etc/apt/apt.conf.d

msgmsg 'Unreadable preferences directory'
chmod -r rootdir/etc/apt/preferences.d
runthemall "E: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/preferences.d/ - opendir (13: Permission denied)"
chmod +r rootdir/etc/apt/preferences.d