File: libnss-systemd.postinst

package info (click to toggle)
systemd 259-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 105,132 kB
  • sloc: ansic: 726,480; xml: 121,118; python: 36,740; sh: 35,016; cpp: 946; makefile: 273; awk: 102; lisp: 13; sed: 1
file content (39 lines) | stat: -rw-r--r-- 1,435 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
#!/bin/sh

set -e

#DEBHELPER#

# begin-remove-after: released:forky
# systemd/251.3-2 (between Debian 11 and 12) added libnss-systemd to the
# shadow and gshadow databases, not just passwd and group as before, but
# at the time existing systems were not updated to match.
# Ensure that it is listed in all four databases, while preserving
# configuration for any database that already mentions it. (#1118640)
fix_1118640 () {
    local nsswitch="${DPKG_ROOT}/etc/nsswitch.conf"
    local db
    local line

    for db in passwd group shadow gshadow; do
        if line="$(grep -E "^$db:"'[^#]*\s(systemd)(\s|#|$)' "$nsswitch")"; then
            if [ "$DPKG_MAINTSCRIPT_DEBUG" = 1 ]; then
                echo "$db configuration for libnss-systemd already looks OK: $line" >&2
            fi
        else
            echo "Adding libnss-systemd to $db configuration..." >&2
            sed -E -i \
                -e "/^$db:"'\s[^#]*$/ s/$/ systemd/' \
                -e "/^$db:"'\s.*#/ s/#/ systemd #/' \
                "$nsswitch"
        fi
    done
}
# We do this for upgrades from versions where it was not yet fixed
# (Debian 11, 12 or 13), and also for new installations (which should
# be a no-op, but there could conceivably be stale configuration
# still present if an old version was removed but not purged).
if [ "$1" = configure ] && dpkg --compare-versions "$2" lt 258.1-2~; then
    fix_1118640
fi
# end-remove-after