Bug 2096369

Summary: [spec] systemd-libs-239-51.el8_5.5.x86_64 editing compiled nssswitch file
Product: Red Hat Enterprise Linux 8 Reporter: Mike Ralph <mralph>
Component: systemdAssignee: Jan Macku <jamacku>
Status: CLOSED ERRATA QA Contact: Frantisek Sumsal <fsumsal>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 8.5CC: maburgha, msekleta, systemd-maint-list
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: systemd-239-61.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-08 10:49:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mike Ralph 2022-06-13 16:15:19 UTC
Description of problem:
  Upon patching systemd-libs-239-51.el8_5.5.x86_64 edits nssswitch.conf which is complied from a custom profile in authselect.

Version-Release number of selected component (if applicable):
  systemd-libs-239-51.el8_5.5.x86_64

How reproducible:
  Consistantly

Steps to Reproduce:
1. Patch system that is using a customer authselect profile with nssswitch.conf.

Actual results:
  systemd gets added to /etc/nssswitch.conf passwd and group.


Expected results:
  No change to /etc/nssswitch.conf

Additional info:
# rpm -q --scripts systemd-libs-239-51.el8_5.5.x86_64

This produces the following:

postinstall scriptlet (using /bin/sh):


function mod_nss() {
    if [ -f "$1" ] ; then
        # sed-fu to add myhostanme to hosts line
        grep -E -q '^hosts:.* myhostname' "$1" ||
        sed -i.bak -e '
                /^hosts:/ !b
                /\<myhostname\>/ b
                s/[[:blank:]]*$/ myhostname/
                ' "$1" &>/dev/null || :

        # Add nss-systemd to passwd and group
        grep -E -q '^(passwd|group):.* systemd' "$1" ||
        sed -i.bak -r -e '
                s/^(passwd|group):(.*)/\1: \2 systemd/
                ' "$1" &>/dev/null || :
    fi
}

FILE="$(readlink /etc/nsswitch.conf || echo /etc/nsswitch.conf)"
mod_nss "$FILE"

if [ "$FILE" = "/etc/authselect/user-nsswitch.conf" ] ; then
        authselect apply-changes &> /dev/null
else
        # also apply the same changes to nsswitch.conf to affect
        # possible future authselect configuration
	mod_nss "/etc/authselect/user-nsswitch.conf"
fi

# check if nobody or nfsnobody is defined
export SYSTEMD_NSS_BYPASS_SYNTHETIC=1
if getent passwd nfsnobody &>/dev/null; then
   test -f /etc/systemd/dont-synthesize-nobody || {
       echo 'Detected system with nfsnobody defined, creating /etc/systemd/dont-synthesize-nobody'
       mkdir -p /etc/systemd || :
       : >/etc/systemd/dont-synthesize-nobody || :
   }
elif getent passwd nobody 2>/dev/null | grep -v 'nobody:[x*]:65534:65534:.*:/:/sbin/nologin' &>/dev/null; then
   test -f /etc/systemd/dont-synthesize-nobody || {
       echo 'Detected system with incompatible nobody defined, creating /etc/systemd/dont-synthesize-nobody'
       mkdir -p /etc/systemd || :
       : >/etc/systemd/dont-synthesize-nobody || :
   }
fi

Comment 6 errata-xmlrpc 2022-11-08 10:49:56 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (systemd bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:7727