Commit Graph

21656 Commits

Author SHA1 Message Date
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
Corinna Vinschen 343a2a5581 Cygwin: strptime: make sure to fail on invalid input digits
conv_num returns NULL if the input is invalid, e. g., the
numbers are out of range.  However, the code fails to test
this in a lot of places.

Rather than adding checks all over the place, rename conv_num
to __conv_num and create a wrapper macro conv_num to perform
the task of error checking.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-21 19:39:37 +01:00
Alexey Lapshin acf176104f strptime: fix am/pm converting to 24-hour system
Fix the issue of parsing 08:00AM, which currently gives a 20:00 representation.
2024-02-21 15:52:14 +01:00
Corinna Vinschen c90b20192d Cygwin: getgrent/getpwent: avoid local enumeration on DCs
...if we're supposed to enumerate the AD accounts anyway.  This
avoids some useless duplication.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-20 23:55:51 +01:00
Corinna Vinschen 15e82eef3a Cygwin: getgrent: fix local SAM enumeration on domain member machines
Don't skip output of local SAM groups on domain member machines.
They can have valid, user-defined groups in their SAM.  Just
skip builtin groups if we're enumerating AD as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-20 23:51:33 +01:00
Corinna Vinschen 5cc6996987 Cygwin: passwd/group: drop Capability SIDs
Capability SIDs (S-1-15-3-...) have been introduced with
Windows 10 1909.  They don't resolve with LookupAccountSid.
We don't need them and they don't map gracefully into out
POSIX account namespace.  Also, add code to make sure to
filter them out *iff* they become resolvable at one point.

While at it, slightly reorder code for non-resolving SIDs
by authority values.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-20 17:25:23 +01:00
Corinna Vinschen 70653fd8f1 Cygwin: gettimeofday: allow tv NULL pointer
Add a missing check for the struct timeval pointer being NULL.

Reported-by: 109224573 <109224573@qq.com>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-20 12:30:34 +01:00
Corinna Vinschen a7bf7c7dd5 Cygwin: timespec_get: implement C11 function
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-16 20:44:31 +01:00
Takashi Yano f9542a2e8e Cygwin: pty: Re-fix the last bug regarding nat-pipe.
Fixes: f907b5f405 ("Cygwin: pty: Fix failure to revert from nat-pipe in disable_pcon.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-16 18:18:26 +09:00
Takashi Yano f907b5f405 Cygwin: pty: Fix failure to revert from nat-pipe in disable_pcon.
Fixes: a903878948 ("Cygwin: pty: Additional fix for transferring input at exit.");
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-16 17:15:29 +09:00
Takashi Yano f3ba4db2e2 Cygwin: console: Fix a bug that 64th console cannot be handled.
Fixes: 930e553da8 ("Cygwin: console: Unify EnumWindows() callback functions.");
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-16 04:06:01 +09:00
Takashi Yano 4dd3dc876c Cygwin: console: Fix a bug that cannot handle consoles more than 32.
Fixes: 3721a756b0 ("Cygwin: console: Make the console accessible from other terminals.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-16 02:37:46 +09:00
Takashi Yano 930e553da8 Cygwin: console: Unify EnumWindows() callback functions.
Previously, three similar callback fuctions were used in console
code. This patch unifies these functions to ease maintenance cost.

Fixes: 8aad3a7ede ("Cygwin: console: Fix a problem that minor ID is incorrect in ConEmu.")
Suggested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-14 23:18:23 +09:00
Takashi Yano 054f4801e6 Cygwin: pty: Make GNU screen and tmux work in ConEmu cygwin-connector.
Fixes: 3721a756b0 ("Cygwin: console: Make the console accessible from other terminals.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-14 23:18:04 +09:00
Corinna Vinschen 2a2a6486a0 Cygwin: accommodate gcc -Og option
All three warnings produced with -Og are false positives.
But given we're using -Werror unconditionally it's better
to be safe than sorry.

Reported-by: Kevin Ushey <kevinushey@gmail.com>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-14 14:00:34 +01:00
Corinna Vinschen 4e77fa9b8b Cygwin: find_fast_cwd: don't run assembler checking code on ARM64
https://cygwin.com/pipermail/cygwin/2024-February/255397.html
reports a crash on ARM64 probably related to checking x86_64
code on the x86_64 emulator on AArch64.

At least for testing, pull the code checking the host HW
up to be called before trying to evaluate assembler code.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-13 16:48:15 +01:00
Takashi Yano 8aad3a7ede Cygwin: console: Fix a problem that minor ID is incorrect in ConEmu.
Previously, minor device number of console was not assigned correctly
in ConEmu environment. This is because console window of ConEmu is
not enumerated by EnumWindows(). This patch fixes the issue.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-13 23:27:44 +09:00