Commit Graph

12792 Commits

Author SHA1 Message Date
Takashi Yano via Cygwin-patches 442093214d Cygwin: pty: Keep code page between non-cygwin apps.
- After commit bb428520, there has been the disadvantage:
  4) Code page cannot be changed by chcp.com. Acctually, chcp works
     itself and changes code page of its own pseudo console.  However,
     since pseudo console is recreated for another process, it cannot
     inherit the code page.
  This patch clears this disadvantage.
2021-01-28 11:21:12 +01:00
Takashi Yano via Cygwin-patches 10d083c745 Cygwin: pty: Inherit typeahead data between two input pipes.
- PTY has a problem that the key input, which is typed during windows
  native app is running, disappears when it returns to shell. This is
  beacuse pty has two input pipes, one is for cygwin apps and the other
  one is for native windows apps. The key input during windows native
  program is running is sent to the second input pipe while cygwin
  shell reads input from the first input pipe. This issue had been
  fixed once by commit 29431fcb, however, the new implementation of
  pseudo console support by commit bb428520 could not inherit this
  feature. This patch realize transfering input data between these
  two pipes bidirectionally by utilizing cygwin-console-helper process.
  The helper process is launched prior to starting the non-cygwin app,
  however, exits immediately unlike previous implementation.
2021-01-28 11:21:12 +01:00
Corinna Vinschen 5b941f21b5 Cygwin: Align *utime*() with POSIX/glibc
Followup to previous patch, this time matching definitions in Cygwin

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-01-26 17:27:35 +01:00
Ken Brown b32f6dd40a Cygwin: chown: make sure ctime gets updated when necessary
Following POSIX, ensure that ctime is updated if chown succeeds,
unless the new owner is specified as (uid_t)-1 and the new group is
specified as (gid_t)-1.  Previously, ctime was unchanged whenever the
owner and group were both unchanged.

Aside from POSIX compliance, this fix makes gnulib report that chown
works on Cygwin.  This improves the efficiency of packages like GNU
tar that use gnulib's chown module.  Previously such packages would
use a gnulib replacement for chown on Cygwin.
2021-01-25 21:07:53 -05:00
Ben Wijen f4cac1217e syscalls.cc: Deduplicate remove
The remove code is already in the _remove_r function.
So, just call the _remove_r function.
2021-01-25 19:57:46 +01:00
Takashi Yano via Cygwin-patches 460eb128cb Cygwin: console: Add missing guard regarding attach_mutex.
- The commit a5333345 did not fix the problem enough. This patch
  provides additional guard for the issue.
2021-01-25 19:54:21 +01:00
Ben Wijen cb41c375a6 syscalls.cc: unlink_nt: Try FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE
I think we don't need an extra flag as we can utilize: access & FILE_WRITE_ATTRIBUTES
What do you think?

Ben Wijen (1):
  syscalls.cc: unlink_nt: Try FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE

 winsup/cygwin/ntdll.h     |  3 ++-
 winsup/cygwin/syscalls.cc | 22 +++++++--------
 winsup/cygwin/wincap.cc   | 11 ++++++++
 winsup/cygwin/wincap.h    | 56 ++++++++++++++++++++-------------------
 4 files changed, 53 insertions(+), 39 deletions(-)

--
2.30.0

>From 2d0ff6fec10d03c24d11c747852018b7bc1136ac Mon Sep 17 00:00:00 2001
In-Reply-To: <20210122105201.GD810271@calimero.vinschen.de>
References: <20210122105201.GD810271@calimero.vinschen.de>
From: Ben Wijen <ben@wijen.net>
Date: Tue, 17 Dec 2019 15:15:25 +0100
Subject: [PATCH v3 1/8] syscalls.cc: unlink_nt: Try
 FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE

Implement wincap.has_posix_unlink_semantics_with_ignore_readonly and when set
skip setting/clearing of READONLY attribute and instead use
FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE
2021-01-25 10:50:13 +01:00
Ken Brown a60a4501b7 Cygwin: ptsname_r: always return an error number on failure
Return EBADF on a bad file descriptor.  Previously 0 was returned, in
violation of the requirement in
https://man7.org/linux/man-pages/man3/ptsname_r.3.html that an error
number should be returned on failure.

We are intentionally deviating from Linux, on which ENOTTY is
returned.

Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00245.html
2021-01-22 10:36:43 -05:00
Ken Brown 4aefad2bb8 Cygwin: normalize_posix_path: fix error handling when .. is encountered
When .. is in the source path and the path prefix exists but is not a
directory, return ENOTDIR instead of ENOENT.  This fixes a POSIX
compliance issue for realpath(3):

  https://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html

Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00214.html
2021-01-22 10:31:09 -05:00
Ben Wijen 0c0ff5dc21 Cygwin: Move post-dir unlink check
Move post-dir unlink check from fhandler_disk_file::rmdir to
_unlink_nt_post_dir_check

If a directory is not removed through fhandler_disk_file::rmdir
we can now make sure the post dir check is performed.
2021-01-22 13:35:11 +01:00
Takashi Yano via Cygwin-patches a533334581 Cygwin: console: Fix "Bad file descriptor" error in script command.
- After the commit 72770148, script command exits occasionally with
  the error "Bad file descriptor" if it is started in console on Win7
  and non-cygwin process is executed. This patch fixes the issue.
2021-01-20 10:19:39 +01:00
Takashi Yano via Cygwin-patches 5755870f7c Cygwin: pty: Reduce buffer size in get_console_process_id().
- The buffer used in get_console_process_id(), introduced by commit
  72770148, is too large and ERROR_NOT_ENOUGH_MEMORY occurs in Win7.
  Therefore, the buffer size has been reduced.
2021-01-20 10:19:39 +01:00
Takashi Yano via Cygwin-patches 62e739b51b Cygwin: pty: Lessen the side effect of workaround for rlwarp.
- This patch lessens the side effect of the workaround for rlwrap
  introduced by commit 4e16b033.
2021-01-19 10:56:43 +01:00
Takashi Yano via Cygwin-patches 59ccb3a008 Cygwin: spawn.cc: Fix typo in comment by commit 974e6d76. 2021-01-19 10:56:18 +01:00
Corinna Vinschen 877f0d13f0 Cygwin: rmdir: handle /dev in fhandler_dev::rmdir
The isdev_dev check in rmdir is unclean.  Create a virtual method
fhandler_dev::rmdir to handle this transparently.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-01-19 10:54:35 +01:00
Ken Brown 31ccf40583 Cygwin: document a recent bug fix
This documents commit aec64798, "Cygwin: add flag to indicate reparse
points unknown to WinAPI".
2021-01-18 11:11:45 -05:00
Takashi Yano via Cygwin-patches a776a0ce26 Cygwin: pty: Set input_available_event only for cygwin pipe.
- cat exits immediately in the following senario.
    1) Execute env CYGWIN=disable_pcon script
    2) Execute cmd.exe
    3) Execute cat in cmd.exe.
  This is caused by setting input_available_event for the pipe for
  non-cygwin app. This patch fixes the issue.
2021-01-18 16:26:28 +01:00
Takashi Yano via Cygwin-patches 25ce7a6245 Cygwin: pty: Make master thread functions be static.
- The functions pty_master_thread() and pty_master_fwd_thread()
  should be static (i.e. should not access class member) because
  the instance is deleted if the master is dup()'ed and the first
  master is closed. In this case, because the dup()'ed instance
  still exists, these master threads are also still alive even
  though the instance has been deleted. As a result, accesing
  class members in these functions causes accessi violation.

  Addresses:
  https://cygwin.com/pipermail/cygwin-developers/2021-January/012030.html
2021-01-18 14:18:43 +01:00
Takashi Yano via Cygwin-patches 72770148ad Cygwin: pty: Prevent pty from changing code page of parent console.
- After commit 232fde0e, pty changes console code page when the first
  non-cygwin app is executed. If pty is started in real console device,
  pty changes the code page of root console. This causes very annoying
  result because changing code page changes the font of command prompt
  if console is in legacy mode. This patch avoids this by creating a
  new invisible console for the first pty started in console device.
2021-01-18 14:18:43 +01:00
Ben Wijen 9e88e840c2 cxx.cc: Fix dynamic initialization for static local variables
The old implementation for __cxa_guard_acquire did not return 1,
therefore dynamic initialization was never performed.

If concurrent-safe dynamic initialisation is ever needed, CXX ABI
must be followed when re-implementing __cxa_guard_acquire (et al.)
2021-01-18 12:22:53 +01:00
Ben Wijen cbeb1009a9 syscalls.cc: Use EISDIR
This is the non-POSIX value returned by Linux since 2.1.132.
2021-01-18 12:04:42 +01:00
Ben Wijen 17ede0eae5 syscalls.cc: Fix num_links
NtQueryInformationFile on fh_ro needs FILE_READ_ATTRIBUTES
to succeed.
2021-01-18 12:01:19 +01:00
Corinna Vinschen 226ed24f2b Cygwin: Add Ben Wijen to list of contributors
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-01-18 12:01:19 +01:00
Takashi Yano via Cygwin-patches 85ea2614f5 Cygwin: pty: Make close_pseudoconsole() be a static member function.
- The function close_pseudoconsole() should be static so that it
  can be safely called in spawn.cc even after the fhandler_pty_slave
  instance has been deleted. That is, there is a problem with the
  current code. This patch fixes the issue.
2021-01-18 11:02:46 +01:00
Takashi Yano via Cygwin-patches 974e6d76d8 Cygwin: console: Revise the code to switch xterm mode.
- If application changes the console mode, mode management introduced
  by commit 10d8c278 will be corrupted. For example, stdout of jansi
  v2.0.1 or later is piped to less, jansi resets the xterm mode flag
  ENABLE_VIRTUAL_TERMINA_PROCESSING when jansi is terminated. This
  causes garbled output in less because less needs this flag enabled.
  This patch fixes the issue.
2021-01-18 11:02:46 +01:00
Takashi Yano via Cygwin-patches fa22eea29d Cygwin: pty: Add workaround for rlwrap 0.40 or later.
- The workaround for rlwrap introduced by commit 8199b0cc does not
  take effect for rlwrap 0.40 or later. This patch add a workaround
  for rlwrap 0.40 or later as well.
2021-01-18 11:02:46 +01:00
Ken Brown 9ad86f619c Cygwin: fstatat: call fstat64 instead of fstat
This fixes a bug on 32-bit Cygwin that was introduced in commit
84252946, "Cygwin: fstatat, fchownat: support the AT_EMPTY_PATH flag".

Add a comment explaining why fstat should not be called.

Addresses: https://cygwin.com/pipermail/cygwin/2021-January/247399.html
2021-01-12 14:41:53 -05:00
Brian Inglis 1dd3f69db5 fhandler_proc.cc(format_proc_cpuinfo): report Intel SGX bits
Update to Linux next 5.10 cpuinfo flags for Intel SDM 36.7.1 Software
Guard Extensions, and 38.1.4 SGX Launch Control Configuration.
Launch control restricts what software can run with enclave protections,
which helps protect the system from bad enclaves.
2020-12-17 16:03:50 +01:00
Takashi Yano via Cygwin-patches 4e16b0330a Cygwin: pty: Revise the workaround for rlwrap.
- Previous workaround has a problem that screen is distorted if up
  arrow key is pressed at the first line after running "rlwrap cmd".
  This patch fixes the issue.
2020-12-16 10:31:09 +01:00
Takashi Yano via Cygwin-patches da8cebcded Cygwin: pty: Check response for CSI6n more strictly.
- Previous code to read response for CSI6n allows invalid response
  such as "CSI Pl; Pc H" other than correct response "CSI Pl; Pc R".
  With this patch, the response is checked more strictly.
2020-12-16 10:31:09 +01:00
Corinna Vinschen 532b91d24e Cygwin: Make sure newer apps get uname_x even when loading uname dynamically
if an application built after API version 334 loads uname dynamically,
it actually gets the old uname, rather than the new uname_x.  Fix this by
checking the apps API version in uname and call uname_x instead, if it's
a newer app.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-12-15 13:05:13 +01:00
Takashi Yano via Cygwin-patches 8199b0cc38 Cygwin: pty: Add a workaround for rlwrap.
- If rlwrap is used with non-cygwin apps, it fails to setup pseudo
  console. This patch adds a workaround for this issue.
2020-12-14 11:02:23 +01:00
Takashi Yano via Cygwin-patches 55eff668b8 Cygwin: pty: Revise the code for timeout in term_has_pcon_cap().
- Sometimes timeout period in term_has_pcon_cap() may not be enough
  when the machine slows down for some reason. This patch eases the
  issue. In the new code, effective timeout period is expected to be
  extended as a result due to slowing-down the wait loop as well when
  the machine gets into busy.
2020-12-14 11:02:23 +01:00
Takashi Yano via Cygwin-patches c2c33e4d67 Cygwin: pty: Skip term_has_pcon_cap() if pseudo console is disabled.
- This patch skips unnecessary term_has_pcon_cap() call if pseudo
  console is disabled.
2020-12-14 11:02:23 +01:00
Jeremy Drake via Cygwin-patches 21ec498d7f cygwin: use CREATE_DEFAULT_ERROR_MODE in spawn
This allows native processes to get Windows-default error handling
behavior (such as invoking the registered JIT debugger).
2020-12-10 10:57:40 +01:00
Ken Brown b6624e23e1 Cygwin: dtable::dup_worker: update comment and debug output
The comment and debug output became obsolete in commit 23771fa1f7 when
dup_worker started calling fhandler_base::clone instead of build_fh_pc
and fhandler_base::operator=.
2020-12-07 16:19:57 -05:00
Mark Geisert 9e573ba50f Cygwin: Allow to set SO_PEERCRED zero (v2)
The existing code errors as EINVAL any attempt to set a value for
SO_PEERCRED via setsockopt() on an AF_UNIX/AF_LOCAL socket.  But to
enable the workaround set_no_getpeereid behavior for Python one has
to be able to set SO_PEERCRED to zero.  Ergo, this patch.  Python has
no way to specify a NULL pointer for 'optval'.

This v2 of patch allows the original working (i.e., allow NULL,0 for
optval,optlen to mean turn off SO_PEERCRED) in addition to the new
working described above.  The sense of the 'if' stmt is reversed for
readability.
2020-12-07 16:29:11 +01:00
Mark Geisert 58ac5f985c Cygwin: Launch cygmagic with bash, not sh
On some systems /bin/sh is not /bin/bash and cygmagic has bash-isms in
it.  So even though cygmagic has a /bin/bash shebang, it also needs to be
launched with bash from within Makefile.in.
2020-12-07 10:37:32 +01:00
Anton Lavrentiev via Cygwin-patches 6c9c37d0a9 Fix trace output for getdomainname() 2020-12-07 10:20:45 +01:00
Brian Inglis 31a69bf1d9 winsup/doc/Makefile.in: create man5 dir and install proc.5 2020-12-04 12:40:58 +01:00
Brian Inglis 4157cae5f8 specialnames.xml: add proc(5) Cygwin man page 2020-12-04 12:40:58 +01:00
Corinna Vinschen 604bb7126e
Cygwin: Fix remaining warnings building path testsuite 2020-12-02 15:31:58 +00:00
Jon Turney 0d0f06416a
Cygwin: Fix building of utils testsuite
Avoid referencing undefined max_mount_entry.
2020-12-02 15:31:57 +00:00
Corinna Vinschen aec6479820 Cygwin: add flag to indicate reparse points unknown to WinAPI
https://cygwin.com/pipermail/cygwin/2020-December/246938.html
reports a problem where, when adding a Cygwin default symlink
to $PATH since Cygwin 3.1.5, $PATH handling appears to be broken.

3.1.5 switched to WSL symlinks as Cygwin default symlinks.

A piece of code in path handling skips resolving reparse points
if they are the last component in the path.  Thus a reparse point
in $PATH is not resolved but converted to Windows path syntax
verbatim.

If you do this with a WSL symlink, certain WinAPI functions fail.
The underlying $PATH handling fails to recognize the reparse
point in $PATH and returns with STATUS_IO_REPARSE_TAG_NOT_HANDLED.
As a result, the calling WinAPI function fails, most prominently
so CreateProcess.

Fix this problem by adding a PATH_REP_NOAPI bit to path_types
and a matching method path_conv::is_winapi_reparse_point().

Right now this flag is set for WSL symlinks and Cygwin AF_UNIX
sockets (new type implemented as reparse points).

The aforementioned code skipping repare point path resolution calls
is_winapi_reparse_point() rather than is_known_reparse_point(),
so now path resolution is only skipped for reparse points known
to WinAPI.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-12-02 16:14:41 +01:00
Corinna Vinschen e9bc4cccef Cygwin: path.h: add comments to briefly explain path_types
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-12-02 16:14:41 +01:00
Corinna Vinschen 702bec7bc9 Cygwin: testsuite: libltp: fix warnings showing up with -Wall
This libltp is old as old dirt and still using K&R style.
If it's really to be used again at all, it needs a serious
refresh.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-12-02 14:12:56 +01:00
Corinna Vinschen 80e35a211f Cygwin: /proc/sys FS: don't export NFS and DFS as block devices
Network filesystems are not block devices.  Apparently this code
hasn't been executed anyway, given how network filesystems are
hidden behind \Device\Mup.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-12-01 09:37:10 +01:00
Christian Franke 3434d35a64 Cygwin: Fix access to block devices below /proc/sys.
Use fhandler_dev_floppy instead of fhandler_procsys for such devices.
The read()/write() functions from fhandler_procsys do not ensure
sector aligned transfers and lseek() fails always.

Signed-off-by: Christian Franke <franke@computer.org>
2020-11-30 11:53:00 +01:00
Jon Turney 7fa8405d3f
Cygwin: Have cygmagic not create output if an error occurs
Improve the 'cygmagic' script, so it doesn't create the output file if
an error occurs, even in one of the backtick-enclosed pipelines it runs.
2020-11-25 13:34:18 +00:00
Jon Turney 47e698cc04
Cygwin: Use standard CXXFLAGS when compiling localtime_wrapper.c
This has an separate, explicit compilation rule which omits CXXFLAGS, so
expected flags like '-g -O2' aren't being used.
2020-11-25 13:34:07 +00:00