Bug 1173119

Summary: nsswitch.conf moved to /usr/etc
Product: [openSUSE] openSUSE Tumbleweed Reporter: Ludwig Nussel <lnussel>
Component: YaST2Assignee: YaST Team <yast-internal>
Status: RESOLVED FIXED QA Contact: Jiri Srain <jsrain>
Severity: Normal    
Priority: P5 - None CC: ancor, dgonzalez, jlopez, lnussel
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
URL: https://trello.com/c/IILaIEvG
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Ludwig Nussel 2020-06-18 13:21:32 UTC
in Factory the default nsswitch.conf is now in /usr/etc/nsswitch.conf. /etc/nsswitch.conf doesn't exist anymore. That means for yast it needs to read the default from /usr/etc/nsswitch.conf and changed lines to /etc/nsswitch.conf. It must not duplicate the complete file though.
Comment 1 José Iván López González 2020-06-19 14:19:41 UTC
Tracking it in trello. Thanks!
Comment 2 David Diaz 2020-07-20 13:40:29 UTC
(In reply to Ludwig Nussel from comment #0)
> [...] That means for yast it needs to
> read the default from /usr/etc/nsswitch.conf and changed lines to
> /etc/nsswitch.conf. It must not duplicate the complete file though.

If I didn't miss something, this is not working as described. Once you have the /etc/nsswitch.conf file in the system, /usr/etc/nsswitch.conf is completely ignored.

To check it, I installed the latest openSUSE TW available, 


> localhost:~ # cat /etc/os-release 
> 
> NAME="openSUSE Tumbleweed"
> \# VERSION="20200715"
> ID="opensuse-tumbleweed"
> ID_LIKE="opensuse suse"
> VERSION_ID="20200715"
> PRETTY_NAME="openSUSE Tumbleweed"
> ANSI_COLOR="0;32"
> CPE_NAME="cpe:/o:opensuse:tumbleweed:20200715"
> BUG_REPORT_URL="https://bugs.opensuse.org"
> HOME_URL="https://www.opensuse.org/"
> LOGO="distributor-logo"


which comes with both files


> localhost:~ # find / -name "nsswitch.conf"
> 
> /usr/etc/nsswitch.conf
> /etc/nsswitch.conf


And, using the `strace` command, I could check that only /etc/nsswitch.conf file is being read


> localhost:~ # strace getent hosts 2>&1 | grep nsswitch.conf
> 
> openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
> read(3, "#\n# /etc/nsswitch.conf\n#\n# An ex"..., 4096) = 2221


Then, I "removed" it temporary, which results in /usr/etc/nsswitch.conf been reading after failing to load /etc/nsswitch.conf


> localhost:~ # strace getent hosts 2>&1 | grep nsswitch.conf
> 
> openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
> openat(AT_FDCWD, "/usr/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
> read(3, "#\n# /etc/nsswitch.conf\n#\n# An ex"..., 4096) = 2190


Going a little bit further, I created a very basic /etc/nsswitch.conf file just to "overwrite" the configuration of /usr/etc/nsswitch.conf for `passwd` from "compat" to "files". But, contrary as expected, the /usr/etc/nsswitch.conf file is not used for reading the rest of configuration


> localhost:~ # echo "passwd:  files" > /etc/nsswitch.conf
> localhost:~ # strace getent hosts 2>&1 | grep nsswitch.conf
> 
> openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3


Even more, to probe if "only changed lines should be added to /etc/nsswitch.conf", I modified the "hosts" entry in /usr/etc/nsswitch.conf from "files nis" to "db" without success


> localhost:~ # getent hosts
> 127.0.0.1       localhost


However, setting it in /etc/nsswitch.conf works


> 
> localhost:~ # echo "hosts:   db" > /etc/nsswitch.conf
> localhost:~ # getent hosts
> 
> localhost:~ # 
> 


With those tests in mind, do you think there is another problem here? Or maybe still being necessary to duplicate the file when wanting to overwrite some entries?

Thanks.
Comment 3 David Diaz 2020-07-22 09:53:43 UTC
In fact, seems that this configuration file corresponds to the "Variant 3" described in "Packaging UsrEtc"[1] openSUSE wiki page. Then, we will resume the work considering that "/etc/nsswitch.conf" is a replacement of "/usr/etc/nsswitch.conf"


[1] https://en.opensuse.org/openSUSE:Packaging_UsrEtc#Variant_3
Comment 4 Ludwig Nussel 2020-08-05 08:17:57 UTC
I'll have to revisit the glibc patch. Having to duplicate the entire file was not intended.
Comment 5 Ancor Gonzalez Sosa 2020-08-10 09:42:59 UTC
In principle this bug was fixed via
https://build.opensuse.org/request/show/823151

(In reply to Ludwig Nussel from comment #4)
> I'll have to revisit the glibc patch. Having to duplicate the entire file
> was not intended.

The previous submit request assumes that's the case. If you confirm duplicating the whole file is not needed, please reopen this bug.