drop privileges in copy:// method as we do for file://
[apt.git] / test / integration / test-apt-get-update-unauth-warning
1 #!/bin/sh
2 #
3 # ensure we print warnings for unauthenticated repositories
4 #
5 set -e
6
7 TESTDIR=$(readlink -f $(dirname $0))
8 . $TESTDIR/framework
9
10 setupenvironment
11 configarchitecture "i386"
12 configcompression '.' 'gz'
13
14 # a "normal" package with source and binary
15 buildsimplenativepackage 'foo' 'all' '2.0'
16
17 setupaptarchive --no-update
18
19 APTARCHIVE="$(readlink -f ./aptarchive)"
20 find "$APTARCHIVE/dists/unstable" -name '*Release*' -delete
21
22 echo 'Acquire::Progress::Ignore::ShowErrorText "false";' > rootdir/etc/apt/apt.conf.d/99show-no-ignore-errors.conf
23
24 # update without authenticated files leads to warning
25 testfailureequal "Get:1 file:$APTARCHIVE unstable InRelease
26 Ign:1 file:$APTARCHIVE unstable InRelease
27 Get:2 file:$APTARCHIVE unstable Release
28 Err:2 file:$APTARCHIVE unstable Release
29 File not found - ${APTARCHIVE}/dists/unstable/Release (2: No such file or directory)
30 Reading package lists...
31 E: The repository 'file:$APTARCHIVE unstable Release' does not have a Release file.
32 N: Updating such a repository securily is impossible and therefore disabled by default.
33 N: See apt-secure(8) manpage for repository creation and user configuration details." aptget update --no-allow-insecure-repositories -q=0
34
35 # no package foo
36 testsuccessequal 'Listing...' apt list foo
37 testequal 'lock
38 partial' ls rootdir/var/lib/apt/lists
39
40 filesize() {
41 local CREATEDBY="$1"
42 shift
43 stat -c%s "$(aptget indextargets --no-release-info --format '$(URI)' "Created-By: $CREATEDBY" "$@" | cut -d'/' -f 3- ).gz"
44 }
45 # allow override
46 #aptget update --allow-insecure-repositories -o Debug::pkgAcquire::worker=1
47 #exit
48 testwarningequal "Get:1 file:$APTARCHIVE unstable InRelease
49 Ign:1 file:$APTARCHIVE unstable InRelease
50 Get:2 file:$APTARCHIVE unstable Release
51 Ign:2 file:$APTARCHIVE unstable Release
52 Get:3 file:$APTARCHIVE unstable/main Sources
53 Ign:3 file:$APTARCHIVE unstable/main Sources
54 Get:4 file:$APTARCHIVE unstable/main i386 Packages
55 Ign:4 file:$APTARCHIVE unstable/main i386 Packages
56 Get:5 file:$APTARCHIVE unstable/main all Packages
57 Ign:5 file:$APTARCHIVE unstable/main all Packages
58 Get:6 file:$APTARCHIVE unstable/main Translation-en
59 Ign:6 file:$APTARCHIVE unstable/main Translation-en
60 Get:3 file:$APTARCHIVE unstable/main Sources
61 Ign:3 file:$APTARCHIVE unstable/main Sources
62 Get:4 file:$APTARCHIVE unstable/main i386 Packages
63 Ign:4 file:$APTARCHIVE unstable/main i386 Packages
64 Get:5 file:$APTARCHIVE unstable/main all Packages
65 Ign:5 file:$APTARCHIVE unstable/main all Packages
66 Get:6 file:$APTARCHIVE unstable/main Translation-en
67 Ign:6 file:$APTARCHIVE unstable/main Translation-en
68 Get:3 file:$APTARCHIVE unstable/main Sources
69 Ign:3 file:$APTARCHIVE unstable/main Sources
70 Get:4 file:$APTARCHIVE unstable/main i386 Packages
71 Ign:4 file:$APTARCHIVE unstable/main i386 Packages
72 Get:5 file:$APTARCHIVE unstable/main all Packages
73 Ign:5 file:$APTARCHIVE unstable/main all Packages
74 Get:6 file:$APTARCHIVE unstable/main Translation-en
75 Ign:6 file:$APTARCHIVE unstable/main Translation-en
76 Get:3 file:$APTARCHIVE unstable/main Sources [$(filesize 'Sources') B]
77 Get:4 file:$APTARCHIVE unstable/main i386 Packages [$(filesize 'Packages' 'Architecture: i386') B]
78 Get:5 file:$APTARCHIVE unstable/main all Packages [$(filesize 'Packages' 'Architecture: all') B]
79 Get:6 file:$APTARCHIVE unstable/main Translation-en [$(filesize 'Translations') B]
80 Reading package lists...
81 W: The repository 'file:$APTARCHIVE unstable Release' does not have a Release file.
82 N: Data from such a repository can not be authenticated and is therefore potentially dangerous to use.
83 N: See apt-secure(8) manpage for repository creation and user configuration details." aptget update --allow-insecure-repositories -q=0
84 # ensure we can not install the package
85 testfailureequal "WARNING: The following packages cannot be authenticated!
86 foo
87 E: There were unauthenticated packages and -y was used without --allow-unauthenticated" aptget install -qq -y foo