Bug 2176337 - systemd upgrade should not forcibly add 'systemd' in passwd nsswitch.conf
Summary: systemd upgrade should not forcibly add 'systemd' in passwd nsswitch.conf
Keywords:
Status: VERIFIED
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: systemd
Version: 9.1
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: rc
: ---
Assignee: Jacek Migacz
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-03-08 01:38 UTC by Ding-Yi Chen
Modified: 2023-08-17 10:44 UTC (History)
3 users (show)

Fixed In Version: systemd-252-16.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Gitlab redhat/centos-stream/rpms systemd merge_requests 78 0 None merged spec: Append 'systemd' to nsswitch.conf only during install 2023-05-29 11:36:16 UTC
Red Hat Bugzilla 1577250 0 unspecified CLOSED systemd-libs modifies /etc/nsswitch.conf in scriptlets which conflicts with authselect on Fedora 28 2023-03-08 01:57:26 UTC
Red Hat Issue Tracker RHELPLAN-151008 0 None None None 2023-03-08 01:40:21 UTC

Description Ding-Yi Chen 2023-03-08 01:38:54 UTC
Description of problem:

post script of systemd forcily append of `systemd` in following databases

- passwd
- group

While the behavior make sense for initial installation, but not necessary for upgrade. Some customers need to use their own nsswitch.conf, and would not want it to be modified by systemd upgrade script.


Quote Pavel Březina from https://bugzilla.redhat.com/show_bug.cgi?id=1577250#c7

> Do you actually need to run it during upgrade?
> Wouldn't it be sufficient to run it only during first installation?


Version-Release number of selected component (if applicable):

systemd-250-12.el9_1.1.x86_64

How reproducible:

always


Steps to Reproduce:
1. Edit /etc/nsswitch.conf, and make the passwd line become: 
 
   passwd: sss files
2. Upgrade systemd
3. grep passwd /etc/nsswitch.conf

Actual results:

systemd is forcibly appended 

passwd: sss files systemd

Expected results:

the passwd line is untouched

passwd: sss files

Additional info:

Work around:

Instead of removing systemd keywords, comment them out like

 
passwd:     files sss # systemd
group:      files sss # systemd


================ systemd post script
# rpm -q --scripts systemd-libs
postinstall scriptlet (using /bin/sh):


function mod_nss() {
    if [ -f "$1" ] ; then
        # 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)"
if [ "$FILE" = "/etc/authselect/nsswitch.conf" ] && authselect check &>/dev/null; then
        mod_nss "/etc/authselect/user-nsswitch.conf"
        authselect apply-changes &> /dev/null || :
else
        mod_nss "$FILE"
        # also apply the same changes to user-nsswitch.conf to affect
        # possible future authselect configuration
        mod_nss "/etc/authselect/user-nsswitch.conf"
fi
...

Comment 1 Pavel Březina 2023-03-29 08:42:25 UTC
Does systemd still touch the nsswitch.conf on its own? AFAIK I removed the scriptlets in Fedora 37... This can be left on authselect, so it shouldn't be necessary to run any scriptlet on systemd side.

See: https://fedoraproject.org/wiki/Changes/Make_Authselect_Mandatory

Comment 2 Pavel Březina 2023-03-29 08:46:48 UTC
Ah, this is RHEL, the authselect change is not yet there. In that case, probably touching nsswitch.conf only on first install should be sufficient to avoid overriding user changes.


Note You need to log in before you can comment on or make changes to this bug.