From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 670E73870841; Wed, 22 Apr 2020 07:35:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 670E73870841 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: accounts: Don't keep old schemes when parsing nsswitch.conf X-Act-Checkin: newlib-cygwin X-Git-Author: David Macek via Cygwin-patches X-Git-Refname: refs/heads/master X-Git-Oldrev: d5add9ee5e5e6e5dca97bc6061f427407c006de0 X-Git-Newrev: 969c8392fe3122af31c288fb88e3ba1942f881d2 Message-Id: <20200422073523.670E73870841@sourceware.org> Date: Wed, 22 Apr 2020 07:35:23 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Apr 2020 07:35:23 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=969c8392fe3122af31c288fb88e3ba1942f881d2 commit 969c8392fe3122af31c288fb88e3ba1942f881d2 Author: David Macek via Cygwin-patches Date: Mon Apr 20 19:21:00 2020 +0200 Cygwin: accounts: Don't keep old schemes when parsing nsswitch.conf The implicit assumption seemed to be that any subsequent occurence of the same setting in nsswitch.conf is supposed to rewrite the previous ones completely. This was not the case if the third or any further schema was previously defined and the last line defined less than that (but at least 2), for example: ``` db_home: windows cygwin /myhome/%U db_home: cygwin desc ``` Let's document this behavior as well. Signed-off-by: David Macek Diff: --- winsup/cygwin/uinfo.cc | 7 +++---- winsup/doc/ntsec.xml | 5 +++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 2d5fc488b..b733a6ee8 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -790,12 +790,12 @@ cygheap_pwdgrp::nss_init_line (const char *line) scheme = gecos_scheme; if (scheme) { - uint16_t idx = 0; + for (uint16_t idx = 0; idx < NSS_SCHEME_MAX; ++idx) + scheme[idx].method = NSS_SCHEME_FALLBACK; - scheme[0].method = scheme[1].method = NSS_SCHEME_FALLBACK; c = strchr (c, ':') + 1; c += strspn (c, " \t"); - while (*c && idx < NSS_SCHEME_MAX) + for (uint16_t idx = 0; *c && idx < NSS_SCHEME_MAX; ++idx) { if (NSS_CMP ("windows")) scheme[idx].method = NSS_SCHEME_WINDOWS; @@ -826,7 +826,6 @@ cygheap_pwdgrp::nss_init_line (const char *line) } c += strcspn (c, " \t"); c += strspn (c, " \t"); - ++idx; } } } diff --git a/winsup/doc/ntsec.xml b/winsup/doc/ntsec.xml index a4c253098..08a33bdc6 100644 --- a/winsup/doc/ntsec.xml +++ b/winsup/doc/ntsec.xml @@ -918,6 +918,11 @@ Apart from this restriction, the remainder of the line can have as many spaces and TABs as you like. + +When the same keyword occurs multiple times, the last one wins, as if the +previous ones were ignored. + + The <literal>passwd:</literal> and <literal>group:</literal> settings