93dc2d
commit dc9b69d5331dcdca4547c0490cb9fefbd89e40f6
93dc2d
Author: Florian Weimer <fweimer@redhat.com>
93dc2d
Date:   Fri Dec 17 12:01:20 2021 +0100
93dc2d
93dc2d
    nss: Use "files dns" as the default for the hosts database (bug 28700)
93dc2d
    
93dc2d
    This matches what is currently in nss/nsswitch.conf.  The new ordering
93dc2d
    matches what most distributions use in their installed configuration
93dc2d
    files.
93dc2d
    
93dc2d
    It is common to add localhost to /etc/hosts because the name does not
93dc2d
    exist in the DNS, but is commonly used as a host name.
93dc2d
    
93dc2d
    With the built-in "dns [!UNAVAIL=return] files" default, dns is
93dc2d
    searched first and provides an answer for "localhost" (NXDOMAIN).
93dc2d
    We never look at the files database as a result, so the contents of
93dc2d
    /etc/hosts is ignored.  This means that "getent hosts localhost"
93dc2d
    fail without a /etc/nsswitch.conf file, even though the host name
93dc2d
    is listed in /etc/hosts.
93dc2d
    
93dc2d
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
93dc2d
    (cherry picked from commit b99b0f93ee8762fe53ff65802deb6f00700b9924)
93dc2d
93dc2d
diff --git a/manual/nss.texi b/manual/nss.texi
93dc2d
index 3aaa7786f8cf3168..524d22ad1e7f8ca0 100644
93dc2d
--- a/manual/nss.texi
93dc2d
+++ b/manual/nss.texi
93dc2d
@@ -324,9 +324,8 @@ missing.
93dc2d
 
93dc2d
 @cindex default value, and NSS
93dc2d
 For the @code{hosts} and @code{networks} databases the default value is
93dc2d
-@code{dns [!UNAVAIL=return] files}.  I.e., the system is prepared for
93dc2d
-the DNS service not to be available but if it is available the answer it
93dc2d
-returns is definitive.
93dc2d
+@code{files dns}.  I.e., local configuration will override the contents
93dc2d
+of the domain name system (DNS).
93dc2d
 
93dc2d
 The @code{passwd}, @code{group}, and @code{shadow} databases was
93dc2d
 traditionally handled in a special way.  The appropriate files in the
93dc2d
diff --git a/nss/XXX-lookup.c b/nss/XXX-lookup.c
93dc2d
index f1c97f7c8e9d7378..dbc87868dd408d9f 100644
93dc2d
--- a/nss/XXX-lookup.c
93dc2d
+++ b/nss/XXX-lookup.c
93dc2d
@@ -29,7 +29,7 @@
93dc2d
 |* ALTERNATE_NAME - name of another service which is examined in   *|
93dc2d
 |*                  case DATABASE_NAME is not found                *|
93dc2d
 |* 								   *|
93dc2d
-|* DEFAULT_CONFIG - string for default conf (e.g. "dns files")	   *|
93dc2d
+|* DEFAULT_CONFIG - string for default conf (e.g. "files dns")	   *|
93dc2d
 |* 								   *|
93dc2d
 \*******************************************************************/
93dc2d
 
93dc2d
diff --git a/nss/nss_database.c b/nss/nss_database.c
93dc2d
index ab121cb371c087e9..54561f03287db2e4 100644
93dc2d
--- a/nss/nss_database.c
93dc2d
+++ b/nss/nss_database.c
93dc2d
@@ -80,7 +80,7 @@ enum nss_database_default
93dc2d
 {
93dc2d
  nss_database_default_defconfig = 0, /* "nis [NOTFOUND=return] files".  */
93dc2d
  nss_database_default_compat, /* "compat [NOTFOUND=return] files".  */
93dc2d
- nss_database_default_dns,    /* "dns [!UNAVAIL=return] files".  */
93dc2d
+ nss_database_default_dns,    /* "files dns".  */
93dc2d
  nss_database_default_files,    /* "files".  */
93dc2d
  nss_database_default_nis,    /* "nis".  */
93dc2d
  nss_database_default_nis_nisplus,    /* "nis nisplus".  */
93dc2d
@@ -133,7 +133,7 @@ nss_database_select_default (struct nss_database_default_cache *cache,
93dc2d
 #endif
93dc2d
 
93dc2d
     case nss_database_default_dns:
93dc2d
-      line = "dns [!UNAVAIL=return] files";
93dc2d
+      line = "files dns";
93dc2d
       break;
93dc2d
 
93dc2d
     case nss_database_default_files: