From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 653133858D28 for ; Wed, 15 Dec 2021 21:45:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 653133858D28 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-608-HSPOpA3sPYS5-A4a6cpeYg-1; Wed, 15 Dec 2021 16:45:07 -0500 X-MC-Unique: HSPOpA3sPYS5-A4a6cpeYg-1 Received: by mail-qv1-f70.google.com with SMTP id jn10-20020ad45dea000000b003bd74c93df4so31683687qvb.15 for ; Wed, 15 Dec 2021 13:45:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:organization:in-reply-to :content-transfer-encoding; bh=0ThFWtd8rCKOl5uU2VUoighE5V67PdL/H7k8lZzRqEk=; b=UtSNB3gvRYvCqTJwZK3ZeHI6TgaHxYDi6IAmgBBQ3Duj+edpERMQ6cMoH9gy33mtoJ Isov/rKJHLqVtIBBk8cJXFcIqdsrNMye0hEk/G5P+3Q/IILuvCjAX3PwvquE1yNzfFOX hGIe+Or/BCMzK1616YDU2Omjj/r+0N/9ITUXU4xmn15g8DNdY0gMKdXdv/k7mNyDVHAS 4p5jLv5TX6sbEppJFtjz5EajWcGM3BBb17vG/+SZlfqxJ6jLqPWN34qJYjVO/EMHQIBK MEhZCDSxVnsEg8r8EY3k8629vWaDvqnfhYszanC/fMAf2SeqmT4OB1q7GfQ5cwZpjwGo CPcA== X-Gm-Message-State: AOAM533EkcYPgbMH6PA99zgVV7rc9petzL9+xTJ6QggaRQUXlVQ0MeWv D8NZ2np2+SOvBUHey1WfV/6latuWz5IVaajHEe8MRLOOjvRnq7eyoMUVmADe8pEC5xn2j7Pvlq1 /s1ilHXg8o9S0OjPqEIqG X-Received: by 2002:a05:620a:2942:: with SMTP id n2mr10303496qkp.608.1639604707217; Wed, 15 Dec 2021 13:45:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDHNYQ//kARPdrC41mNDOtqnig3G17KLvur415678pKVhXFRRAhH+W+xWtMaNhcME2lSoABA== X-Received: by 2002:a05:620a:2942:: with SMTP id n2mr10303484qkp.608.1639604706697; Wed, 15 Dec 2021 13:45:06 -0800 (PST) Received: from [192.168.0.241] (135-23-175-80.cpe.pppoe.ca. [135.23.175.80]) by smtp.gmail.com with ESMTPSA id j16sm2379660qtx.92.2021.12.15.13.45.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Dec 2021 13:45:06 -0800 (PST) Message-ID: Date: Wed, 15 Dec 2021 16:45:05 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH] nss: Use "files dns" as the default for the hosts database (bug 28700) To: Florian Weimer , libc-alpha@sourceware.org References: <87zgp1pvk2.fsf@oldenburg.str.redhat.com> From: Carlos O'Donell Organization: Red Hat In-Reply-To: <87zgp1pvk2.fsf@oldenburg.str.redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Dec 2021 21:45:10 -0000 On 12/15/21 13:33, Florian Weimer via Libc-alpha wrote: > This matches what is currently in nss/nsswitch.conf. The new ordering > matches what most distributions use in their installed configuration > files. > > It is common to add localhost to /etc/hosts because the name does not > exist in the DNS, but is commonly used as a host name. > > With the built-in "dns [!UNAVAIL=return] files" default, dns is > searched first and provides an answer for "localhost" (NXDOMAIN). > We never look at the files database as a result, so the contents of > /etc/hosts is ignored. This means that "getent hosts localhost" > fail without a /etc/nsswitch.conf file, even though the host name > is listed in /etc/hosts. > > Tested on i686-linux-gnu and x86_64-linux-gnu. This is a no-brainer IMO. And files and dns are *builtin* to glibc so the builtin default using only builtin modules is a great default IMO. There will be no further dlopens required to handle IdM queries via NSS. Please note that the linux man pages still show: hosts: dns [!UNAVAIL=return] files as an example, and it would be kind to send Michael Kerrisk a patch for this. I expect most downstream distributions have never seen this because they ship with a modified /etc/nsswitch.conf that the distribution owns. I expect the experimentation we're seeing upstream in this area to become more and more common. The defaults should make sense for modern systems. The builtin was something I reviewed when we did the NSS reloading work and it struck me as odd that it was dns first. LGTM. Reviewed-by: Carlos O'Donell > Thanks, > Florian > --- > manual/nss.texi | 5 ++--- > nss/XXX-lookup.c | 2 +- > nss/nss_database.c | 4 ++-- > 3 files changed, 5 insertions(+), 6 deletions(-) > > diff --git a/manual/nss.texi b/manual/nss.texi > index 3aaa7786f8..524d22ad1e 100644 > --- a/manual/nss.texi > +++ b/manual/nss.texi > @@ -324,9 +324,8 @@ missing. > > @cindex default value, and NSS > For the @code{hosts} and @code{networks} databases the default value is > -@code{dns [!UNAVAIL=return] files}. I.e., the system is prepared for > -the DNS service not to be available but if it is available the answer it > -returns is definitive. > +@code{files dns}. I.e., local configuration will override the contents > +of the domain name system (DNS). OK. > > The @code{passwd}, @code{group}, and @code{shadow} databases was > traditionally handled in a special way. The appropriate files in the > diff --git a/nss/XXX-lookup.c b/nss/XXX-lookup.c > index 302c6361e0..e129f699fa 100644 > --- a/nss/XXX-lookup.c > +++ b/nss/XXX-lookup.c > @@ -28,7 +28,7 @@ > |* ALTERNATE_NAME - name of another service which is examined in *| > |* case DATABASE_NAME is not found *| > |* *| > -|* DEFAULT_CONFIG - string for default conf (e.g. "dns files") *| > +|* DEFAULT_CONFIG - string for default conf (e.g. "files dns") *| OK. > |* *| > \*******************************************************************/ > > diff --git a/nss/nss_database.c b/nss/nss_database.c > index ab121cb371..54561f0328 100644 > --- a/nss/nss_database.c > +++ b/nss/nss_database.c > @@ -80,7 +80,7 @@ enum nss_database_default > { > nss_database_default_defconfig = 0, /* "nis [NOTFOUND=return] files". */ > nss_database_default_compat, /* "compat [NOTFOUND=return] files". */ > - nss_database_default_dns, /* "dns [!UNAVAIL=return] files". */ > + nss_database_default_dns, /* "files dns". */ OK. > nss_database_default_files, /* "files". */ > nss_database_default_nis, /* "nis". */ > nss_database_default_nis_nisplus, /* "nis nisplus". */ > @@ -133,7 +133,7 @@ nss_database_select_default (struct nss_database_default_cache *cache, > #endif > > case nss_database_default_dns: > - line = "dns [!UNAVAIL=return] files"; > + line = "files dns"; OK. > break; > > case nss_database_default_files: > -- Cheers, Carlos.