19-install-tor-browser-AppArmor-profile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh
  2. set -e
  3. echo "Installing AppArmor profile for Tor Browser"
  4. PATCH='/usr/share/tails/torbrowser-AppArmor-profile.patch'
  5. PROFILE='/etc/apparmor.d/torbrowser'
  6. ### Functions
  7. toggle_src_APT_sources() {
  8. MODE="$1"
  9. TEMP_APT_SOURCES='/etc/apt/sources.list.d/tmp-deb-src.list'
  10. case "$MODE" in
  11. on)
  12. cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list \
  13. | grep --extended-regexp --line-regexp --invert-match \
  14. 'deb\s+file:/root/local-packages\s+\./' \
  15. | grep --extended-regexp --invert-match \
  16. '^deb\s+http://tagged\.snapshots\.deb\.tails\.boum.org/[^/]+/torproject(/|\s)' \
  17. | grep --extended-regexp --invert-match \
  18. '^deb\s+http://time-based\.snapshots\.deb\.tails\.boum.org/torproject/' \
  19. | sed --regexp-extended -e 's,^deb(\s+),deb-src\1,' \
  20. > "$TEMP_APT_SOURCES"
  21. ;;
  22. off)
  23. rm "$TEMP_APT_SOURCES"
  24. ;;
  25. esac
  26. apt-get --yes update
  27. }
  28. install_torbrowser_AppArmor_profile() {
  29. tmpdir="$(mktemp -d)"
  30. (
  31. cd "$tmpdir"
  32. apt-get source torbrowser-launcher/stretch
  33. install -m 0644 \
  34. torbrowser-launcher-*/apparmor/torbrowser.Browser.firefox \
  35. "$PROFILE"
  36. )
  37. rm -r "$tmpdir"
  38. }
  39. ### Main
  40. toggle_src_APT_sources on
  41. install_torbrowser_AppArmor_profile
  42. toggle_src_APT_sources off
  43. patch --forward --batch "$PROFILE" < "$PATCH"
  44. rm "$PATCH"