test-apt-update-file 1.7 KB

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