File: debian-security-support.postinst

package info (click to toggle)
debian-security-support 1%3A10%2B2022.08.23
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 368 kB
  • sloc: perl: 776; sh: 419; makefile: 108
file content (76 lines) | stat: -rw-r--r-- 2,080 bytes parent folder | download
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh

set -e

. /usr/share/debconf/confmodule

USERNAME=debian-security-support
LIB_DIR="/var/lib/$USERNAME"

######################################################################
#                                                                    #
# WARNING: if you modify code here, you probably also need to modify #
#          ../check-support-status.hook                              #
#                                                                    #
######################################################################

case "$1" in
configure)
    # assert user

    if ! getent passwd "$USERNAME" > /dev/null; then
        adduser \
            --system --quiet \
            --home "$LIB_DIR" \
            --shell /bin/false --group \
            --gecos "Debian security support check" \
            "$USERNAME"
    fi

    # needed for schroots which copy /etc/passwd from the host
    if [ ! -d "$LIB_DIR" ]; then
        mkdir "$LIB_DIR"
        chown $USERNAME:$USERNAME "$LIB_DIR"
    fi

    if [ "$TMPDIR" ] && [ "$(stat --format=%a "$TMPDIR")" != '1777' ] ; then
        export TMPDIR='/tmp'
    fi

    TEMPDIR="$(mktemp --tmpdir --directory debian-security-support.postinst.XXXXX)"
    trap "rm -rf '$TEMPDIR'" EXIT

    MODES="ended limited earlyend"

    for MODE in $MODES ; do
        OUTPUT="$TEMPDIR/output"
        runuser "$USERNAME" --shell /bin/bash --command "
        check-support-status \
            --type $MODE \
            --no-heading \
            --status-db \"$LIB_DIR/security-support.semaphore\" \
        " >"$OUTPUT"

        if [ -s "$OUTPUT" ] ; then
            db_capb escape
            db_subst debian-security-support/$MODE MESSAGE "$(debconf-escape -e <"$OUTPUT")"
            db_input critical debian-security-support/$MODE || true
            db_go
            db_reset debian-security-support/$MODE
        fi
    done
    ;;
abort-upgrade|abort-remove|abort-deconfigure)
    ;;
triggered)
    ;;
*)
    echo "postinst called with unknown argument '$1'"
    exit 1
    ;;
esac

db_stop

#DEBHELPER#
exit 0