test-apt-update-file 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/sh
  2. #
  3. # Ensure that we do not modify file:/// uris (regression test for
  4. # CVE-2014-0487
  5. #
  6. set -e
  7. TESTDIR=$(readlink -f $(dirname $0))
  8. . $TESTDIR/framework
  9. setupenvironment
  10. configarchitecture "amd64"
  11. configcompression 'bz2' 'gz'
  12. confighashes 'SHA512'
  13. insertpackage 'unstable' 'foo' 'all' '1'
  14. insertsource 'unstable' 'foo' 'all' '1'
  15. setupaptarchive --no-update
  16. # ensure the archive is not writable
  17. addtrap 'prefix' 'chmod 755 aptarchive/dists/unstable/main/binary-all;'
  18. if [ "$(id -u)" = '0' ]; then
  19. chmod 550 aptarchive/dists/unstable/main/binary-all
  20. testfailure aptget update
  21. fi
  22. chmod 555 aptarchive/dists/unstable/main/binary-all
  23. testsuccess aptget update
  24. # the release files aren't an IMS-hit, but the indexes are
  25. redatereleasefiles '+1 hour'
  26. # we don't download the index if it isn't updated
  27. testsuccess aptget update -o Debug::pkgAcquire::Auth=1
  28. # file:/ isn't shown in the log, so see if it was downloaded anyhow
  29. cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output
  30. canary="SHA512:$(bzcat aptarchive/dists/unstable/main/binary-all/Packages.bz2 | sha512sum |cut -f1 -d' ')"
  31. testfailure grep -- "$canary" rootdir/tmp/update.output
  32. testfoo() {
  33. # foo is still available
  34. testsuccess aptget install -s foo
  35. testsuccess aptcache showsrc foo
  36. testsuccess aptget source foo --print-uris
  37. }
  38. testfoo
  39. # the release file is new again, the index still isn't, but it is somehow gone now from disk
  40. redatereleasefiles '+2 hour'
  41. find rootdir/var/lib/apt/lists -name '*_Packages*' -delete
  42. testsuccess aptget update -o Debug::pkgAcquire::Auth=1
  43. # file:/ isn't shown in the log, so see if it was downloaded anyhow
  44. cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output
  45. canary="SHA512:$(bzcat aptarchive/dists/unstable/main/binary-all/Packages.bz2 | sha512sum |cut -f1 -d' ')"
  46. testsuccess grep -- "$canary" rootdir/tmp/update.output
  47. testfoo