tor.postinst 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #DEBHELPER#
  45. exit 0