[PATCH] libc: Replace i386/sys/fenv.h symlink with an #include shim

2020-05-16 Thread David Macek via Cygwin-patches
Same reasoning as fbaa0967.

Signed-off-by: David Macek 
---

Excuse my ignorance, but is this acceptable?  I'm not sure
what actually happens with these files, but it'd be nice to
get rid of the last symlink in the repo.

 newlib/libc/machine/i386/sys/fenv.h | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)
 mode change 12 => 100644 newlib/libc/machine/i386/sys/fenv.h

diff --git a/newlib/libc/machine/i386/sys/fenv.h 
b/newlib/libc/machine/i386/sys/fenv.h
deleted file mode 12
index 218057825e..00
--- a/newlib/libc/machine/i386/sys/fenv.h
+++ /dev/null
@@ -1 +0,0 @@
-../../x86_64/sys/fenv.h
\ No newline at end of file
diff --git a/newlib/libc/machine/i386/sys/fenv.h 
b/newlib/libc/machine/i386/sys/fenv.h
new file mode 100644
index 00..d2c41a6d5a
--- /dev/null
+++ b/newlib/libc/machine/i386/sys/fenv.h
@@ -0,0 +1,5 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include "../../x86_64/sys/fenv.h"
-- 
2.26.2.windows.1



[PATCH v2] cygwin: doc: Add keywords for ACE order issues

2020-05-13 Thread David Macek via Cygwin-patches
Windows Explorer shows a warning with Cygwin-created DACLs, but putting
the text of the warning into Google doesn't lead to the relevant Cygwin
docs.  Let's copy the warning text into the docs in the hopes of helping
confused users.  Most of the credit for the wording belongs to Yaakov
Selkowitz.

Latest inquiry: 

Signed-off-by: David Macek 
---

I thought about the wording and there was one one advantage of the
clumsy variant -- anyone intending to modify the paragraph would
immediately know why the full message is there (in my opinion it
doesn't add much value for the reader).  In any case, here's the
variant with nicer wording (which I also like better).

 winsup/doc/ntsec.xml | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/winsup/doc/ntsec.xml b/winsup/doc/ntsec.xml
index 08a33bdc6c..8644965349 100644
--- a/winsup/doc/ntsec.xml
+++ b/winsup/doc/ntsec.xml
@@ -2159,11 +2159,13 @@ will correctly deal with the ACL regardless of the 
order of allow and
 deny ACEs.  The second rule is not modified to get the ACEs in the
 preferred order.
 
-Unfortunately the security tab in the file properties dialog of
-the Windows Explorer insists to rearrange the order of the ACEs to
-canonical order before you can read them. Thank God, the sort order
-remains unchanged if one presses the Cancel button.  But don't even
-think of pressing OK...
+Unfortunately, the security tab in the file properties dialog of
+the Windows Explorer will pop up a warning stating "The permissions on
+... are incorrectly ordered, which may cause some entries to be
+ineffective."  Pressing the Cancel button of the properties dialog
+fortunately leaves the sort order unchanged, but pressing OK will cause
+Explorer to canonicalize the order of the ACEs, thereby invalidating
+POSIX compatibility.
 
 Canonical ACLs are unable to reflect each possible combination
 of POSIX permissions. Example:
-- 
2.26.2.windows.1



Re: [PATCH] cygwin: doc: Add keywords for ACE order issues

2020-05-12 Thread David Macek via Cygwin-patches
> +warning says "The permissions on ... are incorrectly orderer, which may

Oof. Please fix "orderer" to "ordered" if accepted.

-- 
David Macek


[PATCH] cygwin: doc: Add keywords for ACE order issues

2020-05-12 Thread David Macek via Cygwin-patches
Windows Explorer shows a warning with Cygwin-created DACLs, but putting
the text of the warning into Google doesn't lead to the relevant Cygwin
docs.  Let's copy the warning text into the docs in the hopes of helping
confused users.

Latest inquiry: 

Signed-off-by: David Macek 
---
 winsup/doc/ntsec.xml | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/winsup/doc/ntsec.xml b/winsup/doc/ntsec.xml
index 08a33bdc6c..b94cdd9a97 100644
--- a/winsup/doc/ntsec.xml
+++ b/winsup/doc/ntsec.xml
@@ -2163,7 +2163,10 @@ preferred order.
 the Windows Explorer insists to rearrange the order of the ACEs to
 canonical order before you can read them. Thank God, the sort order
 remains unchanged if one presses the Cancel button.  But don't even
-think of pressing OK...
+think of pressing OK...  For the sake
+of people searching for this explanation, let's note that the Explorer
+warning says "The permissions on ... are incorrectly orderer, which may
+cause some entries to be ineffective."
 
 Canonical ACLs are unable to reflect each possible combination
 of POSIX permissions. Example:
-- 
2.26.2.windows.1



[PATCH 1/3 v3] Cygwin: accounts: Unify nsswitch.conf db_* defaults

2020-04-21 Thread David Macek via Cygwin-patches
Signed-off-by: David Macek 
---
 winsup/cygwin/uinfo.cc | 11 +--
 winsup/doc/ntsec.xml   | 21 ++---
 2 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index 57d90189d3..2d5fc488bb 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -626,15 +626,12 @@ cygheap_pwdgrp::init ()
   grp_cache.cygserver.init_grp ();
   grp_cache.file.init_grp ();
   grp_cache.win.init_grp ();
-  /* Default settings:
+  /* Default settings (excluding fallbacks):
 
  passwd: files db
  group:  files db
  db_prefix: auto   DISABLED
  db_separator: +   DISABLED
- db_home: cygwin desc
- db_shell: cygwin desc
- db_gecos: cygwin desc
  db_enum: cache builtin
   */
   pwd_src = (NSS_SRC_FILES | NSS_SRC_DB);
@@ -831,12 +828,6 @@ cygheap_pwdgrp::nss_init_line (const char *line)
  c += strspn (c, " \t");
  ++idx;
}
- /* If nothing has been set, revert to default. */
- if (scheme[0].method == NSS_SCHEME_FALLBACK)
-   {
- scheme[0].method = NSS_SCHEME_CYGWIN;
- scheme[1].method = NSS_SCHEME_DESC;
-   }
}
}
   break;
diff --git a/winsup/doc/ntsec.xml b/winsup/doc/ntsec.xml
index 5287845686..a4c253098d 100644
--- a/winsup/doc/ntsec.xml
+++ b/winsup/doc/ntsec.xml
@@ -1507,19 +1507,16 @@ of each schema when used with 
db_home:
 
 
 
-As has been briefly mentioned before, the default setting for
-db_home: is
+db_home: defines no default schemata.  If this setting is 
not
+present in /etc/nsswitch.conf, the aforementioned fallback
+takes over, which is equivalent to a /etc/nsswitch.conf
+settting of
 
 
 
   db_home: /home/%U
 
 
-
-So by default, Cygwin just sets the home dir to
-/home/$USERNAME.
-
-
 
 
 
@@ -1590,8 +1587,10 @@ when used with db_shell:
 
 
 
-As for db_home:, the default setting for
-db_shell: is pretty much a constant
+db_shell: defines no default schemata.  If this setting is
+not present in /etc/nsswitch.conf, the aforementioned
+fallback takes over, which is equivalent to a
+/etc/nsswitch.conf settting of
 
 
 
@@ -1664,13 +1663,13 @@ The following list describes the meaning of each schema 
when used with
   
 Fallback
 If none of the schemes given for db_gecos:
- define a non-empty pathname, nothing is added to
+ define a non-empty string, nothing is added to
  pw_gecos.
   
 
 
 
-The default setting for db_gecos: is the empty string.
+db_gecos: defines no default schemata.
 
 
 
-- 
2.26.1.windows.1



[PATCH 1/3 v2] Cygwin: accounts: Unify nsswitch.conf db_* defaults

2020-04-20 Thread David Macek via Cygwin-patches
Signed-off-by: David Macek 
---
 winsup/cygwin/uinfo.cc | 11 +--
 winsup/doc/ntsec.xml   | 27 +++
 2 files changed, 8 insertions(+), 30 deletions(-)

diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index 57d90189d3..2d5fc488bb 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -626,15 +626,12 @@ cygheap_pwdgrp::init ()
   grp_cache.cygserver.init_grp ();
   grp_cache.file.init_grp ();
   grp_cache.win.init_grp ();
-  /* Default settings:
+  /* Default settings (excluding fallbacks):
 
  passwd: files db
  group:  files db
  db_prefix: auto   DISABLED
  db_separator: +   DISABLED
- db_home: cygwin desc
- db_shell: cygwin desc
- db_gecos: cygwin desc
  db_enum: cache builtin
   */
   pwd_src = (NSS_SRC_FILES | NSS_SRC_DB);
@@ -831,12 +828,6 @@ cygheap_pwdgrp::nss_init_line (const char *line)
  c += strspn (c, " \t");
  ++idx;
}
- /* If nothing has been set, revert to default. */
- if (scheme[0].method == NSS_SCHEME_FALLBACK)
-   {
- scheme[0].method = NSS_SCHEME_CYGWIN;
- scheme[1].method = NSS_SCHEME_DESC;
-   }
}
}
   break;
diff --git a/winsup/doc/ntsec.xml b/winsup/doc/ntsec.xml
index 5287845686..032bebe4dc 100644
--- a/winsup/doc/ntsec.xml
+++ b/winsup/doc/ntsec.xml
@@ -874,9 +874,6 @@ set up to all default values:
   db_prefix:auto
   db_separator: + -->
   db_enum:  cache builtin
-  db_home:  /home/%U
-  db_shell: /bin/bash
-  db_gecos: empty
 
 
 The 
/etc/nsswitch.conf syntax
@@ -1508,15 +1505,8 @@ of each schema when used with db_home:
 
 
 As has been briefly mentioned before, the default setting for
-db_home: is
-
-
-
-  db_home: /home/%U
-
-
-
-So by default, Cygwin just sets the home dir to
+db_home: defines no schemata, which means only the fallback
+option is used, so by default, Cygwin just sets the home dir to
 /home/$USERNAME.
 
 
@@ -1591,14 +1581,11 @@ when used with db_shell:
 
 
 As for db_home:, the default setting for
-db_shell: is pretty much a constant
+db_shell: defines no schemata, which means only the fallback
+option is used, so by default, Cygwin just sets the home dir to
+/bin/bash.
 
 
-
-  db_shell: /bin/bash
-
-
-
 
 
 
@@ -1664,13 +1651,13 @@ The following list describes the meaning of each schema 
when used with
   
 Fallback
 If none of the schemes given for db_gecos:
- define a non-empty pathname, nothing is added to
+ define a non-empty string, nothing is added to
  pw_gecos.
   
 
 
 
-The default setting for db_gecos: is the empty string.
+The default setting for db_gecos: defines no schemata.
 
 
 
-- 
2.26.1.windows.1



[PATCH 2/3 v2] Cygwin: accounts: Don't keep old schemes when parsing nsswitch.conf

2020-04-20 Thread David Macek via 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 
---
 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.
 
 
+
+When the same keyword occurs multiple times, the last one wins, as if the
+previous ones were ignored.
+
+
 
 
 The passwd: and 
group: settings
-- 
2.26.1.windows.1



[PATCH 3/3] Cygwin: accounts: Report unrecognized db_* nsswitch.conf keywords

2020-04-20 Thread David Macek via Cygwin-patches
Signed-off-by: David Macek 
---
 winsup/cygwin/uinfo.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index b733a6ee87..e105248c20 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -828,6 +828,8 @@ cygheap_pwdgrp::nss_init_line (const char *line)
  c += strspn (c, " \t");
}
}
+ else
+ debug_printf ("Invalid nsswitch.conf content: %s", line);
}
   break;
 case '\0':
-- 
2.26.1.windows.1



License declaration

2020-04-20 Thread David Macek via Cygwin-patches
Patches to the Cygwin sources sent by me are licensed under the
2-clause BSD license.  This applies to all past patches as well.

I'll try to add a Signed-off-by to each patch.

-- 
David Macek


[PATCH 2/2] cygheap_pwdgrp: Don't keep old schemes when parsing nsswitch.conf

2020-04-17 Thread David Macek via 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.
---
 winsup/cygwin/uinfo.cc | 5 +++--
 winsup/doc/ntsec.xml   | 5 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index 227faa4248..a4fcc33d8d 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -793,9 +793,10 @@ 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;
+ uint16_t idx = 0;
  c = strchr (c, ':') + 1;
  c += strspn (c, " \t");
  while (*c && idx < NSS_SCHEME_MAX)
diff --git a/winsup/doc/ntsec.xml b/winsup/doc/ntsec.xml
index 5287845686..153ff1eac8 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 passwd: and 
group: settings
-- 
2.26.1.windows.1



[PATCH 1/2] cygheap_pwdgrp: Don't invent undocumented defaults in nsswitch.conf

2020-04-17 Thread David Macek via Cygwin-patches
---
 winsup/cygwin/uinfo.cc | 6 --
 1 file changed, 6 deletions(-)

diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index 57d90189d3..227faa4248 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -831,12 +831,6 @@ cygheap_pwdgrp::nss_init_line (const char *line)
  c += strspn (c, " \t");
  ++idx;
}
- /* If nothing has been set, revert to default. */
- if (scheme[0].method == NSS_SCHEME_FALLBACK)
-   {
- scheme[0].method = NSS_SCHEME_CYGWIN;
- scheme[1].method = NSS_SCHEME_DESC;
-   }
}
}
   break;
-- 
2.26.1.windows.1



[PATCH] cygheap_pwdgrp: Handle invalid db_* entries correctly

2020-04-16 Thread David Macek via Cygwin-patches
If the first scheme in db_* was invalid, the code would think there
were no schemes specified and replace the second scheme with
NSS_SCHEME_DESC.

Signed-off-by: David Macek 
---
 winsup/cygwin/uinfo.cc | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index bfcce00da0..be3c4855cc 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -823,7 +823,10 @@ cygheap_pwdgrp::nss_init_line (const char *line)
  c, e - c);
}
  else
-   debug_printf ("Invalid nsswitch.conf content: %s", line);
+   {
+ debug_printf ("Invalid nsswitch.conf content: %s", line);
+ --idx;
+   }
  c += strcspn (c, " \t");
  c += strspn (c, " \t");
  ++idx;
-- 
2.26.1.windows.1