Commit Graph

9517 Commits

Author SHA1 Message Date
Corinna Vinschen fcec4830ab Cygwin: sysconf: don't set errno for unsupported options
We return -1 with errno set to EINVAL for sysconf options for
values required by POSIX, but not implemented on Cygwin.
This is incorrect.  Return -1, but don't set errno for these options.
Drop the "nsup" enum to indicate unsupported values, it's not
required anymore.

Fixes: 59e3b6ca7d (CVS import)
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-02 22:02:59 +01:00
Corinna Vinschen cf00bba99a Cygwin: sysconf: belatedly add correct return value for _SC_DELAYTIMER_MAX
When adding the timer_getoverrun function, DELAYTIMER_MAX was added
to limits.h, but the return value of sysconf(_SC_DELAYTIMER_MAX) wasn't
changed accordingly.  Fix that now.

Fixes: 9e295a8d19 ("Cygwin: posix timers: implement timer_getoverrun")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-02 22:02:44 +01:00
Takashi Yano 2b3a70d0a6 Cygwin: pty: Add still missing acquire/release_attach_mutex.
- transfer_input() function uses console api, so it should be guarded
  by attach_mutex. However, in most cases, it is missing. This patch
  fixes the issue.
2022-03-03 04:41:20 +09:00
Takashi Yano df24c3d3c6 Cygwin: pty: Communalize the code for temporary attach to console.
- This patch communalizes the code for attaching another console
  temporarily and resuming to the original attach state, because
  there were a plurality of similar codes throughout.
2022-03-02 21:35:40 +09:00
Takashi Yano 5f4e7b0368 Cygwin: console, pty: Revamp the acquire/release_attach_mutex timing.
- This patch revises the acquiring/releasing timing for attach_mutex
  to make the period in which it is being acquired shorter. Further,
  acquiring/releasing are added to where they are missing but needed.
2022-03-02 19:20:48 +09:00
Corinna Vinschen 42e23c5ad2 Cygwin: _pinfo::siginfo: fix sig_send call
Request __SIGPENDINGALL, not __SIGPENDING, when fetching signal info
for the calling process.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-02 09:48:01 +01:00
Takashi Yano 312dc2289c Cygwin: console: Fix a bug from comparison between int and DWORD. 2022-03-02 11:18:01 +09:00
Takashi Yano 020fa7ed7b Cygwin: console: Prevent special keys processing from drop.
- There was a potential risk to drop special key processing when
  process_input_messsage() is called intermittently. This patch
  fixes the issue.
2022-03-02 09:55:52 +09:00
Takashi Yano 2b4d4728f2 Cygwin: console: Stop to create struct instance which is not needed.
- In fhandler_console::cons_master_thread(), a struct which has
  only a static function is used. In this case, struct instance
  is not necessary. So with this patch, the static function is
  invoked without creating instance.
2022-03-02 08:47:03 +09:00
Corinna Vinschen 3e4dd6cc48 Cygwin: update 3.4 release text
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:27:10 +01:00
Corinna Vinschen 9a3c058f66 Cygwin: /proc/<PID>/status: Fill SigPnd, SigBlk and SigIgn values with life
So far the values of SigPnd and SigBlk were always 0 and SigIgn
was incorrectly set to the block mask of the current thread of
the calling process.

Fix that by adding a _pinfo::siginfo method and a PICOM_SIGINFO
message to allow to request actual signal info of any running process.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Corinna Vinschen 195169186b Cygwin: wait_sig: allow to compute process-wide mask of pending signals
Add a signal __SIGPENDINGALL to allow computing the mask of all
currently pending signals.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Corinna Vinschen 05e7a60dd7 Cygwin: add init_cygheap::compute_sigblkmask method
Add method to compute process-wide signal block mask

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Corinna Vinschen 9551e617e7 Cygwin: Makefile: fix ctags --extras option
--extra is deprectated, use --extras

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Corinna Vinschen c78f149733 Cygwin: handle_sigprocmask: If new signal set is NULL, ignore "how"
The "how" value only makes sense if a new set is given.  If we
only read the current signal set, ignore the value of "how" per
POSIX:

"If set is a null pointer, the value of the argument how is not
significant"

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Corinna Vinschen 25937aa1d0 Cygwin: /proc/<PID>/status: fix format specifier
The format specifier used for the signal masks is incorrectly
assuming 32 bit values.  Fix it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Takashi Yano aec053c60c Cygwin: pty: Rename some functions/variables with the name *pcon*.
- With this patch, some pty functions/variables have been renamed
  so that the name *pcon* is not used for those that are called
  even when the pseudo console is not active.
2022-03-01 22:09:01 +09:00
Corinna Vinschen 3e11a002b3 Cygwin: sysconf: _SC_TZNAME_MAX: return -1 as valid value
sysconf incorrectly sets errno to EINVAL for _SC_TZNAME_MAX.
Don't do that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 11:43:52 +01:00
Takashi Yano 1e6c51d741 Cygwin: pty: Reorganize the code path of setting up and closing pcon.
- This patch reorganizes the code path of setting-up and cleaning-up
  of the pseudo console to improve readability and maintainability
  of pty code.
2022-03-01 19:40:55 +09:00
Takashi Yano fbfea31dd9 Cygwin: pty: Avoid cutting the branch the pty master is sitting on.
- When Ctrl-C terminates a non-cygwin process on a pseudo console,
  pty master attaches to the pseudo console first, and send
  CTRL_C_EVENT. If the non-cygwin process closes the pseudo console
  before the pty master calls FreeConsole(), the pty master process
  will crash. With this patch, pty master process takes over the
  ownership of the pseudo console, and closes it by myself.
2022-03-01 19:40:46 +09:00
Takashi Yano 95a28b1f9e Cygwin: pty: Isolate CTRL_C_EVENTs between ptys.
- With this patch, unique invisible consoles are created for each pty
  to isolate CTRL_C_EVENTs between ptys. This is necessary by Ctrl-C
  handling in fhandler_termios::process_sigs() for non-cygwin apps
  started in pty if the pseudo console is disabled.
2022-02-28 20:25:09 +09:00
Takashi Yano 8ff9f216fd Cygwin: console: Improve the code to avoid typeahead key swapping.
- The commit "Cygwin: console: Prevent the order of typeahead input
  from swapped." did not fully resolve the issue. If keys are typed
  during input buffer fix, the order of key event may be swapped.
  This patch fixes the issue again.
2022-02-28 20:17:12 +09:00
Takashi Yano f6db6f52ae Cygwin: pinfo: Fix exit code for non-cygwin apps which reads console.
- The recent commit "Cygwin: pinfo: Fix exit code when non-cygwin app
  exits by Ctrl-C." did not fix enough the issue. If a non-cygwin app
  is reading the console, it will not return STATUS_CONTROL_C_EXIT
  even if it is terminated by Ctrl-C. As a result, the previous patch
  does not take effect.
  This patch solves this issue by setting sigExeced to SIGINT in
  ctrl_c_handler(). In addition, sigExeced will be cleared if the app
  does not terminated within predetermined time period. The reason is
  that the app does not seem to be terminated by the signal sigExeced.
2022-02-28 20:10:02 +09:00
Takashi Yano 15a35758d8 Cygwin: termios: Ensure detection of GDB inferior in process_sigs().
- In some situations, some cygwin processes might wrongly identified
  as GDB inferior. This patch ensures the detection of GDB inferior.
2022-02-28 08:00:16 +09:00
Takashi Yano 33d8578feb Cygwin: termios: Add comments to the code refactored recently.
- This patch adds some comments to the source code whose intent may
  not be clear enough from the code which is refactored recently.
2022-02-27 20:50:53 +09:00
Takashi Yano d857df6f08 Cygwin: console: Correct the past fix for apps which open pty.
- The commit "Cygwin: console: Fix issues of apps which open pty."
  did not fix the second problem correctly. That commit looked to
  fix the issue, but the actual problem was that ctrl_c_handler()
  should be reregistered *AFTER* FreeConsole()/AttachConsole().
  This patch correct that.
2022-02-27 12:46:05 +09:00
Takashi Yano 696a713bf2 Cygwin: console: Revert experimental code mixed accidentally.
- The commit "Cygwin: console: Restore CTRL_BREAK_EVENT handling."
  was accidentally mixed with experimental code in exceptions.cc.
  Due to this, non-cygwin app receives CTRL_C_EVENT twice in the
  following scenario.
   1) Run 'sleep 10 | <non-cygwin app>'
   2) Hit Ctrl-C.
   3) The non-cygwin app receives CTRL_C_EVENT twice.
  This patch reverts the code with the problem.
2022-02-27 00:34:30 +09:00
Takashi Yano 95a60b7fdd Cygwin: console: Prevent the order of typeahead input from swapped.
- If a lot of keys are typed very quickly in the app which does
  not read console, the order of input keys in console input buffer
  occasionally swapped. Although this extremely rarely happens,
  is obviously a bug of cons_master_thread. This patch fixes the
  issue.
2022-02-26 15:59:54 +09:00
Takashi Yano e9d4341677 Cygwin: pty: Stop to send CTRL_C_EVENT if pcon activated.
- The commit "Cygwin: console: Redesign handling of special keys."
  removes special treatment for pty in with pseudo console activated,
  however, it is necessary on second thought. This is because sending
  CTRL_C_EVENT to non-cygwin apps will be done in pseudo console,
  therefore, sending it in fhandler_pty_master::write() duplicates
  that event for non-cygwin apps.
2022-02-26 15:59:32 +09:00
Takashi Yano 32401ad98e Cygwin: console: Fix issues of apps which open pty.
- After some recent changes for special keys handling break the
  apps which open pty (such as script command). If the app which
  opens pty is executed in console, the following issues occur.
    1) If the script command was started from non-cygwin shell
       (such as cmd.exe), another cygwin app started in pty slave
       cannot receive Ctrl-C.
    2) If non-cygwin app is executed in pty slave, the app which
       opened the pty (e.g. script command) crashes by Ctrl-C.
  This patch fixes these issues.
2022-02-26 15:59:20 +09:00
Takashi Yano 3a6b11c697 Cygwin: pinfo: Fix exit code when non-cygwin app exits by Ctrl-C.
- Previously, if non-cygwin app exits by Ctrl-C, exit code was
  0x00007f00. With this patch, the exit code will be 0x00000002,
  which means process exited by SIGINT.
2022-02-25 17:29:28 +09:00
Takashi Yano 5c4a0824e7 Cygwin: console: Restore CTRL_BREAK_EVENT handling.
- The recent change by the commit "Cygwin: console: Redesign handling
  of special keys." breaks the handling of CTRL_BREAK_EVENT. The login
  shell in console exits on Ctrl-Break key. This patch fixes the issue.
2022-02-24 17:35:21 +09:00
Takashi Yano 2f2b915505 Cygwin: pty, console: Add a workaround for GDB SIGINT handling.
- The inferior of the GDB cannot be continued after SIGINT even
  though nopass option is set. This seems because cygwin GDB does
  not support hooking cygwin signal. Therefore, a workaround for
  GDB is added. With this patch, only CTRL_C_EVENT is sent to the
  GDB inferior by Ctrl-C and sending SIGINT is omitted. Note that
  "handle SIGINT (no)pass" command does not take effect even with
  or without this patch.
2022-02-24 02:17:32 +09:00
Takashi Yano d2b14c303c Cygwin: console: Redesign handling of special keys.
- This patch rearranges the cooperation between cons_master_thread,
  line_edit, and ctrl_c_handler so that only one of them operates
  at the same time. Since these handle Ctrl-C individually, so the
  signal may be sent multiple times to the process. This patch fixes
  the issue.
2022-02-24 01:38:08 +09:00
Corinna Vinschen f2dc492df0 Cygwin: unlink: filter out virtual files and devices early on
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-22 13:33:06 +01:00
Johannes Schindelin 4ec08891a0 Cygwin: Implicitly support the /dev/fd symlink and friends
Bash has a very convenient feature that is called process substitution
(e.g. `diff -u <(seq 0 10) <(seq 1 11)`). To make this work, Bash
requires the `/dev/fd` symlink to exist, and Cygwin therefore creates
this symlink (together with the `stdin`, `stdout` and `stderr` ones)
upon start-up.

This strategy is incompatible with the idea of providing a subset of
Cygwin in a `.zip` file (because there is no standard way to represent
symlinks in `.zip` files, and besides, older Windows versions would
potentially lack support for them anyway).

That type of `.zip` file is what Git for Windows wants to use, though,
bundling a minimal subset for third-party applications in MinGit (see
https://github.com/git-for-windows/git/wiki/MinGit for details).

Let's side-step this problem completely by creating those symlinks
implicitly, similar to the way `/dev/` is populated with special
devices.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2022-02-22 13:33:00 +01:00
Corinna Vinschen 8bb6821c7a Cygwin: Adjust path to newlib libc.a, too
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-22 12:49:33 +01:00
Jon Turney 56ec1fcb0d Cygwin: Adjust path to newlib libm.a in builddir
Adjust path to newlib libm.a in builddir, changed by ac9f8c46
2022-02-22 12:49:33 +01:00
Matt Joyce 44b60f0c4b Make __sdidinit unused
Remove dependency on __sdidinit member of struct _reent to check
object initialization. Like __sdidinit, the __cleanup member of
struct _reent is initialized in the __sinit() function. Checking
initialization against __cleanup serves the same purpose and will
reduce overhead in the __sfp() function in a follow up patch.
2022-02-22 12:38:46 +01:00
Takashi Yano 054b00d96a Cygwin: pty: Encapsulate pty code in tty::setpgid().
- This patch hides complex pty codes in tty::setpgid() to transfer
  input into the class fhandler_pty_slave by encapsulating it.
2022-02-22 07:33:09 +09:00
Takashi Yano 0ddf19d6ca Cygwin: pty, console: Fix handle leak which occurs on exec() error.
- This patch fixes the handle leak which occurs when exec() fails
  with an error. The duplicated handles will be closed when the
  exec'ed process is terminated. However, if exec() fails, the code
  path does not reach to the code closing the duplicated handles.
  To implement this fix more appropriately, the setup, cleanup and
  closing pty codes which was previously located in spawn.cc are
  encapsulated into the fhandler_pty_slave class functions.
2022-02-22 07:26:34 +09:00
Takashi Yano fc26624377 Cygwin: console: Call fix_tab_position() only if having broken tabs.
- Calling fix_tab_position() is necessary in Windows 10 with xterm
  compatible mode enabled, because it has a problem that the tab
  positions will be broken when the window size is changed. Fortunately,
  this problem has been fixed in Windows 11. Therefore, with this patch,
  necessity of fix_tab_position() call is determined by referring to
  wincap.has_con_broken_tabs(), which is recently introduced.
2022-02-20 19:22:09 +09:00
Takashi Yano 29d8a83008 Cygwin: console: Rearrange set_(in|out)put_mode() calls.
- With this patch, all set_(in|out)put_mode() calls are rearranged
  as follows.

  1) Setup for cygwin apps, started from non-cygwin app, is done
     in fhandler_console::post_open_setup(), which overrides
     fhandler_base::post_open_setup() called from dtable.cc.
  2) Cleanup for cygwin app is done in fhandler_console::close().
  3) Setup for cygwin apps is also in fhandler_console::bg_check(),
     which overrides fhandler_termios::bg_check(). This is called
     on read(), write() and select() for console. It is necessary
     if cygwin and non-cygwin apps are started simultaneously in
     the same process group.
  4) Setup for non-cygwin apps is done in spawn.cc via
     fhandler_console::setup_console_for_non_cygwin_app().
  5) Cleanup for non-cygwin app is done in spawn.cc vid
     fhandler_console::cleanup_console_for_non_cygwin_app().
  6) Setup for non-cygwin app started by GDB is done in
     fhandler_console::set_console_mode_to_native().
  7) No explicit cleanup for non-cygwin app started by GDB, because
     console mode is automatically reset to tty::cygwin on read()/
     write() in GDB thanks to 3).
2022-02-20 19:22:02 +09:00
Takashi Yano 2cab4d0bb4 Cygwin: pty, console: Refactor the code processing special keys.
- This patch commonize the code which processes special keys in pty
  and console to improve maintanancibility. As a result, some small
  bugs have been fixed.
2022-02-20 19:21:51 +09:00
Takashi Yano 9f1930bf34 Cygwin: wincap: Add capabilities for Windows 11.
- The capability changes since Windows 11 have been reflected in
  wincap.cc. The capability has_con_broken_tabs is added, which is
  false since Windows 11.
2022-02-16 19:59:14 +09:00
Brian Inglis 97b8a93b3c fhandler_proc.cc(format_proc_cpuinfo): fix bad bits in last change
move Linux 5.16 Gobble Gobble flags to 5.17 Superb Owl correct positions:
0x00000007:1 Intel Advanced Matrix eXtensions:
		 EAX:22 amx_bf16 Brain Float 16 dot product
		 EAX:24 amx_tile Tile matrix multiply
		 EAX:25 amx_int8 Int 8 byte dot product
0x00000007:0 Intel Advanced Matrix eXtensions:
		 EDX:22 amx_bf16 Brain Float 16 dot product
		 EDX:24 amx_tile Tile matrix multiply
		 EDX:25 amx_int8 Int 8 byte dot product
2022-02-16 09:31:32 +01:00
Takashi Yano dd65342315 Cygwin: console: Set console mode even if stdin/stdout is redirected.
- When non-cygwin app is started in console, console mode is set to
  tty::native. However, if stdin is redirected, current code does not
  set the input mode of the console. In this case, if the app opens
  "CONIN$", the console mode will not be appropriate for non-cygwin
  app. This patch fixes the issue.

Addresses:
https://github.com/GitCredentialManager/git-credential-manager/issues/576
2022-02-13 23:55:59 +09:00
Takashi Yano cb0e392903 Cygwin: console: Fix console mode for non-cygwin inferior of GDB.
- Currently, there is no chance to change console mode for non-cygwin
  inferior of GDB. With this patch, the console mode is changed to
  tty::native in CreateProcess() and ContinueDebugEvent() hooked in
  fhandler_console.
2022-02-13 23:55:59 +09:00
Takashi Yano bed1add783 Cygwin: pty: Fix a bug in tty_min::segpgid().
- In tty_min::setpgid(), a pointer to fhandler instance is casted to
  fhandler_pty_slave and accessed even if terminal is not a pty slave.
  This patch fixes the issue.
2022-02-13 23:55:59 +09:00
Takashi Yano c4704c7c20 Cygwin: pty: Discard input in from_master_nat pipe on signal as well.
- Currently, pty discards input only in from_master pipe on signal.
  Due to this, if pty is started without pseudo console support and
  start a non-cygwin process from cmd.exe, type adhead input is not
  discarded on signals such as Ctrl-C. This patch fixes the issue.
2022-02-13 23:55:59 +09:00
Takashi Yano b958e1f03a Cygwin: pty: Revise the code to wait for completion of forwarding.
- With this patch, the code to wait for completion of forwarding of
  output from non-cygwin app is revised so that it can more reliably
  detect the completion.
2022-02-13 23:55:59 +09:00
Takashi Yano bddd9c1c41 Cygwin: pty: Prevent deadlock on echo output.
- If the slave process writes a lot of text output, doecho() can
  cause deadlock. This is because output_mutex is held in slave::
  write() and if WriteFile() is blocked due to pipe full, doecho()
  tries to acquire output_mutex and gets into deadlock. With this
  patch, the deadlock is prevented on the sacrifice of atomicity
  of doecho().
2022-02-13 23:55:59 +09:00
Takashi Yano b04aea00f1 Cygwin: pty: Pass Ctrl-Z (EOF) to non-cygwin apps with disable_pcon.
- Previously, non-cygwin app running in pty started without pseudo
  console support was suspended by Ctrl-Z rather than sending EOF.
  Even worse, suspended app could not be resumed by fg command. With
  this patch, Ctrl-Z (EOF for non-cygwin apps) is passed to non-cygwin
  app instead of suspending that app. This patch also handles Ctrl-\
  (QUIT) and Ctrl-D (EOF) as well.
2022-02-13 23:55:59 +09:00
Takashi Yano c05c36a7c8 Cygwin: pty, console: Fix Ctrl-C handling for non-cygwin apps.
- Currently, if cat is started from cmd.exe which is started in cygwin
  console, Ctrl-C terminates not only cat but also cmd.exe. This also
  happens in pty in which pseudo console is disabled. This patch fixes
  the issue.
2022-02-13 23:55:59 +09:00
Mitchell Hentges 8a95249d73 Cygwin: console: Maintain ENABLE_(INSERT|QUICK_EDIT)_MODE flags.
- Currently, ENABLE_INSERT_MODE and ENABLE_QUICK_EDIT_MODE are cleared
  if cygwin is started in console. These flags will not be recovered
  even when exiting from cygwin. Also note that if ENABLE_EXTENDED_FLAGS
  is once unset, then the flag ENABLE_QUICK_EDIT_MODE it's associated
  with will no longer be preserved. Unfortunately, we're accidentally
  stepping on this in fhandler_console::set_input_mode().

  This patch solves this by carrying forward these flags in the place
  where it had been ignoring them. Since the previous behaviour of
  leaving these flags unset would essentially maintain their existing
  state, adding the carry-over of the flags now should not alter console
  behaviour.
2022-02-11 09:07:30 +09:00
Takashi Yano 7e6422fd2a Cygwin: wincap: Add capabilities for Windows 10 2004 and newer.
- The capability changes since Windows 10 2004 have been reflected
  in wincap.cc. (has_con_broken_il_dl has been changed to false.)
2022-02-05 19:28:34 +09:00
Corinna Vinschen c3efc81658 Cygwin: drop dllfixdbg script
On second thought, we don't actually need this script.
Express the entire action as sufficiently simple Makefile rule.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-05 10:42:27 +01:00
Takashi Yano 44d8704179 Cygwin: console: Remove unnecessary (redundant) code. 2022-02-05 16:55:12 +09:00
Corinna Vinschen 899cf3c952 Cygwin: fix dependency to dllfixdbg script
Only the files created from cygwin0.dll depend on the script, not
cygwin0.dll as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-04 18:27:14 +01:00
Corinna Vinschen 820c736785 Cygwin: dllfixdbg: improve readability
- formatting
- use array pointer as argument rather than variable arguments
- syntactical fixes
- add comments
- drop unnecessary recomputation of all section VMAs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-04 18:27:14 +01:00
Corinna Vinschen 4aeba49016 Cygwin: dllfixdbg: honor Makefile verbositiy flag "V"
In Makefile.am, add the value of $(V) to the dllfixdbg call.
In dllfixdbg, if V=1, print what the script is doing.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-03 16:22:46 +01:00
Corinna Vinschen 7ae91f3b56 Cygwin: dllfixdbg: don't overwrite input DLL
Change dllfixdbg to keep the input DLL intact and just generate
a new DLL matching the debug file.  Fix Makefile rule accordingly.
The result is, cygwin0.dll is the original DLL created with full
debug sections and stays that way throughout the build process.
Only new-cygwin1.dll will become the stripped DLL matching with
the file containing the debug sections cygwin1.dbg.  This is ok,
because commit ba02fef995 ("Cygwin: Makefile.am: fix DLL build rule")
made new-cygwin1.dll the DLL to be installed.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-03 16:22:46 +01:00
Takashi Yano 96646006a7 Cygwin: console: Fix IL/DL escape sequence on the last line.
- Currently, escape sequence IL/DL (CSI Ps L, CSI Ps M) does not
  work correctly at the last (bottom end) line. This patch fixes
  the issue.

Addresses:
  https://cygwin.com/pipermail/cygwin/2022-February/250736.html
2022-02-03 21:09:44 +09:00
Takashi Yano e5aca9ced9 Cygwin: path: Fix UNC path handling for SMB3 mounted to a drive.
- If an UNC path is mounted to a drive using SMB3.11, accessing to
  the drive fails with error "Too many levels of symbolic links."
  This patch fixes the issue.
2022-02-03 12:21:21 +09:00
Corinna Vinschen 4a70041dfd Cygwin: silence dllfixdbg
There's no good reason to print the objcopy generation rules

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-02 21:30:20 +01:00
Corinna Vinschen ba02fef995 Cygwin: Makefile.am: fix DLL build rule
A single Makefile rule creates three files in three steps, the second
and third one never showing up in dependencies.  The next step creating
the link lib only depends on the first of these files.  Even if the
second or third step in the DLL build rule fails, the next make
invocation never picks up on this and just goes ahead creating the
link lib.

Fix this by splitting the DLL build rule into three rules, with
every step on the way depending on the previous rule.  Also fix up
the names, TEST_DLL_NAME just doesn't cut it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-02 21:30:20 +01:00
Corinna Vinschen 047eaf9a6b Cygwin: drop autoloading kernel32 symbols available since Windows 7
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-28 10:36:54 +01:00
Corinna Vinschen d079ab4d37 Revert "Cygwin: fix permission problem when writing DAC info on Samba shares"
This reverts commit 0390cc8572.

There's no indication what exact situation this patch was supposed to
solve, and local testing doesn't show any such problems.  However, this
patch itself introduced a new problem, as outlined by
https://cygwin.com/pipermail/cygwin/2022-January/250629.html

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-27 15:31:25 +01:00
Corinna Vinschen f467a1da58 Cygwin: ACLs: don't set indicator for default ACEs prematurely
Commit a2bfe7cae6 introduced a change ignoring default ACEs on files
to come up with a valid POSIX ACL, reflecting the Windows ACEs actually
making sense on files.

However, if CREATOR OWNER or CREATOR GROUP ACEs - both only making sense
as default ACEs - are found in the ACL, a value indicating the presence
of default ACEs gets set, even on files.  This in turn breaks a
subsequent integrity check and get_posix_access returns EINVAL.

The code path handling default ACEs on directories sets this indicator
anyway, so don't set it just because one of the above SIDs are found.

Fixes: a2bfe7cae6 ("Cygwin: ACLs: ignore *_INHERIT flags in file ACLs")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-25 19:53:40 +01:00
Jon Turney 9c546e0fd2
Cygwin: silence most custom build rules 2022-01-19 17:13:44 +00:00
Anton Lavrentiev via Cygwin-patches 93511d575e Cygwin: resolver: cygwin_query() skip response header on internal error
- When dn_comp() failed internally there is no longer any need to
fill the response header since it's now all cleared upon entry
2022-01-19 15:26:14 +01:00
Corinna Vinschen a74707e7ac Cygwin: add resolver fixes to release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-19 08:51:03 +01:00
Anton Lavrentiev via Cygwin-patches 099d5a9a57 Cygwin: resolver: A few fixes for cygwin_query(), part 2
Make sure Windows ResultSet is free'd when dn_comp failed internally
2022-01-19 08:05:18 +01:00
Anton Lavrentiev via Cygwin-patches 54f0590a66 Cygwin: resolver: Targets in SRV DNS responses may not be compressed
RFC2782 clearly says so yet it's a common misconception to perform the
compression in the violation of the standard.  This patch fixes that
2022-01-19 08:05:18 +01:00
Anton Lavrentiev via Cygwin-patches 905f51d797 Cygwin: resolver: Fix to match response ID with request ID
In case when the native OS resolver is used (via os_query) the returned
response ID is always 0.  It should actually match the ID passed in to
res_send() in the DNS request header.  This patch fixes that
2022-01-19 08:05:18 +01:00
Anton Lavrentiev via Cygwin-patches 12bf36f72b Cygwin: resolver: A few fixes for cygwin_query()
- Make sure the answer buffer is properly cleared so there is no trailing
garbage when the response does not fit entirely in;
- Make sure an internal decomp failure gets reported correctly (w/return code -1);
- Make sure that the buffer is not overrun when filling out the header.
2022-01-19 08:05:18 +01:00
Anton Lavrentiev via Cygwin-patches fa279a583d Cygwin: resolver: Process options forward (not backwards)
Also, make sure the debug setting propagates to the parser of
the remainder of /etc/resolv.conf
2022-01-19 08:05:18 +01:00
Takashi Yano ff539cc0f9 Cygwin: fhandler_base: Fix double free caused when open() fails.
- When open fails, archetype stored in archetypes[] is not cleared.
  This causes double free when next open fail. This patch fixes the
  issue.

Addresses:
  https://cygwin.com/pipermail/cygwin/2022-January/250518.html
2022-01-18 22:17:37 +09:00
Corinna Vinschen 0cae2b802b Cygwin: add release text for last two patches
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-18 11:57:14 +01:00
Johannes Schindelin bd4fdcc059 Cygwin: path_conv: do not get confused by a directory with `.lnk` suffix
When trying to create a directory called `xyz` in the presence of a
directory `xyz.lnk`, the Cygwin runtime errors out with an `ENOENT`.

The root cause is actually a bit deeper: the `symlink_info::check()`
method tries to figure out whether the given path refers to a symbolic
link as emulated via `.lnk` files, but since it is a directory, that is
not the case, and that hypothesis is rejected.

However, the `fileattr` field is not cleared, so that a later
`.exists()` call on the instance mistakenly thinks that the symlink
actually exists. Let's clear that field.

This fixes https://github.com/msys2/msys2-runtime/issues/81

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2022-01-18 11:55:44 +01:00
Anton Lavrentiev via Cygwin-patches e195f51af7 Cygwin: resolver: Added processing of AAAA records
AAAA records returned from Windows resolver were flagged as "No
structure" in debug output because of being processed (although
correctly) in the default catch-all case.  This patch makes the AAAA
records properly recognized.
2022-01-18 11:24:48 +01:00
Anton Lavrentiev via Cygwin-patches 90947659b0 Cygwin: resolver: A little more consistency in debug messages 2022-01-18 11:24:37 +01:00
Anton Lavrentiev via Cygwin-patches 3baaf08324 Cygwin: resolver: Format spec consistency for Windows errors 2022-01-18 11:24:33 +01:00
Anton Lavrentiev via Cygwin-patches 5f40b62709 Cygwin: resolver: Debug to output both IP and port # in native b.o.
Also, change a few other debug output spots for consistency
2022-01-18 11:24:20 +01:00
Anton Lavrentiev via Cygwin-patches 1dd65a9ede Use matching format for NTSTATUS 2022-01-17 11:32:00 +01:00
Anton Lavrentiev via Cygwin-patches 746e7f1b06 Fix format specifier for wide-char string 2022-01-17 11:30:35 +01:00
Takashi Yano 909ed837cc Cygwin: pty: Fix race issue between closing and opening master.
- If the from_master is closed before cleaning up other pipes, such
  as from_slave_nat, the same pty may be allocated and pty master may
  try to open the pipe which is not closed yet, and it will fail.
  This patch fixes the issue.
2022-01-14 23:11:20 +09:00
Takashi Yano bff4594b08 Cygwin: console: Fix potential deadlock regarding acuqiring mutex.
- Acquiring input_mutex and attach_mutex in console code has potential
  risk of deadlock. This patch fixes the issue.
2022-01-14 23:11:07 +09:00
Takashi Yano 3af461092e Cygwin: pty: Stop closing and recreating attach_mutex.
- Closing attach_mutex and recreating it causes the race issue
  between pty and console codes. With this patch, attach_mutex
  is created only once in a process which opens pty, and never
  closed in order to avoid this issue.

Addresses:
  https://cygwin.com/pipermail/cygwin-developers/2021-December/012548.html
2022-01-14 23:11:01 +09:00
Takashi Yano 4f490c4cef Cygwin: pty: Fix memory leak in master_fwd_thread.
- If master_fwd_thread is terminated by cygthread::terminate_thread(),
  the opportunity to release tmp_pathbuf is missed, resulting in a
  memory leak. This patch fixes the issue.
2022-01-14 23:10:55 +09:00
Takashi Yano aa49985245 Cygwin: pty, console: Fix deadlock in GDB regarding mutex.
- GDB inferior may be suspended while the inferior grabs mutex.
  This causes deadlock in terminal I/O. With this patch, timeout
  for waiting mutex is set to 0 for the debugger process when the
  process calls CreateProcess() with DEBUG_PROCESS flag to avoid
  deadlock. This may cause the race issue in GDB, however, there
  is no other way than that.

Addresses:
 https://cygwin.com/pipermail/cygwin-developers/2021-December/012542.html
2022-01-14 23:10:47 +09:00
Brian Inglis bd179c36bf fhandler_proc.cc(format_proc_cpuinfo): add Linux 5.16 Gobble Gobble flags
0x00000007:1 Intel Advanced Matrix eXtensions:
		 EAX:22 amx_bf16 Brain Float 16 dot product
		 EAX:24 amx_tile Tile matrix multiply
		 EAX:25 amx_int8 Int 8 byte dot product
0x80000008:0 AMD EBX:27 cppc      Collaborative Processor Performance Control
2022-01-12 19:43:43 +01:00
Corinna Vinschen 935c33877d posix_spawn: fix get/set uid/gid calls for 32 bit Cygwin
32 bit Cygwin still exports function calls to support old applications.
E. g., when switching from 16 to 32 bit uid/gid values, new function
like getuid32 have been added and the old getuid function still only
provides 16 bit values.  Newly built applications using getuid are
actually calling getuid32.

However, this link magic isn't performed inside Cygwin itself, so if
newlib functions call getuid, they actually call the old getuid, not
the new getuid32.  This leads to truncated uid/gid values.

https://cygwin.com/pipermail/cygwin/2022-January/250453.html reports
how this leads to problems in posix_spawn.

Fix this temporarily. i686 support will go away soon in Cygwin and the
fix can be dropped.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-12 11:57:35 +01:00
Corinna Vinschen f574c30857 Cygwin: Makefile: add dependency to newlib's libs
We need deps to newlib's libc.a and libm.a, otherwise changes
in newlib code don't trigger a rebuild of the Cygwin DLL.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-12 11:45:54 +01:00
Corinna Vinschen a2bfe7cae6 Cygwin: ACLs: ignore *_INHERIT flags in file ACLs
get_posix_access() creates DEF_*_OBJ aclent_t entries from Windows ACEs
with INHERIT flags set, independent of the file type.  These flags only
make sense on directory objects, but certain Windows functions don't
check the file type and allow INHERIT ACE flags even on non-directories.

As a fix, make sure to ignore the INHERIT flags on non-directory ACLs
and don't propagate the matching DEF_*_OBJ aclent_t entries to callers.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-11 22:22:03 +01:00
Ken Brown 0ce992c1e4 Cygwin: fhandler_pipe::get_query_hdl_per_process: avoid a crash
NtQueryInformationProcess(ProcessHandleInformation) can return
STATUS_SUCCESS with invalid handle data for certain processes
("minimal" processes on Windows 10).  This can cause a crash when
there's an attempt to access that data.  Fix that by setting
NumberOfHandles to zero before calling NtQueryInformationProcess.

Addresses: https://cygwin.com/pipermail/cygwin-patches/2021q4/011611.html
2021-12-26 18:29:23 -05:00
Takashi Yano 80f4b7d545 Cygwin: pty: Fix input switching failure.
- This patch fixes the failure of input switching between io_handle
  and io_handle_nat. This very rarely happens, however, input is
  wrongly switched to io_handle_nat even though the non-cygwin app
  is in the background.
2021-12-15 12:25:58 +09:00
Takashi Yano 0795f704f7 Cygwin: pty: Fix conditions for input transfer again. 2021-12-14 19:20:34 +09:00
Takashi Yano 720234b78a Cygwin: pty: Fix conditions for input transfer.
- The recent commit "Cygwin: pty: Add missing input transfer when
  switch_to_pcon_in state." causes regression that rlwrap cannot
  work with cmd.exe. This patch fixes the issue.
2021-12-14 12:32:36 +09:00
Takashi Yano 8d8724ee1b Cygwin: pty: Fix Ctrl-C handling further for non-cygwin apps.
- The recent commit: "Cygwin: pty: Fix Ctrl-C handling for non-cygwin
  apps in background." causes the problem that cmd.exe is terminated
  by Ctrl-C even if it is running in pseudo console. This patch fixes
  the issue.
2021-12-13 19:43:02 +09:00