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