Commit Graph

459 Commits

Author SHA1 Message Date
Corinna Vinschen 483fb49ea0 Cygwin: add W10 pseudo console support to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-08-29 13:56:43 +02:00
Corinna Vinschen b7399d5e6f Revert "Cygwin: fix potential SEGV in sigwaitinfo/signalfd scenario"
This reverts commit 92115a83a4.

This was utterly wrong.
2019-08-17 10:12:16 +02:00
Corinna Vinschen 92115a83a4 Cygwin: fix potential SEGV in sigwaitinfo/signalfd scenario
On sigwaitinfo or reading from a signalfd, signal processing sets up
signal handling via sigdelayed even if the handler address is NULL.
This doesn't have any impact on sigwaitinfo scenarios (or at least, I
wasn't able to come up with a reproducer) but it breaks signalfd
scenarios, where eventually a call to call_signal_handler from
sigdelayed will try to call the NULL function.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-08-13 12:21:05 +02:00
Corinna Vinschen d59c2c9b82 Cygwin: drop preliminary 3.0.8 release file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-08-09 17:49:16 +02:00
Corinna Vinschen 449e9a73d1 Cygwin: add missing bugfix release messages for 3.1.0
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-08-09 17:47:55 +02:00
Mark Geisert 362b98b49a Cygwin: Implement CPU_SET(3) macros
This patch supplies an implementation of the CPU_SET(3) processor
affinity macros as documented on the relevant Linux man page.

There is a mostly superset implementation of cpusets under newlib's
libc/sys/RTEMS/include/sys that has Linux and FreeBSD compatibility
and is built on top of FreeBSD bitsets.  This Cygwin implementation
and the RTEMS one could be combined if desired at some future point.
2019-08-05 13:22:04 +02:00
Corinna Vinschen a13145a30d Cygwin: Export newlib ndbm functions
Signed-off-by: Corinna Vinschen <corinna-cygwin@cygwin.com>
2019-07-24 22:32:48 +02:00
Ken Brown 6b843b82a8 Cygwin: document the last bug fix 2019-07-24 14:56:21 -04:00
Ken Brown 86817773c5 Cygwin: add release notes for 3.0.8 2019-07-22 08:18:16 -04:00
Corinna Vinschen bae987be12 Cygwin: sigpending: don't report pending signals for other threads
The sigpending mechanism failed to check if the pending signal was a
process-wide signal, or a signal for the curent thread.  Fix that by
adding a matching conditional to wait_sig's __SIGPENDING code.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-07-12 17:27:26 +02:00
Ken Brown 3dcc10ec90 Tweak release message 2019-06-25 16:38:39 -04:00
Ken Brown 9604a251bd Cygwin: timerfd: avoid a deadlock
Add a function timerfd_tracker::enter_critical_section_cancelable,
which is like enter_critical_section but honors a cancel event.  Call
this when a timer expires while the timerfd thread is in its inner
loop.  This avoids a deadlock if timerfd_tracker::dtor has entered its
critical section and is trying to cancel the thread.  See
https://cygwin.com/ml/cygwin/2019-06/msg00096.html.
2019-06-25 15:44:43 -04:00
Mark Geisert 641ecb0753 Cygwin: Implement sched_[gs]etaffinity()
This patch set implements the Linux syscalls sched_getaffinity,
sched_setaffinity, pthread_getaffinity_np, and pthread_setaffinity_np.
Linux has a straightforward view of the cpu sets used in affinity masks.
They are simply long (1024-bit) bit masks.  This code emulates that view
while internally dealing with Windows' distribution of available CPUs among
processor groups.
2019-06-24 09:18:14 +02:00
Corinna Vinschen ad101bcb0f Rename <xlocale.h> back to <sys/_locale.h>
libX11 provides <X11/Xlocale.h>.  The build of libX11 itself adds
include/X11 to the compiler's include path.  This results in a name
collision with /usr/include/xlocale.h on case-insensitive filesystems.

Commit 90e35b1eb3 renamed sys/_locale.h to xlocale.h in March 2017 under
the assumption that we should provide the locale_t type in the same file
as on Linux, FreeBSD, and Darwin.

A few weeks later (June 2017), glibc removed the xlocale.h file in favor
of bits/types/locale_t.h, which shouldn't be included directly anyway.

For reference and the reasoning, see
https://sourceware.org/git/?p=glibc.git;a=commit;h=f0be25b6336d

Given the above, revert 90e35b1eb3 and
fix additional usage of xlocale.h.
2019-06-14 10:02:08 +02:00
Corinna Vinschen 4ac32559c0 Cygwin: Add release info for 3.0.7
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit 01c253a4c58b6c1da01615431bdc4c88fcba48ea)
2019-04-30 18:49:23 +02:00
Corinna Vinschen f527171a93 Cygwin: define MSG_EOR and refuse in send(2)
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-04-25 19:00:08 +02:00
Corinna Vinschen f0ea836b75 Cygwin: add latest signal handling fixes to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-04-06 18:09:41 +02:00
Corinna Vinschen 557227dda3 Cygwin: winpids: Fix getting process multiple times, take 2
commit d1be0a59d4,
"Cygwin: winpids: Fix getting process multiple times"
fixed duplicate processes in ps -W output, but it fixed
the symptom, not the cause.  It also didn't fix the problem
that the `ps' process itself may show up twice in its own
output.

This patch fixes it.  The spawn worker only deleted the
"winpid.PID" symlink of the current process if the child is
a non-Cygwin process, under the assumption that the exec'ing
process exits anyway.  However, the Window in which both
winpid.PID symlinks point to the same cygpid.PID area is just
too long.  The spawn worker now also deletes its own winpid.PID
symlink if the exec'ed process is a Cygwin process.

Additionally the fix from d1be0a59d4
is now performed on the calling process, too.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-04-02 13:00:22 +02:00
Corinna Vinschen de3c82ee6d Cygwin: Add console patches to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-31 19:37:55 +02:00
Corinna Vinschen 7b8049f7a3 Cygwin: document ps -W duplication bug fix
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-31 12:50:50 +02:00
Ken Brown 298581868a Cygwin: document the recent FIFO changes 2019-03-27 19:47:59 +01:00
Corinna Vinschen 10900b98d1 Cygwin: wcsxfrm_l: Only byte swap if dest size is > 0
commit c0d7d3e1a2 removed the usage of the
LCMAP_BYTEREV flag in the call to LCMapStringW to workaround a strange
bug in LCMapStringW.  This patch didn't take a userspace call of
wcsxfrm{_l} with NULL buffer and 0 size to evaluate the required buffer
size into account.  This introduced a crash trying to byte swap the
NULL buffer.  This patch fixes that problem.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-19 21:03:06 +01:00
Corinna Vinschen 38322b9bf6 Cygwin: proc: fix /proc/version output after uname change
3.0.0 changed uname but missed to align /proc/version
which then used the old uname function on the new uname
struct.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-18 11:34:00 +01:00
Corinna Vinschen 004d8adfa2 Cygwin: acls: allow converting empty acl to text
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-13 12:09:11 +01:00
Corinna Vinschen 673a3daa84 Cygwin: add /proc changes to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-12 11:47:31 +01:00
Corinna Vinschen d9f934c9e9 Cygwin: fix permissions of winpid symlinks
The winpid symlinks got created with no query permissions, so
only admins could see all Cygwin processes.  Create symlinks
so everyone has query permissions instead.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-11 21:40:04 +01:00
Corinna Vinschen 4ec5ffc198 Cygwin: posix timers: fix a deadlock
Canceling the timer thread runs under lock.  The thread uses the same
lock to guard its timer_tracker struct access.  If the timing is bad,
timer_settime or timer_delete grab the lock at the same time, the timer
expires.  In the end, cancel waits for the thread sync while the thread
waits for ther lock to be released.

Fix this by not waiting for the thread sync under lock.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-08 12:57:42 +01:00
Corinna Vinschen 094a2a17ad Cygwin: posix timers: fix resource leak
On setting the timer, the thread is accidentally only canceled when
disarming the timer.  This leaks one thread per timer_settimer call.
Move the thread cancellation where it belongs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-06 22:19:16 +01:00
Corinna Vinschen fc5b248784 Cygwin: update 3.0.2 release file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-04 14:14:15 +01:00
Corinna Vinschen 379598dd67 Cygwin: Disable creating case-sensitive folders by default
Inspecting the content of case-sensitive directories
on remote machines results in lots of errors like
disappearing diretories and files, file not found, etc.

This is not feasible as default behaviour

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-01 14:38:36 +01:00
Corinna Vinschen a4e2eb6ba3 Cygwin: timerfd: fix shared memory allocation in fork/exec
timerfd_tracker::fixup_after_fork_exec always tries to restore
the shared timer region at the same address as in the parent.
This is entirely unnecessary and wasn't intended, rather some
kind of copy/paste thinko.  Fix that.  Print NtMapViewOfSection
status code in api_fatal on failure for debugging.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-24 20:23:34 +01:00
Corinna Vinschen aeaa051f3b Cygwin: POSIX timers: Fix timer values returned for unarmed timer
The "optimized" condition to recognize an unarmed timer was plain
wrong.  Replace it by checking the stored it_value against 0.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-24 10:12:03 +01:00
Corinna Vinschen f3be186911 Cygwin: Add 3.0.2 release file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-23 23:07:42 +01:00
Yaakov Selkowitz a62b29bfec Cygwin: document secure_getenv
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2019-02-19 14:34:18 -06:00
Corinna Vinschen e53373bbdb Cygwin: re-enable create_token for older systems
Under WOW64 on 64 bit Windows 7, MsV1_0S4ULogon appears to be
unimplemented, probably under Vista as well.  Re-enable
create_token method, to allow basic seteuid on W7 WOW64 and
Vista as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-18 21:00:59 +01:00
Corinna Vinschen 367c1ae161 Cygwin: mount: define binary mount as default
Commit c1023ee353 changed the way
path_conv::binmode() works.  Rather than returning three states,
O_BINARY, O_TEXT, 0, it only returned 2 states, O_BINARY, O_TEXT.  Since
mounts are only binary if they are explicitely mounted binary by setting
the MOUNT_BINARY flag, textmode is default.

This introduced a new bug.  When inheriting stdio HANDLEs from native
Windows processes, the fhandler and its path_conv are created from a
device struct only.  None of the path or mount flags get set this way.
So the mount flags are 0 and path_conv::binmode() returned 0.

After the path_conv::binmode() change it returned O_TEXT since, as
explained above, the default mount mode is textmode.

Rather than just enforcing binary mode for path_conv's created from
device structs, this patch changes the default mount mode to binary:

Replace MOUNT_BINARY flag with MOUNT_TEXT flag with opposite meaning.
Drop all explicit setting of MOUNT_BINARY.  Drop local set_flags
function, it doesn't add any value.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-18 10:26:53 +01:00
Corinna Vinschen 5e6ce1cfb2 Cygwin: utils: kill: revert erroneously removed optind correction
When recognizing a negative pid, optind is off by one.  The
code correcting this has been erroneously removed by commit
8de660271f.  Revert that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-18 10:22:37 +01:00
Corinna Vinschen 7e671e7578 Cygwin: fork: add PROCESS_VM_OPERATION to child process permissions
...on parent process.  This is required for successful mmap propagation.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-18 10:19:44 +01:00
Corinna Vinschen 9a3cc77b2a Cygwin: passwd/group: store account name case correct
When looking up valid accounts by name, LookupAccountName returns
a SID and a case-correct domain name.  However, the name was input
and LookupAccountName is case-insensitive, so the name is not
necessarily written the same way as in SAM or AD.

Fix that by doing a reverse lookup on the just fetched SID.  This
fetches the account name in the correct case.  Override the
incoming name with the case correct name from LookupAccountSid.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-13 11:13:28 +01:00
Michael Haubenwallner f6be530a23 Cygwin: forkables: update doc, add release notes 2019-02-11 14:28:00 +01:00
Corinna Vinschen 0be0b8f033 Cygwin: execve: fix setting O_APPEND file offset for native child
dtable::set_file_pointers_for_exec is called from
child_info_spawn::worker to move the file position of O_APPEND
files to EOF if the child is a native child.

However, this only works correctly for the first O_APPEND
file descriptor:

- set_file_pointers_for_exec calls SetFilePointer.  The higher
  4 bytes of the desired file offset are given to SetFilePointer
  as pointer to a DWORD value.  On return, SetFilePointer returns
  the higher 4 bytes of the new file position in this DWORD.

- So for the second and subsequent descriptors the higher 4 byte
  of the file position depend on what the actual file position
  of the previous file has been set to:

- If the file is > 2 Gigs, the high offset will not be 0 anymore.

- If the desciptor points to a non-seekable file (i.e., a pipe
  or socket), SetFilePosition returns an error and sets the high
  position to -1.

Fix this by calling SetFilePointerEx instead, which does not
modify the incoming position value.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-09 15:36:02 +01:00
Corinna Vinschen d5d9aac759 Cygwin: tweak Cygwin PID change release note
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-02 21:13:37 +01:00
Corinna Vinschen b5e1003722 Cygwin: processes: use dedicated Cygwin PID rather than Windows PID
Using the Windows PID as Cygwin PID has a few drawbacks:

- the PIDs on Windows get reused quickly.  Some POSIX applications choke
  on that, so we need extra code to avoid too quick PID reuse.

- The code to avoid PID reuse keeps parent process handles and
  (depending on a build option) child processes open unnecessarily.

- After an execve, the process has a split personality:  Its Windows PID
  is a new PID, while its Cygwin PID is the PID of the execve caller
  process.  This requires to keep two procinfo shared sections open, the
  second just to redirect process info requests to the first, correct
  one.

This patch changes the way Cygwin PIDs are generated:

- Cygwin PIDs are generated independently of the Windows PID, in a way
  expected by POSIX processes.  The PIDs are created incrementally in
  the range between 2 and 65535, round-robin.

- On startup of the first Cygwin process, choose a semi-random start PID
  for the first process in the lower PID range to make the PIDs slightly
  unpredictable.  This may not be necessary but it seems kind of inviting
  to know that the first Cygwin process always starts with PID 2.

- Every process not only creates the shared procinfo section, but also a
  symlink in the NT namespace, symlinking the Windows PID to the Cygwin
  PID.  This drops the need for the extra procinfo section after execve.

- Don't keep other process handles around unnecessarily.

- Simplify the code creating/opening the shared procinfo section and
  make a clear distinction between interfaces getting a Cygwin PID and
  interfaces getting a Windows PID.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-01 20:06:47 +01:00
Corinna Vinschen 351b57527d Cygwin: Add pthread exception handling patch to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-01 10:45:27 +01:00
Corinna Vinschen a52396bd07 Cygwin: raise: change to call pthread_kill
POSIX requires that raise(3) is equivalent to

  pthread_kill(pthread_self(), sig);

in multi-threaded applications.  Our raise just called kill(sig).
Fix that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-30 11:36:45 +01:00
Corinna Vinschen 0fb497165f Cygwin: seteuid: use Kerberos/MsV1_0 S4U authentication by default
- This simple and official method replaces cyglsa and "create token"
  methods.  No network share access, same as before.

- lsaauth and create_token are disabled now.  If problems crop up,
  they can be easily reactivated.  If no problems crop up, they
  can be removed in a while, together with the lsaauth subdir.

- Bump Cygwin version to 3.0.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-26 19:41:03 +01:00
Corinna Vinschen 84230b71c6 Cygwin: uname: Raise size of utsname fields and revamp uname(2) output
New format:

  sysname:      CYGWIN_NT-${osversion}-${os_build_number}[-WOW64]
  nodename:     `gethostname`
  release:      ${cygwin_version}-${API minor}.${arch}[.snap]
  version:      YYYY-MM-DD HH:MM UTC
  machine:      ${arch}
_GNU_SOURCE:
  domainname:   `getdomainname`
!_GNU_SOURCE:
  __domainname: `getdomainname`

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-26 18:37:25 +01:00
Corinna Vinschen 2c12a2c32a Cygwin: seteuid: refuse changing uid to disabled or locked out user
So far seteuid could change uid to any existing account, given
sufficient permissions of the caller.  This is kind of bad since
it disallows admins to refuse login to disabled or locked out
accounts.

Add check for the account's UF_ACCOUNTDISABLE or UF_LOCKOUT flags
and don't let the user in, if one of the flags is set.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-24 16:24:35 +01:00
Corinna Vinschen c6171b9fde Cygwin: gethostname: fix fetching hostname from non-winsock function
If gethostname() fails we call GetComputerNameEx with
ComputerNameDnsFullyQualified.  This is wrong, gethostname should return
the hostname only, not the FQDN.  Fix this by calling GetComputerNameEx
with ComputerNameDnsHostname.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-24 14:04:42 +01:00
Corinna Vinschen b79b0c2bae Cygwin: cygthread: set thread name before calling thread func
When reusing a cygthread, the stub method fails to set the thread name
to the new name.  The name is only set when actually creating the
thread.  Fix that by moving the SetThreadName call right in front of the
thread function call.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-23 21:45:59 +01:00