test-apt-update-file 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. insertpackage 'unstable' 'foo' 'all' '1'
  13. insertsource 'unstable' 'foo' 'all' '1'
  14. setupaptarchive --no-update
  15. # ensure the archive is not writable
  16. addtrap 'prefix' 'chmod 750 aptarchive/dists/unstable/main/binary-amd64;'
  17. chmod 550 aptarchive/dists/unstable/main/binary-amd64
  18. testsuccess aptget update
  19. # the release files aren't an IMS-hit, but the indexes are
  20. redatereleasefiles '+1 hour'
  21. # we don't download the index if it isn't updated
  22. testsuccess aptget update -o Debug::pkgAcquire::Auth=1
  23. # file:/ isn't shown in the log, so see if it was downloaded anyhow
  24. cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output
  25. canary="SHA512:$(bzcat aptarchive/dists/unstable/main/binary-amd64/Packages.bz2 | sha512sum |cut -f1 -d' ')"
  26. testfailure grep -- "$canary" rootdir/tmp/update.output
  27. testfoo() {
  28. # foo is still available
  29. testsuccess aptget install -s foo
  30. testsuccess aptcache showsrc foo
  31. testsuccess aptget source foo --print-uris
  32. }
  33. testfoo
  34. # the release file is new again, the index still isn't, but it is somehow gone now from disk
  35. redatereleasefiles '+2 hour'
  36. find rootdir/var/lib/apt/lists -name '*_Packages*' -delete
  37. testsuccess aptget update -o Debug::pkgAcquire::Auth=1
  38. # file:/ isn't shown in the log, so see if it was downloaded anyhow
  39. cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output
  40. canary="SHA512:$(bzcat aptarchive/dists/unstable/main/binary-amd64/Packages.bz2 | sha512sum |cut -f1 -d' ')"
  41. testsuccess grep -- "$canary" rootdir/tmp/update.output
  42. testfoo