| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
#DEBHELPER# |
| 6 |
|
| 7 |
# begin-remove-after: released:forky |
| 8 |
# systemd/251.3-2 (between Debian 11 and 12) added libnss-systemd to the |
| 9 |
# shadow and gshadow databases, not just passwd and group as before, but |
| 10 |
# at the time existing systems were not updated to match. |
| 11 |
# Ensure that it is listed in all four databases, while preserving |
| 12 |
# configuration for any database that already mentions it. (#1118640) |
| 13 |
fix_1118640 () { |
| 14 |
local nsswitch="${DPKG_ROOT}/etc/nsswitch.conf" |
| 15 |
local db |
| 16 |
local line |
| 17 |
|
| 18 |
for db in passwd group shadow gshadow; do |
| 19 |
if line="$(grep -E "^$db:"'[^#]*\s(systemd)(\s|#|$)' "$nsswitch")"; then |
| 20 |
if [ "$DPKG_MAINTSCRIPT_DEBUG" = 1 ]; then |
| 21 |
echo "$db configuration for libnss-systemd already looks OK: $line" >&2 |
| 22 |
fi |
| 23 |
else |
| 24 |
echo "Adding libnss-systemd to $db configuration..." >&2 |
| 25 |
sed -E -i \ |
| 26 |
-e "/^$db:"'\s[^#]*$/ s/$/ systemd/' \ |
| 27 |
-e "/^$db:"'\s.*#/ s/#/ systemd #/' \ |
| 28 |
"$nsswitch" |
| 29 |
fi |
| 30 |
done |
| 31 |
} |
| 32 |
# We do this for upgrades from versions where it was not yet fixed |
| 33 |
# (Debian 11, 12 or 13), and also for new installations (which should |
| 34 |
# be a no-op, but there could conceivably be stale configuration |
| 35 |
# still present if an old version was removed but not purged). |
| 36 |
if [ "$1" = configure ] && dpkg --compare-versions "$2" lt 258.1-2~; then |
| 37 |
fix_1118640 |
| 38 |
fi |
| 39 |
# end-remove-after |