From f40fdaa43271edf98b80c08e20f401b5da591501 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 19 Mar 2016 01:56:38 +0100 Subject: cachefile: Only set members that were initialized successfully Otherwise, things will just start failing later down the stack, because (a) the lazy getters do not check if building was successful and (b) any further getter call would return the invalid object anyway. Also initialize VS in pkgCache to nullptr by default. Closes: #818628 --- test/integration/test-bug-818628-unreadable-source | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 test/integration/test-bug-818628-unreadable-source (limited to 'test/integration/test-bug-818628-unreadable-source') diff --git a/test/integration/test-bug-818628-unreadable-source b/test/integration/test-bug-818628-unreadable-source new file mode 100755 index 000000000..84776dd8d --- /dev/null +++ b/test/integration/test-bug-818628-unreadable-source @@ -0,0 +1,42 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" +setupenvironment +configarchitecture 'amd64' 'i386' + +if [ "$(id -u)" = "0" ]; then + msgskip "Tests for unreadable sources.list do not work as root" + exit 0 +fi + +insertinstalledpackage 'apt' 'i386' '1' +buildsimplenativepackage 'apt' 'i386' '2' 'unstable' + +setupaptarchive + +# Test unreadable sources.list files +chmod -r rootdir/etc/apt/sources.list.d + +testfailureequal "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" aptcache policy apt +testfailureequal "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" apt search apt + +chmod +r rootdir/etc/apt/sources.list.d + + +# Test unreadable sources.list files +chmod -r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list + +testfailureequal "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. +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." aptcache policy apt +testfailureequal "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." apt search apt + +chmod +r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list -- cgit v1.2.3