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 <david.macek.0@gmail.com>
This commit is contained in:
David Macek via Cygwin-patches 2020-04-20 19:21:00 +02:00 committed by Corinna Vinschen
parent d5add9ee5e
commit 969c8392fe
2 changed files with 8 additions and 4 deletions

View File

@ -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;
}
}
}

View File

@ -918,6 +918,11 @@ Apart from this restriction, the remainder of the line can have as
many spaces and TABs as you like.
</para>
<para>
When the same keyword occurs multiple times, the last one wins, as if the
previous ones were ignored.
</para>
</sect4>
<sect4 id="ntsec-mapping-nsswitch-pwdgrp"><title id="ntsec-mapping-nsswitch-pwdgrp.title">The <literal>passwd:</literal> and <literal>group:</literal> settings</title>