tor.postinst 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. if [ "$home" = "/var/lib/tor" ]; then
  9. :
  10. #echo "debian-tor homedir check: ok"
  11. else
  12. echo "ERROR: debian-tor account has an unexpected home directory!"
  13. echo "It should be '/var/lib/tor', but it is '$home'."
  14. echo "Removing the debian-tor user might fix this, but the question"
  15. echo "remains how you got into this mess to begin with."
  16. exit 1
  17. fi
  18. else
  19. adduser --quiet \
  20. --system \
  21. --disabled-password \
  22. --home /var/lib/tor \
  23. --no-create-home \
  24. --shell /bin/bash \
  25. --group \
  26. debian-tor
  27. fi
  28. for i in lib run log; do
  29. if ! [ -d "/var/$i/tor" ]; then
  30. echo "Something or somebody made /var/$i/tor disappear."
  31. echo "Creating one for you again."
  32. mkdir "/var/$i/tor"
  33. fi
  34. done
  35. find /var/lib/tor \( \( ! -user debian-tor \) -o \( ! -group debian-tor \) \) -print0 | xargs -0 --no-run-if-empty chown debian-tor:debian-tor
  36. find /var/lib/tor -type d -print0 | xargs -0 --no-run-if-empty chmod 02700
  37. find /var/lib/tor -type f -print0 | xargs -0 --no-run-if-empty chmod 00600
  38. find /var/run/tor \( \( ! -user debian-tor \) -o \( ! -group debian-tor \) \) -print0 | xargs -0 --no-run-if-empty chown debian-tor:debian-tor
  39. find /var/run/tor -type d -print0 | xargs -0 --no-run-if-empty chmod 02750
  40. find /var/run/tor -type f -print0 | xargs -0 --no-run-if-empty chmod 00600
  41. find /var/log/tor \( \( ! -user debian-tor \) -o \( ! -group adm \) \) -print0 | xargs -0 --no-run-if-empty chown debian-tor:adm
  42. find /var/log/tor -type d -print0 | xargs -0 --no-run-if-empty chmod 02750
  43. find /var/log/tor -type f -print0 | xargs -0 --no-run-if-empty chmod 00640
  44. move_away_keys=0
  45. if [ "$1" = "configure" ] &&
  46. [ -e /var/lib/tor/keys ] &&
  47. [ ! -z "$2" ]; then
  48. if dpkg --compare-versions "$2" lt 0.1.2.19-2; then
  49. move_away_keys=1
  50. elif dpkg --compare-versions "$2" gt 0.2.0 &&
  51. dpkg --compare-versions "$2" lt 0.2.0.26-rc; then
  52. move_away_keys=1
  53. fi
  54. fi
  55. if [ "$move_away_keys" = "1" ]; then
  56. echo "Retiring possibly compromised keys. See /usr/share/doc/tor/NEWS.Debian.gz"
  57. echo "and /var/lib/tor/keys/moved-away-by-tor-package/README.REALLY for"
  58. echo "further information."
  59. if ! [ -d /var/lib/tor/keys/moved-away-by-tor-package ]; then
  60. mkdir /var/lib/tor/keys/moved-away-by-tor-package
  61. cat > /var/lib/tor/keys/moved-away-by-tor-package/README.REALLY << EOF
  62. It has been discovered that the random number generator in Debian's
  63. openssl package is predictable. This is caused by an incorrect
  64. Debian-specific change to the openssl package (CVE-2008-0166). As a
  65. result, cryptographic key material may be guessable.
  66. See Debian Security Advisory number 1571 (DSA-1571) for more information:
  67. http://lists.debian.org/debian-security-announce/2008/msg00152.html
  68. The Debian package for Tor has moved away the onion keys upon package
  69. upgrade, and it will have moved away your identity key if it was created
  70. in the affected timeframe. There is no sure way to automatically tell
  71. if your key was created with an affected openssl library, so this move
  72. is done unconditionally.
  73. If you have restarted Tor since this change (and the package probably
  74. did that for you already unless you configured your system differently)
  75. then the Tor daemon already created new keys for itself and in all
  76. likelyhood is already working just fine with new keys.
  77. If you are absolutely certain that your identity key was created with
  78. a non-affected version of openssl and for some reason you have to retain
  79. the old identity, then you can move back the copy of secret_id_key to
  80. /var/lib/tor/keys. Do not move back the onion keys, they were created
  81. only recently since they are temporary keys with a lifetime of only a few
  82. days anyway.
  83. Sincerely,
  84. Peter Palfrader, Tue, 13 May 2008 13:32:23 +0200
  85. EOF
  86. fi
  87. for f in secret_onion_key secret_onion_key.old; do
  88. if [ -e /var/lib/tor/keys/"$f" ]; then
  89. mv -v /var/lib/tor/keys/"$f" /var/lib/tor/keys/moved-away-by-tor-package/"$f"
  90. fi
  91. done
  92. if [ -e /var/lib/tor/keys/secret_id_key ]; then
  93. id_mtime=`/usr/bin/stat -c %Y /var/lib/tor/keys/secret_id_key`
  94. sept=`date -d '2006-09-10' +%s`
  95. if [ "$id_mtime" -gt "$sept" ] ; then
  96. mv -v /var/lib/tor/keys/secret_id_key /var/lib/tor/keys/moved-away-by-tor-package/secret_id_key
  97. fi
  98. fi
  99. fi
  100. #DEBHELPER#
  101. exit 0