summaryrefslogtreecommitdiffhomepage
path: root/debian/debug-me-server.postinst
blob: 83a895a8a3b92650f6567d93694263fbf45f4a9f (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
#!/bin/sh

set -e

if ! getent passwd _debug-me >/dev/null; then
    # --force-badname needed until #521883 resolved
    adduser --system --group --disabled-login --disabled-password \
            --home /var/log/debug-me --force-badname _debug-me
fi
mkdir -p /var/log/debug-me
chmod 700 /var/log/debug-me
chown _debug-me:_debug-me /var/log/debug-me

# We don't need to chown the contents of /var/log/debug-me because the
# postrm either removes both the _debug-me user and the
# /var/log/debug-me directory, or removes neither of them.  So we
# cannot get a situation where there are log files in
# /var/log/debug-me which need to be chowned to the UID of the new
# _debug-me user.
#
# If the postrm is ever changed not to delete the logs in
# /var/log/debug-me even on a package purge, but instead to chown them
# to root, or similar, we would need something like the following
# (untested):
#
# for f in /var/log/debug-me/*; do
#     if test -f "$f"; then
#         links="$(stat --format=%h \"$f\")"
#         if test $links -eq 1; then
#             chown _debug-me:_debug-me "$f"
#         fi
#     fi
# done
#
# (`chown -R` should not be used -- see Lintian tag maintainer-script-should-not-use-recursive-chown-or-chmod)

#DEBHELPER#