test-apt-update-file 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. insertpackage 'unstable' 'bar' 'amd64' '1'
  15. insertsource 'unstable' 'foo' 'all' '1'
  16. setupaptarchive --no-update
  17. logcurrentarchivedirectory
  18. # ensure the archive is not writable
  19. addtrap 'prefix' 'chmod 755 aptarchive/dists/unstable/main/binary-all;'
  20. if [ "$(id -u)" = '0' ]; then
  21. # too deep to notice it, but it also unlikely that files in the same repo have different permissions
  22. chmod 500 aptarchive/dists/unstable/main/binary-all
  23. testfailure aptget update
  24. rm -rf rootdir/var/lib/apt/lists
  25. chmod 755 aptarchive/dists/unstable/main/binary-all
  26. testsuccess aptget update
  27. rm -rf rootdir/var/lib/apt/lists
  28. chmod 511 aptarchive/dists/
  29. testsuccess aptget update
  30. rm -rf rootdir/var/lib/apt/lists
  31. chmod 510 aptarchive/dists/
  32. testsuccesswithnotice aptget update
  33. rm -rf rootdir/var/lib/apt/lists
  34. chmod 500 aptarchive/dists/
  35. testsuccesswithnotice aptget update
  36. chmod 755 aptarchive/dists/
  37. else
  38. testsuccess aptget update
  39. fi
  40. mv rootdir/var/lib/apt/lists/_* rootdir/var/lib/apt/lists/partial
  41. chmod 555 aptarchive/dists/unstable/main/binary-all
  42. testsuccess aptget update -o Debug::pkgAcquire::Worker=1
  43. cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output
  44. testsuccess grep '%0aAlt-Filename:%20' rootdir/tmp/update.output
  45. # the release files aren't an IMS-hit, but the indexes are
  46. redatereleasefiles '+1 hour'
  47. # we don't download the index if it isn't updated
  48. testsuccess aptget update -o Debug::pkgAcquire::Auth=1
  49. # file:/ isn't shown in the log, so see if it was downloaded anyhow
  50. cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output
  51. canary="SHA512:$(bzcat aptarchive/dists/unstable/main/binary-all/Packages.bz2 | sha512sum |cut -f1 -d' ')"
  52. testfailure grep -- "$canary" rootdir/tmp/update.output
  53. testfoo() {
  54. # foo is still available
  55. testsuccess aptget install -s foo
  56. testsuccess aptcache showsrc foo
  57. testsuccess aptget source foo --print-uris
  58. }
  59. testfoo
  60. # the release file is new again, the index still isn't, but it is somehow gone now from disk
  61. redatereleasefiles '+2 hour'
  62. find rootdir/var/lib/apt/lists -name '*_Packages*' -delete
  63. testsuccess aptget update -o Debug::pkgAcquire::Auth=1
  64. # file:/ isn't shown in the log, so see if it was downloaded anyhow
  65. cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output
  66. canary="SHA512:$(bzcat aptarchive/dists/unstable/main/binary-all/Packages.bz2 | sha512sum |cut -f1 -d' ')"
  67. testsuccess grep -- "$canary" rootdir/tmp/update.output
  68. testfoo