test-bug-818628-unreadable-source 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64'
  7. if [ "$(id -u)" = '0' ]; then
  8. msgskip 'Tests for unreadable files do not work as root'
  9. exit 0
  10. fi
  11. insertinstalledpackage 'foo' 'amd64' '1'
  12. insertpackage 'unstable' 'foo' 'amd64' '2'
  13. setupaptarchive --no-update
  14. touch rootdir/etc/apt/apt.conf.d/unreadable.conf
  15. touch rootdir/etc/apt/preferences.d/unreadable.pref
  16. addtrap 'prefix' "chmod -R +r '$(escape_shell "$TMPWORKINGDIRECTORY")/rootdir/etc/apt';"
  17. chmod -r rootdir/etc/apt/trusted.gpg.d
  18. testfailure apt update
  19. chmod +r rootdir/etc/apt/trusted.gpg.d
  20. testsuccess apt update
  21. testsuccess apt policy foo
  22. testsuccess apt search foo
  23. testsuccessequal "Listing...
  24. foo/unstable 2 amd64 [upgradable from: 1]
  25. N: There is 1 additional version. Please use the '-a' switch to see it" apt list --upgradable
  26. runthemall() {
  27. local ERR1="$1"
  28. local ERR2="$1$2"
  29. testfailureequal "$ERR1" aptcache policy
  30. testfailureequal "$ERR1" aptcache policy foo
  31. testfailureequal "$ERR2" aptcache depends foo
  32. testfailureequal "$ERR2" aptcache rdepends foo
  33. testfailureequal "$ERR2" aptcache search foo
  34. testfailureequal "$ERR1" apt policy
  35. testfailureequal "$ERR1" apt policy foo
  36. testfailureequal "$ERR2" apt depends foo
  37. testfailureequal "$ERR2" apt rdepends foo
  38. testfailureequal "$ERR2" apt search foo
  39. testfailureequal "$ERR2" apt list --upgradable
  40. testfailureequal "$ERR2" apt show foo
  41. testfailureequal "$ERR2" aptcache show foo --no-all-versions
  42. testfailureequal "$ERR2" aptmark auto foo
  43. testfailureequal "$ERR2" aptmark manual foo
  44. testfailureequal "$ERR2" aptmark auto foo
  45. }
  46. echo 'Apt::Cmd::Disable-Script-Warning "true";' >> aptconfig.conf
  47. msgmsg 'Unreadable sources file'
  48. chmod -r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list
  49. runthemall "E: Opening $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list - ifstream::ifstream (13: Permission denied)
  50. E: The list of sources could not be read."
  51. chmod +r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list
  52. msgmsg 'Unreadable config file'
  53. chmod -r rootdir/etc/apt/apt.conf.d/unreadable.conf
  54. runthemall "E: Opening configuration file ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/unreadable.conf - ifstream::ifstream (13: Permission denied)"
  55. chmod +r rootdir/etc/apt/apt.conf.d/unreadable.conf
  56. msgmsg 'Unreadable preferences file'
  57. chmod -r rootdir/etc/apt/preferences.d/unreadable.pref
  58. runthemall "E: Could not open file ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/preferences.d/unreadable.pref - open (13: Permission denied)"
  59. chmod +r rootdir/etc/apt/preferences.d/unreadable.pref
  60. msgmsg 'Unreadable sources directory'
  61. chmod -r rootdir/etc/apt/sources.list.d
  62. runthemall "E: Unable to read $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/ - opendir (13: Permission denied)" "
  63. W: You may want to run apt-get update to correct these problems
  64. E: The package cache file is corrupted"
  65. chmod +r rootdir/etc/apt/sources.list.d
  66. msgmsg 'Unreadable config directory'
  67. chmod -r rootdir/etc/apt/apt.conf.d
  68. runthemall "E: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/ - opendir (13: Permission denied)"
  69. chmod +r rootdir/etc/apt/apt.conf.d
  70. msgmsg 'Unreadable preferences directory'
  71. chmod -r rootdir/etc/apt/preferences.d
  72. runthemall "E: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/preferences.d/ - opendir (13: Permission denied)"
  73. chmod +r rootdir/etc/apt/preferences.d