]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Warn if failed to read existing /etc/nsswitch.conf
authorChristian Göttsche <cgzones@googlemail.com>
Mon, 2 Jan 2023 15:11:58 +0000 (16:11 +0100)
committerSerge Hallyn <serge@hallyn.com>
Wed, 4 Jan 2023 20:21:43 +0000 (14:21 -0600)
Commit 90424e7c ("Don't warn when failed to open /etc/nsswitch.conf")
removed the logging for failing to read /etc/nsswitch.conf to reduce the
noise in the case the file does not exists (e.g. musl based systems).

Reintroduce a warning if /etc/nsswitch.conf exists but we failed to read
it (e.g. permission denied).

Improves: 90424e7c ("Don't warn when failed to open /etc/nsswitch.conf")

lib/nss.c

index 23d05182287a397bc580580a6ede0ea687bf30e5..89de2ac9def7526f8a4fa300a9711a324a404390 100644 (file)
--- a/lib/nss.c
+++ b/lib/nss.c
@@ -59,6 +59,9 @@ void nss_init(const char *nsswitch_path) {
        //   subid:     files
        nssfp = fopen(nsswitch_path, "r");
        if (!nssfp) {
+               if (errno != ENOENT)
+                       fprintf(shadow_logfd, "Failed opening %s: %m\n", nsswitch_path);
+
                atomic_store(&nss_init_completed, true);
                return;
        }