* [PATCH 2/3 v2] Cygwin: accounts: Don't keep old schemes when parsing nsswitch.conf
@ 2020-04-20 17:21 David Macek
0 siblings, 0 replies; only message in thread
From: David Macek @ 2020-04-20 17:21 UTC (permalink / raw)
To: cygwin-patches
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>
---
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 2d5fc488bb..b733a6ee87 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 032bebe4dc..b5996567f8 100644
--- a/winsup/doc/ntsec.xml
+++ b/winsup/doc/ntsec.xml
@@ -915,6 +915,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>
--
2.26.1.windows.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-04-20 17:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20 17:21 [PATCH 2/3 v2] Cygwin: accounts: Don't keep old schemes when parsing nsswitch.conf David Macek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).