test-apt-update-stale 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/sh
  2. #
  3. # Ensure that a MITM can not stale the Packages/Sources without
  4. # raising a error message. Note that the Release file is protected
  5. # via the "Valid-Until" header
  6. #
  7. set -e
  8. TESTDIR=$(readlink -f $(dirname $0))
  9. . $TESTDIR/framework
  10. setupenvironment
  11. configarchitecture "i386"
  12. insertpackage 'unstable' 'foo' 'all' '1.0'
  13. setupaptarchive
  14. changetowebserver
  15. aptget update -qq
  16. # insert new version
  17. mkdir aptarchive/dists/unstable/main/binary-i386/saved
  18. cp -p aptarchive/dists/unstable/main/binary-i386/Packages* \
  19. aptarchive/dists/unstable/main/binary-i386/saved
  20. insertpackage 'unstable' 'foo' 'all' '2.0'
  21. # not using compressfile for compat with older apt releases
  22. gzip -c aptarchive/dists/unstable/main/binary-i386/Packages > \
  23. aptarchive/dists/unstable/main/binary-i386/Packages.gz
  24. generatereleasefiles
  25. signreleasefiles
  26. # ensure that we do not get a I-M-S hit for the Release file
  27. touch -d "+1hour" aptarchive/dists/unstable/*Release*
  28. # but now only deliver the previous Packages file instead of the new one
  29. # (simulating a stale attack)
  30. cp -p aptarchive/dists/unstable/main/binary-i386/saved/Packages* \
  31. aptarchive/dists/unstable/main/binary-i386/
  32. # ensure this raises a error
  33. testequal "W: Failed to fetch http://localhost:8080/dists/unstable/main/binary-i386/Packages Hash Sum mismatch
  34. E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq