Commit Graph

21772 Commits

Author SHA1 Message Date
Corinna Vinschen 7db1c6fc4e Cygwin: //server: revert to using WNet and support NFS shares
Continue using WSD for enumerating //, but switch back to
WNet for enumerating shares.

Add trying to enumerate NFS shares for machine names given as FQDN.

Only downcase server names, keep case of shares intact.
Move downcasing into dir_cache class.

Add a comment to explain an extrem weirdness in Windows.

Fixes: 205190a80b ("Cygwin: // and //server: switch to Network Discovery")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-23 22:32:42 +01:00
Corinna Vinschen 8d2c1b4ce6 Cygwin: //server: check existence of server with getaddrinfo
Checking server existence by trying to enumerate its shares
may result in 2 minutes delay until some internal timeout is hit.

In the light that every network is an IP network anyway these
days, let's try with a simple getaddrinfo() call.  This is usually
back in 3 secs even if the server doesn't exist, and it's usually
back in 8 secs if the DNS server can't be connected.  This is the
fastest method I found to check server existence yet.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-22 15:34:29 +01:00
Corinna Vinschen 290843bbda Cygwin: utils: refresh tzmap.h
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-21 21:45:26 +01:00
Corinna Vinschen 2c67eeb233 Cygwin: tzmap-from-unicode.org: drop "E. Europe Standard Time" default
E. Europe Standard Time is available in the unicode.org windowsZones.xml
file, so we can drop the default handling.

Fix a few comments.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-21 21:45:26 +01:00
Corinna Vinschen ace936b707 Cygwin: tzset(1): use GetDynamicTimeZoneInformation
Use official GetDynamicTimeZoneInformation() function instead of
scanning the registry for the timezone keyname.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-21 21:44:57 +01:00
Corinna Vinschen 4c4e6d67d4 Cygwin: fix tzmap-from-unicode.org
The previous change introduced a missing end of comment

Fixes: 60ea9c1c4b ("Cygwin: tzmap-from-unicode.org: drop support for Vista/2008")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-21 21:22:49 +01:00
Corinna Vinschen 8e12860944 Cygwin: utils: refresh tzmap.h
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-20 23:00:02 +01:00
Corinna Vinschen 60ea9c1c4b Cygwin: tzmap-from-unicode.org: drop support for Vista/2008
Commit b794f2c603 ("Cygwin: drop support for systems not supporting
RFC 4646 locales") erroneously changed tzmap.h manually.  Change
the script accordingly.

Fixes: b794f2c603 ("Cygwin: drop support for systems not supporting RFC 4646 locales")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-20 22:59:37 +01:00
Corinna Vinschen b9ed33dec0 Cygwin: readdir: drop support for NT4/Win2K shares and Samba < 3.0.22
These systems are at least 18 years old and so buggy that they are
hopefully not used anymore.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-20 17:45:41 +01:00
Corinna Vinschen 8bd6ba8f16 Cygwin: /proc: fix mem leak in opendir in error case
Fixes: 1f08558f14 ("* fhandler.h (fhandler_proc::opendir): Declare.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-20 14:48:55 +01:00
Corinna Vinschen 205190a80b Cygwin: // and //server: switch to Network Discovery
SMBv1 is ultimately deprecated since Novemer 2023.  It's also
not installed by default on latest Windows versions.

Drop using the WNet (SMBv1) API in favor of using Network Discovery.
Given there's no documented Win32 API for that, the code now uses
the Shell API.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-20 14:46:49 +01:00
Corinna Vinschen 80f722e97c Cygwin: opendir(3): move ENOTDIR check into main function
So far the check for a directory is in the fhandler::opendir
methods. Given that path_conv::check sets FILE_ATTRIBUTE_DIRECTORY
on virtual files either, we can move the check up into the
opendir(3) function. This avoids calling exists() twice when
calling opendir(3).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-20 12:34:51 +01:00
Corinna Vinschen 1719169604 Cygwin: (mostly) drop NT4 and Samba < 3.0 support
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-20 12:31:50 +01:00
Corinna Vinschen 14970f2645 Cygwin: dirent.h: fix a comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-19 23:21:35 +01:00
Corinna Vinschen d06113bf8b Cygwin: readdir(3): stop support for pre-Cygwin 1.5.0 apps
We're filling dirent::__d_internal1 with the inode number to
support apps built under Cygwin 1.3 and earlier.  This doesn't
make sense anymore.  Drop this to free up __d_internal1 for
other TBD use.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-19 16:22:40 +01:00
Brian Inglis bfe2790e7b winsup/cygwin/fhandler/proc.cc: format_proc_cpuinfo() Linux 6.8 cpuinfo flags
add Linux 6.8 cpuinfo flags:
Intel 0x00000007:1 eax:17 fred		Flexible Return and Event Delivery;
AMD   0x8000001f   eax:4  sev_snp	SEV secure nested paging;
document unused and some unprinted bits that could look like omissions;
fix typos and misalignments;

Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
2024-03-18 16:33:56 +01:00
Corinna Vinschen 89afbb8d8a Revert "Cygwin: glob: perform ignore_case_with_glob on input"
This reverts commit a51147467e.

Dumb thinko on my part.  What was supposed to be an optimization
actually broke caseinsensitive globbing in that the entire input
of globbed expressions were downcased.

Drop the unused CCHAR() macro nevertheless.

Fixes: a51147467e ("Cygwin: glob: perform ignore_case_with_glob on input")
Reported-by: Michael Goldshteyn <mgold10000@gmail.com>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-18 11:10:13 +01:00
Joel Sherrill 176b19fbe5 libc/include/sys/select.h: Use elif not elifdef
The cpp directive "elifdef" is only available in very recent GCC versions.
This should be able to compile on older toolchains in C99 mode.`
2024-03-13 09:29:36 -05:00
Chris Johns 8d38c37ed9 RTEMS: Increase FS_SETSIZE to 256 bits 2024-03-13 08:59:24 -05:00
Takashi Yano fc691d0246 Cygwin: pipe: Make sure to set read pipe non-blocking for cygwin apps.
If pipe reader is a non-cygwin app first, and cygwin process reads
the same pipe after that, the pipe has been set to bclocking mode
for the cygwin app. However, the commit 9e4d308cd5 assumes the
pipe for cygwin process always is non-blocking mode. With this patch,
the pipe mode is reset to non-blocking when cygwin app is started.

Addresses: https://cygwin.com/pipermail/cygwin/2024-March/255644.html
Fixes: 9e4d308cd5 ("Cygwin: pipe: Adopt FILE_SYNCHRONOUS_IO_NONALERT flag for read pipe.")
Reported-by: wh <wh9692@protonmail.com>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-03-12 10:17:40 +09:00
Corinna Vinschen 3af5d2bbdd Cygwin: 3.6.0: add release entries for pinned/unpinned flag handling
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-11 12:53:50 +01:00
Corinna Vinschen 775069553b Cygwin: add 3.5.2 release entries for latest commits
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-11 12:53:24 +01:00
Corinna Vinschen 5f586adc63 Cygwin: getgrent: don't skip SAM-only builtin-accounts
Since commit 15e82eef3a ("Cygwin: getgrent: fix local SAM enumeration
on domain member machines") we skip enumerating local BUILTIN accounts
if we also enumerate AD.  However, there are two local accounts which
are only available in local SAM, not in AD.  Don't skip enumerating
those.

Fixes: 15e82eef3a ("Cygwin: getgrent: fix local SAM enumeration on domain member machines")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-11 12:46:50 +01:00
Torbjörn SVENSSON 3b97a5ec67 libc/stdio: Remove wchar_t functions from NEWLIB_NANO_FORMATTED_IO
Regression tested in basepoints/gcc-14-9032-g945cb8490cb with arm-none-eabi.

Example failure without this change:
$ arm-none-eabi-g++ .../pr100611.C -std=c++20 --specs=nosys.specs -o /dev/null --specs=nano.specs
.../ld: .../libc_nano.a(libc_a-svfwprintf.o): in function `_svfwprintf_r':
(.text._svfwprintf_r+0xd8): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x834): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x85c): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x8a8): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x8dc): undefined reference to `__ssputws_r'
.../ld: .../libc_nano.a(libc_a-svfwprintf.o):(.text._svfwprintf_r+0x900): more undefined references to `__ssputws_r' follow
collect2: error: ld returned 1 exit status

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Co-authored-by: Yvan ROUX <yvan.roux@foss.st.com>
2024-03-11 11:29:55 +01:00
Corinna Vinschen 06aa5a7516 Cygwin: FS_IOC_[GS]ETFLAGS: handle pinned and unpinned attributes
Add FS_PINNED_FL and FS_UNPINNED_FL flags and handle them with
mode bits 'p' and 'u' in chattr(1) and lsattr(1).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-08 21:54:58 +01:00
Corinna Vinschen 2100c6ef0d Cygwin: get/set security descriptors using FILE_OPEN_NO_RECALL
Add FILE_OPEN_NO_RECALL to NtOpenFile calls trying to fetch
or write file security descriptors so as not to recall them
from offline storage inadvertently.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-08 21:30:57 +01:00
Corinna Vinschen f6b56abec1 Cygwin: try to avoid recalling offline files
Chances are high that Cygwin recalls offline files from remote
storage, even if the file is only accessed during stat(2) or
readdir(3).

To avoid this
- make sure Cygwin is placeholder-aware,
- open files in path_conv handling, as well as in stat(2)/readdir(3)
  scenarios with FILE_OPEN_NO_RECALL, and
- during symlink checking or testing for executablility, don't even
  try to open the file if one of the OFFLINE attributes is set.

Reported-by: Marcin Wisnicki <mwisnicki@gmail.com>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-08 20:57:06 +01:00
Corinna Vinschen f2010ed784 Cygwin: move EXPORT_ALIAS expressions to end of source
This isn't strictly required, but it avoids confusion in ctags.
Ctags fails to record the next function or method following the
EXPORT_ALIAS expression.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-07 21:50:07 +01:00
Takashi Yano c2310061c6 Cygwin: pipe: Simplify chhecking procedure of query_hdl.
This patch eliminates verbose NtQueryObject() calls in the procedure
to get query_hdl by storing pipe name into fhandler_base::pc when
the pipe is created.  fhandler_pipe::temporary_query_hdl() uses the
storedpipe name rather than the name retrieved by NtQueryObject().

Suggested-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-03-06 03:44:37 +09:00
Takashi Yano 46bb999a89 Cygwin: pipe: Give up to use query_hdl for non-cygwin apps.
Non-cygwin app may call ReadFile() for empty pipe, which makes
NtQueryObject() for ObjectNameInformation block in fhandler_pipe::
get_query_hdl_per_process. Therefore, do not to try to get query_hdl
for non-cygwin apps.

Addresses: https://github.com/msys2/msys2-runtime/issues/202

Fixes: b531d6b06e ("Cygwin: pipe: Introduce temporary query_hdl.")
Reported-by: Alisa Sireneva, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-03-05 22:03:01 +09:00
Takashi Yano b160b690b6 Cygwin: console: Fix a race issue between close() and open().
The open() call for console sometimes fails if the console owner
process is closing the console by close() at the same time. This
is due to mismatch state of con.owner variable and attaching state
to the console. With this patch, checking con.owner and attaching
to con.owner sequence in open(), and resetting con.owner and freeing
console sequence in close() are guarded by output_mutex to avoid
such a race issue.
Addresses: https://cygwin.com/pipermail/cygwin/2024-March/255575.html

Fixes: 3721a756b0 ("Cygwin: console: Make the console accessible from other terminals.")
Reported-by: Kate Deplaix <kit-ty-kate@outlook.com>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-03-04 11:58:09 +09:00
Corinna Vinschen abb532a87f Cygwin: cygheap: compute bucket instead of looping over it
Start at index 0 and use 32 bytes as minimal allocation size.
Reduce NBUCKETS, we don't have such big objects on the
cygheap anyway.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-01 22:35:22 +01:00
Corinna Vinschen 5d3e79ec6b Cygwin: cygheap: use SRWLOCK for cygheap locking
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-01 22:31:33 +01:00
Corinna Vinschen e2ea60728c Cygwin: posix_getdents: do not clear attached DIR structure at fork(2)
The upcoming POSIX issue 8 will require that posix_getdents after
fork() will pick up at the right spot, independently of being
called in the parent or in the child process.  Remove the expression
clearing out the attached DIR after fork.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-01 15:32:39 +01:00
Corinna Vinschen 6d93691547 Cygwin: lseek: improve seeking posix_getdents descriptors
Transfer code lseeking on posix_getdents() directory descriptor
into its own static function and rework it so SEEK_END, SEEK_DATA
and SEEK_HOLE work here as expected, too.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-01 15:32:39 +01:00
Takashi Yano c77a5689f7 Cygwin: console: Do not unmap shared console memory belonging to ctty.
In the condition that console setup for CTTY and close run at the
sametime, accessing shared console memory which is already unmapped
may occur. With this patch, to avoid this race issue, shared console
memory which belongs to contorolling terminal (CTTY) is kept mapped
as before.
Addresses: https://cygwin.com/pipermail/cygwin/2024-February/255561.html

Fixes: 3721a756b0 ("Cygwin: console: Make the console accessible from other terminals.")
Reported-by: Kate Deplaix <kit-ty-kate@outlook.com>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-03-01 20:00:11 +09:00
Christian Franke ee97ae1d5f Cygwin: set ENOSHARE and ECASECLASH _sys_errlist[] entries to empty
These errno values are no longer used by Cygwin.  Change the entries
to empty strings instead of NULL to avoid crashes in existing
binaries directly accessing the table.  Enhance strerror_worker()
such that empty strings also result in "Unknown error ..." messages.
Also add a static_assert check for the _sys_errlist[] size.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-28 09:59:07 +01:00
Christian Franke 6f996d7751 Cygwin: add compile warning if ENOSHARE or ECASECLASH is used
These errno values are no longer used by Cygwin.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-28 09:59:07 +01:00
Corinna Vinschen 7a89f7261d Cygwin: add release text for getgrent local SAM enumeration patch
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-26 15:56:10 +01:00
Christian Franke c2f6c04155 Cygwin: errmap[]: update comments using current winerror.h
Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-26 15:56:10 +01:00
Christian Franke 2b7cc8972f Cygwin: errmap[]: add error numbers to /* ERROR_... */ comments
Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-26 15:56:10 +01:00
Christian Franke 4f843719d3 Cygwin: errmap[]: reduce value size from 32 to 8 bits
Overflow would be detected at compile time.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-26 15:56:10 +01:00
Christian Franke b55eed943b Cygwin: introduce constexpr errmap_size and errmap[] consistency checks
Use constexpr instead of const for errmap[] to allow static_assert
checks on its values.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-26 15:56:10 +01:00
Christian Franke 4af5f9d51e Cygwin: Map ERROR_NO_SUCH_DEVICE and ERROR_MEDIA_CHANGED to ENODEV
If a removable (USB) device is disconnected after opening its raw
device, R/W attempts fail with ERROR_NO_SUCH_DEVICE(433).  If the
raw device of a partition is used, ERROR_MEDIA_CHANGED(1110) is
returned instead.  Both are mapped to ENODEV(19) because <errno.h>
does not offer a value which better matches ERROR_MEDIA_CHANGED.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-24 13:12:14 +01:00
Corinna Vinschen 388da83dce Cygwin: add newgrp release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-24 13:12:14 +01:00
Corinna Vinschen 0e3bb302de Cygwin: newgrp: only allow group from supplementary group list
Windows only allows to set the primary group to a group already
present in the TOKEN_GROUP list.  Cygwin OTOH fakes success at
setgid() time, to allow a subsequent call to setuid() to do
the actual account switching.  To have a sane behaviour in the
command line tool, check group membership and disallow to switch
to groups other than those already present in the user token.

Fixes: 8bd56ec873 ("Cygwin: newgrp: first full version")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-24 13:08:34 +01:00
Corinna Vinschen 808a95d24d Cygwin: newgrp: fix invalid usage of argv
Fix an error message accessing argv[1] even after it has been
potentially moved.  Print group name from group DB instead.

Fixes: 8bd56ec873 ("Cygwin: newgrp: first full version")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-24 13:08:33 +01:00
Sebastian Huber 3e16e86a56 RTEMS: Define ssize_t for <dirent.h>
This fixes the following build issue:

newlib/libc/include/dirent.h:84:1: error: unknown type name 'ssize_t'; did you mean '_ssize_t'?
   84 | ssize_t posix_getdents(int, void *, size_t, int);
      | ^~~~~~~
      | _ssize_t
2024-02-24 11:31:43 +01:00
Corinna Vinschen a0d7758359 Cygwin: strptime: add release note
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-21 20:00:29 +01:00
Corinna Vinschen 585855eef8 Cygwin: strptime: fix am/pm handling
The %p format specifier is handled immediately.  It requires
that tm_hour is already set.  This falls flat in case the am/pm
marker preceeds the time specification.  Locales with am/pm
marker preceeding time spec by default exist (e. g. ko_KR).

Also, the code expects that tm_hour might be set to an invalid
value because the %p specifier is used in conjunction with %H.
But this usage is invalid in itself and now catched as error
condition after commit 343a2a5581 ("Cygwin: strptime: make
sure to fail on invalid input digits").

Change the %H/%I/%p handling according to GLibC, i. e.

- fix tm_hour for pm only if the time value has been specified
  as 12 hour time %I, and

- perform the fixup only after the entire input has been scanned.
  This decouples the fixup from the %p position relativ to %I.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-21 19:54:20 +01:00