summaryrefslogtreecommitdiff
path: root/debian/tor.postinst
blob: 0d2a4dd415358db393a100c2605596835e54e9e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh -e

# checking debian-tor account

uid=`getent passwd debian-tor | cut -d ":" -f 3`
home=`getent passwd debian-tor | cut -d ":" -f 6`

# if there is the uid the account is there and we can do
# the sanit(ar)y checks otherwise we can safely create it.

if [ "$uid" ]; then
	if [ "$home" = "/var/lib/tor" ]; then
		:
		#echo "debian-tor homedir check: ok"
	else
		echo "ERROR: debian-tor account has an unexpected home directory!"
		echo "It should be '/var/lib/tor', but it is '$home'."
		echo "Removing the debian-tor user might fix this, but the question"
		echo "remains how you got into this mess to begin with."
		exit 1
	fi
else
	adduser --quiet \
		--system \
		--disabled-password \
		--home /var/lib/tor \
		--no-create-home \
		--shell /bin/bash \
		--group \
		debian-tor
fi

# ch{owning,moding} things around
# We will do nothing across upgrades.

if [ "$2" = "" ]; then
    for i in lib log run; do
	chown -R debian-tor:debian-tor /var/$i/tor
	chmod -R 700 /var/$i/tor
	find /var/$i/tor -type f -exec chmod 600 '{}' ';'
    done
    chgrp -R adm  /var/log/tor
    chmod -R g+rX /var/log/tor
    chmod    g+s  /var/log/tor
else
    # fix permissions of logs after 0.0.8+0.0.9pre5-1
    if [ "$1" = "configure" ]; then
        if dpkg --compare-versions "$2" le "0.0.8+0.0.9pre5-1" ; then
            chgrp -R adm  /var/log/tor
            chmod -R g+rX /var/log/tor
            chmod    g+s  /var/log/tor
        fi
    fi
fi

#DEBHELPER#

exit 0