[Pkg-sssd-devel] [Git][sssd-team/sssd][master] 3 commits: d/libnss-sss.post{inst, rm}: Add DPKG_ROOT support
Timo Aaltonen (@tjaalton)
gitlab at salsa.debian.org
Wed Aug 17 13:36:33 BST 2022
Timo Aaltonen pushed to branch master at Debian SSSD packaging / sssd
Commits:
62b8a467 by Gioele Barabucci at 2022-08-17T11:13:58+00:00
d/libnss-sss.post{inst,rm}: Add DPKG_ROOT support
- - - - -
4ded9ab2 by Gioele Barabucci at 2022-08-17T11:13:58+00:00
d/libnss-sss.postinst: Fix use of outdated `automounter` instead of `automount`
- - - - -
e020fd0b by Gioele Barabucci at 2022-08-17T11:13:58+00:00
d/libnss-sss.nss: Install NSS service `sss` via dh_installnss
`dh_installnss` provides a declarative way to install NSS services.
In comparison to the existing scripts, `dh_installnss` also handles
`DPKG_ROOT` and various edge-cases such as invalid `/etc/nsswitch.conf`
files, database lines with comments, etc.
- - - - -
4 changed files:
- debian/control
- + debian/libnss-sss.nss
- debian/libnss-sss.postinst
- debian/libnss-sss.postrm
Changes:
=====================================
debian/control
=====================================
@@ -11,6 +11,7 @@ Build-Depends:
debhelper-compat (= 12),
dh-apparmor,
dh-python,
+ dh-sequence-installnss,
dnsutils,
docbook-xml,
docbook-xsl,
=====================================
debian/libnss-sss.nss
=====================================
@@ -0,0 +1,6 @@
+passwd last sss
+group last sss
+shadow last sss
+netgroup last sss
+services last sss
+automount last sss
=====================================
debian/libnss-sss.postinst
=====================================
@@ -1,35 +1,23 @@
#!/bin/sh
set -e
-#DEBHELPER#
-
-# This code was taken from libnss-myhostname, which got it from nss-mdns:
-
log() {
echo "$*"
}
-# try to insert sss entries to the passwd, group, shadow and netgroup
-# lines in /etc/nsswitch.conf to automatically enable libnss-sss
-# support; do not change the configuration if the lines already
-# references some sss lookups
-insert_nss_entry() {
+# Add the `automount` database to nsswitch.conf if it's not there.
+insert_nss_automount_db () {
log "Checking NSS setup..."
# abort if /etc/nsswitch.conf does not exist
- if ! [ -e /etc/nsswitch.conf ]; then
- log "Could not find /etc/nsswitch.conf."
+ if ! [ -e "${DPGK_ROOT}/etc/nsswitch.conf" ]; then
+ log "Could not find ${DPKG_ROOT}/etc/nsswitch.conf."
return
fi
- # append 'sss' to the end of the line if it's not found already
- sed -i --regexp-extended '
- /^(passwd|group|shadow|netgroup|services|automounter):/ {
- /\bsss\b/! s/$/ sss/
- }
- ' /etc/nsswitch.conf
+
# and add a new entry for automount if it's not there
- if ! grep -q automount /etc/nsswitch.conf; then
- log "Adding an entry for automount."
- echo "automount: sss" >> /etc/nsswitch.conf
+ if ! grep -q automount "${DPKG_ROOT}/etc/nsswitch.conf" ; then
+ log "Setting up empty automount NSS database"
+ echo "automount: " >> "${DPKG_ROOT}/etc/nsswitch.conf"
fi
}
@@ -38,16 +26,17 @@ action="$1"
if [ configure = "$action" ]; then
if [ -z "$2" ]; then
log "First installation detected..."
- # first install: setup the recommended configuration (unless
- # nsswitch.conf already contains sss entries)
- insert_nss_entry
+ # first install: setup automount NSS database.
+ insert_nss_automount_db
else
# upgrade
version="$2"
# fix automount typo
if dpkg --compare-versions $version lt "2.2.3-3"; then
- sed -i 's/automounter/automount/' /etc/nsswitch.conf
+ sed -i 's/automounter/automount/' "${DPKG_ROOT}/etc/nsswitch.conf"
fi
fi
fi
+
+#DEBHELPER#
=====================================
debian/libnss-sss.postrm
=====================================
@@ -3,32 +3,26 @@ set -e
#DEBHELPER#
-# This code was taken from libnss-myhostname, which got it from nss-mdns:
-
log() {
echo "$*"
}
-remove_nss_entry() {
+remove_nss_automount_db () {
log "Checking NSS setup..."
# abort if /etc/nsswitch.conf does not exist
- if ! [ -e /etc/nsswitch.conf ]; then
- log "Could not find /etc/nsswitch.conf."
+ if ! [ -e "${DPKG_ROOT}/etc/nsswitch.conf" ]; then
+ log "Could not find ${DPKG_ROOT}/etc/nsswitch.conf."
return
fi
- sed -i --regexp-extended '
- /^(passwd|group|shadow|netgroup|services):/ {
- s/\bsss\b//g
- s/[[:space:]]+$//
- }
- ' /etc/nsswitch.conf
- sed -i '/^automount/d' /etc/nsswitch.conf
+
+ # Remove NSS databases: `automount` and `automounter` (legacy).
+ sed -i '/^automount/d' "${DPKG_ROOT}/etc/nsswitch.conf"
}
case "$1" in
remove|purge)
if [ "${DPKG_MAINTSCRIPT_PACKAGE_REFCOUNT:-1}" = 1 ]; then
- remove_nss_entry
+ remove_nss_automount_db
fi
;;
upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
View it on GitLab: https://salsa.debian.org/sssd-team/sssd/-/compare/e9667329cc9e4e64c646d7e309527561ee40106e...e020fd0bdb2ad5869f8871d8993f457a4aaef002
--
View it on GitLab: https://salsa.debian.org/sssd-team/sssd/-/compare/e9667329cc9e4e64c646d7e309527561ee40106e...e020fd0bdb2ad5869f8871d8993f457a4aaef002
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-sssd-devel/attachments/20220817/3277690c/attachment-0001.htm>
More information about the Pkg-sssd-devel
mailing list