]>
Commit | Line | Data |
---|---|---|
f40fdaa4 JAK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
4 | TESTDIR="$(readlink -f "$(dirname "$0")")" | |
5 | . "$TESTDIR/framework" | |
6 | setupenvironment | |
fdf9eef4 | 7 | configarchitecture 'amd64' |
f40fdaa4 | 8 | |
fdf9eef4 DK |
9 | if [ "$(id -u)" = '0' ]; then |
10 | msgskip 'Tests for unreadable files do not work as root' | |
f40fdaa4 JAK |
11 | exit 0 |
12 | fi | |
13 | ||
fdf9eef4 DK |
14 | insertinstalledpackage 'foo' 'amd64' '1' |
15 | insertpackage 'unstable' 'foo' 'amd64' '2' | |
f40fdaa4 | 16 | |
fdf9eef4 | 17 | setupaptarchive --no-update |
f40fdaa4 | 18 | |
fdf9eef4 DK |
19 | touch rootdir/etc/apt/apt.conf.d/unreadable.conf |
20 | touch rootdir/etc/apt/preferences.d/unreadable.pref | |
f40fdaa4 | 21 | |
fdf9eef4 DK |
22 | addtrap 'prefix' "chmod -R +r '$(escape_shell "$TMPWORKINGDIRECTORY")/rootdir/etc/apt';" |
23 | chmod -r rootdir/etc/apt/trusted.gpg.d | |
24 | testfailure apt update | |
25 | chmod +r rootdir/etc/apt/trusted.gpg.d | |
26 | testsuccess apt update | |
27 | testsuccess apt policy foo | |
28 | testsuccess apt search foo | |
29 | testsuccessequal "Listing... | |
30 | foo/unstable 2 amd64 [upgradable from: 1] | |
31 | N: There is 1 additional version. Please use the '-a' switch to see it" apt list --upgradable | |
f40fdaa4 | 32 | |
fdf9eef4 DK |
33 | runthemall() { |
34 | local ERR1="$1" | |
35 | local ERR2="$1$2" | |
36 | testfailureequal "$ERR1" aptcache policy | |
37 | testfailureequal "$ERR1" aptcache policy foo | |
38 | testfailureequal "$ERR2" aptcache depends foo | |
39 | testfailureequal "$ERR2" aptcache rdepends foo | |
40 | testfailureequal "$ERR2" aptcache search foo | |
41 | testfailureequal "$ERR1" apt policy | |
42 | testfailureequal "$ERR1" apt policy foo | |
43 | testfailureequal "$ERR2" apt depends foo | |
44 | testfailureequal "$ERR2" apt rdepends foo | |
45 | testfailureequal "$ERR2" apt search foo | |
46 | testfailureequal "$ERR2" apt list --upgradable | |
47 | testfailureequal "$ERR2" apt show foo | |
48 | testfailureequal "$ERR2" aptcache show foo --no-all-versions | |
49 | testfailureequal "$ERR2" aptmark auto foo | |
50 | testfailureequal "$ERR2" aptmark manual foo | |
51 | testfailureequal "$ERR2" aptmark auto foo | |
52 | } | |
53 | echo 'Apt::Cmd::Disable-Script-Warning "true";' >> aptconfig.conf | |
f40fdaa4 | 54 | |
fdf9eef4 | 55 | msgmsg 'Unreadable sources file' |
f40fdaa4 | 56 | chmod -r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list |
fdf9eef4 DK |
57 | runthemall "E: Opening $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list - ifstream::ifstream (13: Permission denied) |
58 | E: The list of sources could not be read." | |
59 | chmod +r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list | |
f40fdaa4 | 60 | |
fdf9eef4 DK |
61 | msgmsg 'Unreadable config file' |
62 | chmod -r rootdir/etc/apt/apt.conf.d/unreadable.conf | |
63 | runthemall "E: Opening configuration file ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/unreadable.conf - ifstream::ifstream (13: Permission denied)" | |
64 | chmod +r rootdir/etc/apt/apt.conf.d/unreadable.conf | |
f40fdaa4 | 65 | |
fdf9eef4 DK |
66 | msgmsg 'Unreadable preferences file' |
67 | chmod -r rootdir/etc/apt/preferences.d/unreadable.pref | |
68 | runthemall "E: Could not open file ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/preferences.d/unreadable.pref - open (13: Permission denied)" | |
69 | chmod +r rootdir/etc/apt/preferences.d/unreadable.pref | |
70 | ||
71 | msgmsg 'Unreadable sources directory' | |
72 | chmod -r rootdir/etc/apt/sources.list.d | |
73 | runthemall "E: Unable to read $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/ - opendir (13: Permission denied)" " | |
74 | W: You may want to run apt-get update to correct these problems | |
75 | E: The package cache file is corrupted" | |
76 | chmod +r rootdir/etc/apt/sources.list.d | |
77 | ||
78 | msgmsg 'Unreadable config directory' | |
79 | chmod -r rootdir/etc/apt/apt.conf.d | |
80 | runthemall "E: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/ - opendir (13: Permission denied)" | |
81 | chmod +r rootdir/etc/apt/apt.conf.d | |
82 | ||
83 | msgmsg 'Unreadable preferences directory' | |
84 | chmod -r rootdir/etc/apt/preferences.d | |
85 | runthemall "E: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/preferences.d/ - opendir (13: Permission denied)" | |
86 | chmod +r rootdir/etc/apt/preferences.d |