tor.postinst 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. find /var/lib/tor ! -user debian-tor -o ! -group debian-tor -print0 | xargs -0 --no-run-if-empty chown debian-tor:debian-tor
  29. find /var/lib/tor -type d -print0 | xargs -0 --no-run-if-empty chmod 02700
  30. find /var/lib/tor -type f -print0 | xargs -0 --no-run-if-empty chmod 00600
  31. find /var/run/tor ! -user debian-tor -o ! -group debian-tor -print0 | xargs -0 --no-run-if-empty chown debian-tor:debian-tor
  32. find /var/run/tor -type d -print0 | xargs -0 --no-run-if-empty chmod 02750
  33. find /var/run/tor -type f -print0 | xargs -0 --no-run-if-empty chmod 00600
  34. find /var/log/tor ! -user debian-tor -o ! -group adm -print0 | xargs -0 --no-run-if-empty chown debian-tor:adm
  35. find /var/log/tor -type d -print0 | xargs -0 --no-run-if-empty chmod 02750
  36. find /var/log/tor -type f -print0 | xargs -0 --no-run-if-empty chmod 00640
  37. #DEBHELPER#
  38. exit 0