From 2b0369a5d1673d9e40f2af4db7677b040a26ee58 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 12 Sep 2021 16:08:52 +0200 Subject: Read and work with canonical file-URIs from sources.lists We allow file (and other file-based methods) URIs to either be given as file:///path or as file:/path, but in various places of the acquire system we perform string comparisons on URIs which do not handle this expecting the canonical representation produced by our URI code. That used to be hidden by us quoting and dequoting the URIs in the system, but as we don't do this anymore we have to be a bit more careful on input. Ideally we would do less of these comparisons, but for now lets be content with inserting a canonicalisation early on to prevent hangs in the acquire system. --- test/integration/framework | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'test/integration/framework') diff --git a/test/integration/framework b/test/integration/framework index 1f942d162..009eed9cd 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -1181,7 +1181,7 @@ setupdistsaptarchive() { SECTIONS=$(find "./aptarchive/dists/${DISTS}/" -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ') msgninfo "\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… " echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > "rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb.list" - echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > "rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb-src.list" + echo "deb-src file:$APTARCHIVE $DISTS $SECTIONS" > "rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb-src.list" msgdone "info" done } @@ -1198,7 +1198,7 @@ setupflataptarchive() { fi if [ -f "${APTARCHIVE}/Sources" ]; then msgninfo "\tadd deb-src sources.list line… " - echo "deb-src file://$APTARCHIVEURI /" > 'rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list' + echo "deb-src file:$APTARCHIVEURI /" > 'rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list' msgdone 'info' else rm -f 'rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list' @@ -1360,10 +1360,13 @@ webserverconfig() { } rewritesourceslist() { - local APTARCHIVE="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive" | sed 's# #%20#g')" - local APTARCHIVE2="copy://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive" | sed 's# #%20#g')" + local APTARCHIVE="$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive" | sed 's# #%20#g')" for LIST in $(find "${TMPWORKINGDIRECTORY}/rootdir/etc/apt/sources.list.d/" -name 'apt-test-*.list'); do - sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#$APTARCHIVE2#${1}#" \ + sed -i $LIST \ + -e "s#file://$APTARCHIVE#${1}#" \ + -e "s#file:$APTARCHIVE#${1}#" \ + -e "s#copy://$APTARCHIVE#${1}#" \ + -e "s#copy:$APTARCHIVE#${1}#" \ -e "s#http://[^@]*@\?localhost:${APTHTTPPORT}/\?#${1}#" \ -e "s#https://[^@]*@\?localhost:${APTHTTPSPORT}/\?#${1}#" done @@ -1384,10 +1387,9 @@ waitforpidfile() { } changetowebserver() { - local REWRITE='no' - if [ "$1" != '--no-rewrite' ]; then - REWRITE='yes' - else + local REWRITE='yes' + if [ "$1" = '--no-rewrite' ]; then + REWRITE='no' shift fi if test -x "${APTTESTHELPERSBINDIR}/aptwebserver"; then @@ -1412,12 +1414,17 @@ changetowebserver() { else msgdie 'You have to build apt from source to have test/interactive-helper/aptwebserver available for tests requiring a webserver' fi - if [ "$REWRTE" != 'yes' ]; then + if [ "$REWRITE" != 'no' ]; then rewritesourceslist "http://localhost:${APTHTTPPORT}/" fi } changetohttpswebserver() { + local REWRITE='yes' + if [ "$1" = '--no-rewrite' ]; then + REWRITE='no' + shift + fi local stunnel4 if command -v stunnel4 >/dev/null 2>&1; then stunnel4=stunnel4 @@ -1446,7 +1453,9 @@ connect = $APTHTTPPORT addtrap 'prefix' "kill ${PID};" APTHTTPSPORT="$(lsof -i -n | awk "/^$stunnel4 / && \$2 == \"${PID}\" {print \$9; exit; }" | cut -d':' -f 2)" webserverconfig 'aptwebserver::port::https' "$APTHTTPSPORT" "https://localhost:${APTHTTPSPORT}" - rewritesourceslist "https://localhost:${APTHTTPSPORT}/" + if [ "$REWRITE" != 'no' ]; then + rewritesourceslist "https://localhost:${APTHTTPSPORT}/" + fi } changetocdrom() { -- cgit v1.2.3-70-g09d2