You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

62 lines
1.9 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture 'i386'
  7. insertpackage 'stable' 'good-pkg' 'all' '1.0'
  8. setupaptarchive
  9. changetowebserver
  10. ARCHIVE='http://localhost:8080/'
  11. msgtest 'Initial apt-get update should work with' 'InRelease'
  12. aptget update -qq && msgpass || msgfail
  13. # check that the setup is correct
  14. testequal "good-pkg:
  15. Installed: (none)
  16. Candidate: 1.0
  17. Version table:
  18. 1.0 0
  19. 500 ${ARCHIVE} stable/main i386 Packages" aptcache policy good-pkg
  20. # now exchange to the Packages file, note that this could be
  21. # done via MITM too
  22. insertpackage 'stable' 'bad-mitm' 'all' '1.0'
  23. # this builds compressed files and a new (unsigned) Release
  24. buildaptarchivefromfiles '+1hour'
  25. # add a space into the BEGIN PGP SIGNATURE PART/END PGP SIGNATURE part
  26. # to trick apt - this is still legal to gpg(v)
  27. sed -i '/^-----BEGIN PGP SIGNATURE-----/,/^-----END PGP SIGNATURE-----/ s/^$/ /g' aptarchive/dists/stable/InRelease
  28. # we append the (evil unsigned) Release file to the (good signed) InRelease
  29. cat aptarchive/dists/stable/Release >> aptarchive/dists/stable/InRelease
  30. touch -d '+1hour' aptarchive/dists/stable/InRelease
  31. # ensure the update fails
  32. # useful for debugging to add "-o Debug::pkgAcquire::auth=true"
  33. msgtest 'apt-get update for should fail with the modified' 'InRelease'
  34. aptget update 2>&1 | grep -q 'Hash Sum mismatch' > /dev/null && msgpass || msgfail
  35. # ensure there is no package
  36. testequal 'Reading package lists...
  37. Building dependency tree...
  38. E: Unable to locate package bad-mitm' aptget install bad-mitm -s
  39. # and verify that its not picked up
  40. testequal 'N: Unable to locate package bad-mitm' aptcache policy bad-mitm -q=0
  41. # and that the right one is used
  42. testequal "good-pkg:
  43. Installed: (none)
  44. Candidate: 1.0
  45. Version table:
  46. 1.0 0
  47. 500 ${ARCHIVE} stable/main i386 Packages" aptcache policy good-pkg