tor.postinst 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #!/bin/sh -e
  2. # checking debian-tor account
  3. uid=`getent passwd debian-tor | cut -d ":" -f 3`
  4. home=`getent passwd debian-tor | cut -d ":" -f 6`
  5. # if there is the uid the account is there and we can do
  6. # the sanit(ar)y checks otherwise we can safely create it.
  7. if [ "$uid" ]; then
  8. # guess??? the checks!!!
  9. if [ $uid -ge 100 ] && [ $uid -le 999 ]; then
  10. echo "debian-tor uid check: ok"
  11. else
  12. echo "ERROR: debian-tor account has a non-system uid!"
  13. echo "Please check /usr/share/doc/tor/README.Debian on how to"
  14. echo "correct this problem"
  15. exit 1
  16. fi
  17. if [ "$home" = "/var/lib/tor" ]; then
  18. echo "debian-tor homedir check: ok"
  19. else
  20. echo "ERROR: debian-tor account has an invalid home directory!"
  21. echo "Please check /usr/share/doc/tor/README.Debian on how to"
  22. echo "correct this problem"
  23. exit 1
  24. fi
  25. else
  26. # what this might mean?? oh creating a system l^Huser!
  27. adduser --quiet \
  28. --system \
  29. --disabled-password \
  30. --home /var/lib/tor \
  31. --no-create-home \
  32. --shell /bin/bash \
  33. --group \
  34. debian-tor
  35. fi
  36. # ch{owning,moding} things around
  37. # We will do nothing across upgrades.
  38. if [ "$2" = "" ]; then
  39. for i in lib log run; do
  40. chown -R debian-tor:debian-tor /var/$i/tor
  41. chmod -R 700 /var/$i/tor
  42. find /var/$i/tor -type f -exec chmod 600 '{}' ';'
  43. done
  44. chgrp -R adm /var/log/tor
  45. chmod -R g+rX /var/log/tor
  46. chmod g+s /var/log/tor
  47. else
  48. # fix permissions of logs after 0.0.8+0.0.9pre5-1
  49. if [ "$1" = "configure" ]; then
  50. if dpkg --compare-versions "$2" le "0.0.8+0.0.9pre5-1" ; then
  51. chgrp -R adm /var/log/tor
  52. chmod -R g+rX /var/log/tor
  53. chmod g+s /var/log/tor
  54. fi
  55. fi
  56. fi
  57. move_away_keys=0
  58. if [ "$1" = "configure" ] &&
  59. [ -e /var/lib/tor/keys ] &&
  60. [ ! -z "$2" ]; then
  61. if dpkg --compare-versions "$2" lt 0.1.2.19-2; then
  62. move_away_keys=1
  63. fi
  64. fi
  65. if [ "$move_away_keys" = "1" ]; then
  66. echo "Retiring possibly compromised keys. See /usr/share/doc/tor/NEWS.Debian.gz"
  67. echo "and /var/lib/tor/keys/moved-away-by-tor-package/README.REALLY for"
  68. echo "further information."
  69. if ! [ -d /var/lib/tor/keys/moved-away-by-tor-package ]; then
  70. mkdir /var/lib/tor/keys/moved-away-by-tor-package
  71. cat > /var/lib/tor/keys/moved-away-by-tor-package/README.REALLY << EOF
  72. It has been discovered that the random number generator in Debian's
  73. openssl package is predictable. This is caused by an incorrect
  74. Debian-specific change to the openssl package (CVE-2008-0166). As a
  75. result, cryptographic key material may be guessable.
  76. See Debian Security Advisory number 1571 (DSA-1571) for more information:
  77. http://lists.debian.org/debian-security-announce/2008/msg00152.html
  78. The Debian package for Tor has moved away the onion keys upon package
  79. upgrade, and it will have moved away your identity key if it was created
  80. in the affected timeframe. There is no sure way to automatically tell
  81. if your key was created with an affected openssl library, so this move
  82. is done unconditionally.
  83. If you have restarted Tor since this change (and the package probably
  84. did that for you already unless you configured your system differently)
  85. then the Tor daemon already created new keys for itself and in all
  86. likelyhood is already working just fine with new keys.
  87. If you are absolutely certain that your identity key was created with
  88. a non-affected version of openssl and for some reason you have to retain
  89. the old identity, then you can move back the copy of secret_id_key to
  90. /var/lib/tor/keys. Do not move back the onion keys, they were created
  91. only recently since they are temporary keys with a lifetime of only a few
  92. days anyway.
  93. Sincerely,
  94. Peter Palfrader, Tue, 13 May 2008 13:32:23 +0200
  95. EOF
  96. fi
  97. for f in secret_onion_key secret_onion_key.old; do
  98. if [ -e /var/lib/tor/keys/"$f" ]; then
  99. mv -v /var/lib/tor/keys/"$f" /var/lib/tor/keys/moved-away-by-tor-package/"$f"
  100. fi
  101. done
  102. if [ -e /var/lib/tor/keys/secret_id_key ]; then
  103. id_mtime=`/usr/bin/stat -c %Y /var/lib/tor/keys/secret_id_key`
  104. sept=`date -d '2006-09-10' +%s`
  105. if [ "$id_mtime" -gt "$sept" ] ; then
  106. mv -v /var/lib/tor/keys/secret_id_key /var/lib/tor/keys/moved-away-by-tor-package/secret_id_key
  107. fi
  108. fi
  109. fi
  110. #DEBHELPER#
  111. exit 0