]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
5 years agoCygwin: FIFO: update set_close_on_exec
Ken Brown [Fri, 22 Mar 2019 19:30:40 +0000 (19:30 +0000)]
Cygwin: FIFO: update set_close_on_exec

Deal with each client.

5 years agoCygwin: FIFO: update fixup_after_fork
Ken Brown [Fri, 22 Mar 2019 19:30:40 +0000 (19:30 +0000)]
Cygwin: FIFO: update fixup_after_fork

Fixup each client.  Reset listen_client_thr and lct_termination_evt.

5 years agoCygwin: FIFO: update clone and dup
Ken Brown [Fri, 22 Mar 2019 19:30:39 +0000 (19:30 +0000)]
Cygwin: FIFO: update clone and dup

Deal with all clients.

5 years agoCygwin: FIFO: improve EOF detection
Ken Brown [Fri, 22 Mar 2019 19:30:38 +0000 (19:30 +0000)]
Cygwin: FIFO: improve EOF detection

Add a hit_eof method that tries to detect whether any clients are
connected.  Before concluding that there are none, it gives the
listen_client thread time to update the client data.

5 years agoCygwin: FIFO: add a spinlock
Ken Brown [Fri, 22 Mar 2019 19:30:38 +0000 (19:30 +0000)]
Cygwin: FIFO: add a spinlock

Don't let listen_client_thread and raw_read access the client list
simultaneously.

5 years agoCygwin: FIFO: allow multiple writers
Ken Brown [Fri, 22 Mar 2019 19:30:37 +0000 (19:30 +0000)]
Cygwin: FIFO: allow multiple writers

Introduce a 'fifo_client_handler' structure that can be used by a
reader to communicate with a writer using an instance of the named
pipe.  An fhandler_fifo opened for reading creates a thread that does
the following:

 - maintains a list of fifo_client_handlers
 - listens for_clients trying to connect
 - creates new pipe instances as needed so that there's always at
   least one available for connecting.

The pipe instances are initially created in blocking mode, but they
are set to be non-blocking after a connection is made.

fhandler_fifo::raw_read now loops through the connected clients and
reads from the first one that has data available.

New fhandler_fifo methods: add_client, listen_client,
listen_client_thread, check_listen_client_thread.

Replace the create_pipe method by create_pipe_instance, which allows
unlimited pipe instances.

New helper functions: create_event, set_pipe_non_blocking.

5 years agoCygwin: FIFO: stop using overlapped I/O
Ken Brown [Fri, 22 Mar 2019 19:30:36 +0000 (19:30 +0000)]
Cygwin: FIFO: stop using overlapped I/O

Make fhandler_fifo a derived class of fhandler_base instead of
fhandler_base_overlapped.

Replace the create_pipe macro, which is based on
fhandler_pipe::create, by new create_pipe and open_pipe methods.
These use NT functions instead of Win32 functions.  Replace fifo_name
by get_pipe_name, which returns a pointer to a UNICODE_STRING.

Remove the fnevent macro, which would now be needed only once.

Add a raw_write method, adapted from fhandler_base::raw_write.

Adapt all functions to the changes above.

5 years agoCygwin: Bump DLL version to 3.1
Corinna Vinschen [Wed, 27 Mar 2019 13:01:17 +0000 (14:01 +0100)]
Cygwin: Bump DLL version to 3.1

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: winpids: Fix getting process multiple times
Corinna Vinschen [Wed, 27 Mar 2019 12:53:32 +0000 (13:53 +0100)]
Cygwin: winpids: Fix getting process multiple times

Switching to Cywin-only PIDs introduced a new problem when collecting
Cygwin processes for `ps -W': A process can show up multiple times
again, if the Cygwin procinfo has been opened for a just execing
process.  The execed process then shows up twice, once as Cygwin
process, but with the wrong Windows PID of the execing process,
once as Windows-only process.

The mechanism used to exclude these stray processes didn't work with
the new Cygwin pid handling anymore.  To fix this

* check if the incoming Windows PID is the same as the PID in the
  procinfo.  If not, we have the PID of the execing process while
  procinfo was already changed,
* always check if the process has already been handled, not only
  for processes we got a procinfo for,
* simplify adding pid to pidlist since pid is now always correct.

While at it, fix comments and comment formatting.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoAdd missing includes.
Andrew Stubbs [Mon, 25 Mar 2019 15:33:53 +0000 (15:33 +0000)]
Add missing includes.

These missing includes were causing build warnings, but also a real bug in
which the "size" parameter to "write" was being passed in 32-bit, whereas it
ought to be 64-bit.  This led to intermittent bad behaviour.

5 years agoget and convert boot time once and use as needed
Brian Inglis [Sun, 24 Mar 2019 02:22:39 +0000 (20:22 -0600)]
get and convert boot time once and use as needed

5 years agodefault ps -W process start time to system boot time when inaccessible, 0, -1
Brian Inglis [Sun, 24 Mar 2019 02:22:38 +0000 (20:22 -0600)]
default ps -W process start time to system boot time when inaccessible, 0, -1

5 years agoCygwin: ctrl_c_handler: Use 64 bit timer
Corinna Vinschen [Sun, 24 Mar 2019 21:13:00 +0000 (22:13 +0100)]
Cygwin: ctrl_c_handler: Use 64 bit timer

Just don't use GetTickCount for obvious reasons

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: sys/cygwin.h: fix formatting
Corinna Vinschen [Sat, 23 Mar 2019 16:50:47 +0000 (17:50 +0100)]
Cygwin: sys/cygwin.h: fix formatting

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: strace: print windows and cygwin pid in event output
Corinna Vinschen [Sat, 23 Mar 2019 16:50:00 +0000 (17:50 +0100)]
Cygwin: strace: print windows and cygwin pid in event output

strace only printed the Windows PID in event output so far.

Especially now that Windows and Cygwin PID are decoupled, the
strace user might like to see the Cygwin pid in event output as
well.  However, at process startup, the process might not have
a Cygwin PID yet.

To mitigate this, always print the Windows PID and only add the
Cygwin pid if it exists.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: wcsxfrm_l: Only byte swap if dest size is > 0
Corinna Vinschen [Tue, 19 Mar 2019 19:56:11 +0000 (20:56 +0100)]
Cygwin: wcsxfrm_l: Only byte swap if dest size is > 0

commit c0d7d3e1a2fa96db15613cbd68a68c96966bc402 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>
5 years agoAMD GCN: Implement circular buffering.
Andrew Stubbs [Mon, 18 Mar 2019 16:18:09 +0000 (16:18 +0000)]
AMD GCN: Implement circular buffering.

The GCN port outputs stdout and stderr via a shared-memory interface.
Previously the buffer was limited to 1000 write operations, which was enough
for testing purposes, but easy to exhaust.

This patch implements a new circular buffering system allowing a greater
amount of output.  The interface must allow hundreds of hardware threads to
output simultaneously.  The new limit is UINT32_MAX write operations.

Unfortunately, there's no way to tell if the host side has also been updated.
This code will misbehave unless the gcn-run from GCC is also updated (although
it's fine the other way around), but that patch has already been committed.

OK?

Andrew Stubbs
Mentor Graphics / CodeSourcery

5 years agoCygwin: proc: fix /proc/version output after uname change
Corinna Vinschen [Mon, 18 Mar 2019 10:34:00 +0000 (11:34 +0100)]
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>
5 years agoCygwin: bump version to 3.0.5
Corinna Vinschen [Mon, 18 Mar 2019 10:29:00 +0000 (11:29 +0100)]
Cygwin: bump version to 3.0.5

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoAdd semihosting docs for nios2 and m68k cygwin-3_0_4-release
Jeff Johnston [Thu, 14 Mar 2019 14:23:25 +0000 (10:23 -0400)]
Add semihosting docs for nios2 and m68k

Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Wed Mar 13 20:22:16 2019 -0700

    Add semihosting documentation for nios2 and m68k.

    QEMU maintainers have asked for a specification of the nios2
    semihosting interface.  Since it's essentially a copy of the m68k
    implementation, this patch adds a document for that target as well.

5 years agoCygwin: acls: allow converting empty acl to text
Corinna Vinschen [Wed, 13 Mar 2019 11:06:48 +0000 (12:06 +0100)]
Cygwin: acls: allow converting empty acl to text

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: proc: add missing LF to /proc/<PID>/stat output
Corinna Vinschen [Wed, 13 Mar 2019 10:26:58 +0000 (11:26 +0100)]
Cygwin: proc: add missing LF to /proc/<PID>/stat output

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: ps: simplify code
Corinna Vinschen [Tue, 12 Mar 2019 20:21:13 +0000 (21:21 +0100)]
Cygwin: ps: simplify code

Always use NtQuerySystemInformation(SystemProcessIdInformation).
This drops two code paths calling NtQueryInformationProcess or
GetModuleFileNameExW and only requires to open the process
to fetch system time info.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: ps: show *all* processes in ps -W output
Corinna Vinschen [Tue, 12 Mar 2019 19:55:24 +0000 (20:55 +0100)]
Cygwin: ps: show *all* processes in ps -W output

There's a long-standing bug in ps -W.  It only shows processes which ps
can open with PROCESS_QUERY_LIMITED_INFORMATION permissions.  However,
that fails for a lot of system processes. Due to that, output is
basically restricted to processes in the same session, as well as Cygwin
processes... which isn't *quite* what ps -W was supposed to do.

Basically we only need to open the process to fetch the image name.  If
that fails, utilize the undocumented SystemProcessIdInformation info
class introduced with Windows Vista, which allows to fetch the image
name by specifying the PID.  Restructure the code a bit.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: ntdll.h: Add SystemProcessIdInformation
Corinna Vinschen [Tue, 12 Mar 2019 19:11:38 +0000 (20:11 +0100)]
Cygwin: ntdll.h: Add SystemProcessIdInformation

Add SystemProcessIdInformation to SYSTEM_INFORMATION_CLASS
and define struct _SYSTEM_PROCESS_ID_INFORMATION.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: loadavg: improve debugging of load_init
Corinna Vinschen [Tue, 12 Mar 2019 16:09:42 +0000 (17:09 +0100)]
Cygwin: loadavg: improve debugging of load_init

When logging in via ssh with an unprivileged account,
PdhAddEnglishCounter returns with status 0x800007D0,
PDH_CSTATUS_NO_MACHINE.  We didn't find any workaround
but the changes to improve debugging output may help
in future.  Using UNICODE instead of ANSI functions is
a result of trying to fix this problem.

Also drop the prototype workaround for PdhAddEnglishCounterA.
It's not required anymore since Mingw-w64's pdh.h catched up.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: add /proc changes to release notes
Corinna Vinschen [Tue, 12 Mar 2019 10:47:31 +0000 (11:47 +0100)]
Cygwin: add /proc changes to release notes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fork/exec: Allow all users PROCESS_QUERY_LIMITED_INFORMATION
Corinna Vinschen [Tue, 12 Mar 2019 10:41:35 +0000 (11:41 +0100)]
Cygwin: fork/exec: Allow all users PROCESS_QUERY_LIMITED_INFORMATION

Create process with standard rights, plus
PROCESS_QUERY_LIMITED_INFORMATION for authenticated users.  This
allows to fetch basic process information and thus /proc/<PID>/stat
to succeed on foreign processes.

While at it, fix formatting in CreateProcess calls.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: proc: let stat info always succeed
Corinna Vinschen [Tue, 12 Mar 2019 10:34:50 +0000 (11:34 +0100)]
Cygwin: proc: let stat info always succeed

There's no good reason to return blank if some of the info
couldn't be collected.  Drop useless call collecting
SystemProcessorPerformanceInformation.  Always return some
valid start_time, even if we couldn't collect ProcessTimes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: proc: don't request PROCESS_VM_READ perms for stat
Corinna Vinschen [Tue, 12 Mar 2019 10:20:42 +0000 (11:20 +0100)]
Cygwin: proc: don't request PROCESS_VM_READ perms for stat

The OpenProcess call to generate /proc/<PID>/stat info requests
PROCESS_VM_READ, but that's not required.  Drop it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: proc: return more useful cmdline
Corinna Vinschen [Tue, 12 Mar 2019 10:17:11 +0000 (11:17 +0100)]
Cygwin: proc: return more useful cmdline

Creating /proc/<PID>/cmdline requires permissions to communicate
with the target process via its signal pipe.  If that fails, the
output is "<defunct>" which doesn't make sense most of the time.
Rather, call format_process_exename in this case to get more useful
process name info, albeit not the full cmdline.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fix permissions of winpid symlinks
Corinna Vinschen [Mon, 11 Mar 2019 20:40:04 +0000 (21:40 +0100)]
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>
5 years agoCygwin: bump version to 3.0.4
Corinna Vinschen [Sat, 9 Mar 2019 19:13:50 +0000 (20:13 +0100)]
Cygwin: bump version to 3.0.4

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: posix timers: fix a deadlock cygwin-3_0_3-release
Corinna Vinschen [Fri, 8 Mar 2019 11:51:10 +0000 (12:51 +0100)]
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>
5 years agoCygwin: posix timers: fix resource leak
Corinna Vinschen [Wed, 6 Mar 2019 21:17:32 +0000 (22:17 +0100)]
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>
5 years agoCygwin: bump version to 3.0.3
Corinna Vinschen [Tue, 5 Mar 2019 19:00:30 +0000 (20:00 +0100)]
Cygwin: bump version to 3.0.3

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: seteuid: do not verify lsaprivkeyauth token cygwin-3_0_2-release
Corinna Vinschen [Mon, 4 Mar 2019 19:30:37 +0000 (20:30 +0100)]
Cygwin: seteuid: do not verify lsaprivkeyauth token

We don't support setting groups via /etc/groups anymore.  Also, the
initgroups group list is created via S4U, so we have "Interactive" vs.
"Network" token, an artificial and entirely irrelevant difference.

So,  "verifying" the lsaprivkeyauth token may lead to rejecting a prefectly
valid token.  Just remove the verify_token call.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoRevert "Cygwin: load_user_profile: temporarily extend debug output"
Corinna Vinschen [Mon, 4 Mar 2019 13:58:45 +0000 (14:58 +0100)]
Revert "Cygwin: load_user_profile: temporarily extend debug output"

This reverts commit 6aef5a46d7f22841e6a859103bb3f8acea060b84.

5 years agoCygwin: Revert attempting to unload user profile after use
Corinna Vinschen [Mon, 4 Mar 2019 16:07:31 +0000 (17:07 +0100)]
Cygwin: Revert attempting to unload user profile after use

Revert "Cywin: user profile: unload impersonation user profile on exit"
Revert "Cygwin: seteuid: allow inheriting impersonation user profile handle"
Revert "Cygwin: user profile: add debug output to unload_user_profile"
Revert "Cygwin: user profile: Make an effort to unload unused user profiles"

This reverts commit bcb33dc4f0552e749dcb6c44e1ef7815b5db75a1.
This reverts commit dd3730ed9c1c78176f1aab1b429bb5a105d90a44.
This reverts commit 8eee25241e86fc596acde25c7c53723b75afee30.
This reverts commit 71b8777a7140b79942d6e5079818cad2c3f5f07f.

This patchset actually results in the following problem:

- After a couple of ssh logon/logoff attempts, an interactive session
  of the same user loging in, is broken.

Apparently UnloadUserProfile manages to unload the user's profile
even while a parallel interactive session still uses the user's
profile.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: update 3.0.2 release file
Corinna Vinschen [Mon, 4 Mar 2019 13:14:15 +0000 (14:14 +0100)]
Cygwin: update 3.0.2 release file

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: doc: update case-sensitive dirs description
Corinna Vinschen [Mon, 4 Mar 2019 13:03:32 +0000 (14:03 +0100)]
Cygwin: doc: update case-sensitive dirs description

Since we have to disable automatic case-sensitive mkdir again,
change documentation accordingly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fork: fix child process permissions, take 3
Corinna Vinschen [Sun, 3 Mar 2019 09:59:13 +0000 (10:59 +0100)]
Cygwin: fork: fix child process permissions, take 3

Per MSDN VirtualQueryEx requires PROCESS_QUERY_INFORMATION.
Testing showed that PROCESS_QUERY_LIMITED_INFORMATION is sufficient
since Windows 8.1.  The assumption that Windows 8 is the same as
Windows 8 was not correct, it requires PROCESS_QUERY_INFORMATION
as well.

Fix that by splitting the Windows 8 wincaps into one for Windows 8
and one for Windows 8.1.  Set needs_query_information for Windows 8.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: load_user_profile: Don't give primary domain to ldap
Corinna Vinschen [Sat, 2 Mar 2019 11:47:54 +0000 (12:47 +0100)]
Cygwin: load_user_profile: Don't give primary domain to ldap

If the user domain is the primary domain, LDAP is supposed to
use the default naming context.  This is accomplished by setting
domain name to NULL in the call to cyg_ldap::fetch_ad_account.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: ldap: Fix overwriting domain when creating naming context
Corinna Vinschen [Sat, 2 Mar 2019 11:43:34 +0000 (12:43 +0100)]
Cygwin: ldap: Fix overwriting domain when creating naming context

cyg_ldap::fetch_ad_account creates a naming context from the
incoming domain, if it's not NULL.  The algorithm overwrites
dots with \0 in domain while creating the naming context, but
neglects to restore the dots.

Fix that by never overwriting the incoming domain name.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fenv.h: Add feature test macros, fix values
Corinna Vinschen [Thu, 28 Feb 2019 14:05:13 +0000 (15:05 +0100)]
Cygwin: fenv.h: Add feature test macros, fix values

- feenableexcept,fedisableexcept, fegetexcept are GNU-only
- fegetprec, fesetprec are Solaris, use __MISC_VISIBLE
- _feinitialise is Cygwin-internal only
- Replace self-named FP precision values to values from
  http://www.open-std.org/jtc1/sc22//WG14/www/docs/n752.htm
  as used by Solaris.
- Change return value of fesetprec to adhere to the above document
  and Solaris.
- Document fegetprec, fesetprec as Solaris functions, not as GNU
  functions

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: authentication: Always initialize domain info
Corinna Vinschen [Fri, 1 Mar 2019 20:08:09 +0000 (21:08 +0100)]
Cygwin: authentication: Always initialize domain info

...before calling any of its method.  It's no safe bet that
it's already initialized when calling s4uauth and adding it
to load_user_profile certainly doesn't hurt.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: load_user_profile: use local pointer when appropriate
Corinna Vinschen [Fri, 1 Mar 2019 20:05:23 +0000 (21:05 +0100)]
Cygwin: load_user_profile: use local pointer when appropriate

dnsdomain does not have to be a copy of the domain, a pointer into
cygheap is sufficient.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: load_user_profile: fix use-after-free issue
Corinna Vinschen [Fri, 1 Mar 2019 20:04:02 +0000 (21:04 +0100)]
Cygwin: load_user_profile: fix use-after-free issue

In case of a local machine account login, pi.lpProfilePath points
to the buffer returned by NetUserGetInfo, but NetApiBufferFree
is called prior to calling LoadUserProfileW.  Fix by copying over
usri3_profile to the local userpath buffer, just as in the AD case.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: load_user_profile: temporarily extend debug output
Corinna Vinschen [Fri, 1 Mar 2019 15:05:33 +0000 (16:05 +0100)]
Cygwin: load_user_profile: temporarily extend debug output

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: s4uauth: drop fallback to MsV1_0 if Kerberos fails
Corinna Vinschen [Fri, 1 Mar 2019 15:04:51 +0000 (16:04 +0100)]
Cygwin: s4uauth: drop fallback to MsV1_0 if Kerberos fails

This never really worked.  While at it, restructure code to
do common stuff only in one spot.  Improve debug output.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: Disable creating case-sensitive folders by default
Corinna Vinschen [Fri, 1 Mar 2019 13:32:08 +0000 (14:32 +0100)]
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>
5 years agoCygwin: load_user_profile: chack if we got a valid, known domainname
Corinna Vinschen [Thu, 28 Feb 2019 22:17:55 +0000 (23:17 +0100)]
Cygwin: load_user_profile: chack if we got a valid, known domainname

...otherwise we may suffer a SEGV because dnsdomain is NULL.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: wincap: fix copy/paste bug
Corinna Vinschen [Thu, 28 Feb 2019 15:55:39 +0000 (16:55 +0100)]
Cygwin: wincap: fix copy/paste bug

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: add a sleep when being debugged
Corinna Vinschen [Tue, 26 Feb 2019 09:46:05 +0000 (10:46 +0100)]
Cygwin: timerfd: add a sleep when being debugged

A sleep is required on Windows 10 64 bit only before calling
RegisterClassW in the timerfd thread, and only when running
under strace.  One of the child processes inheriting the timerfd
descriptor will get a STATUS_FLOAT_INEXACT_RESULT exception inside
of msvcrt.dll.  It's apparently some timing problem.  It occurs
in 4 out of 5 runs under strace only.  WOW64 and Windows 7 64 bit
don't have this problem.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: reduce size of shared mem region to a single page
Corinna Vinschen [Tue, 26 Feb 2019 09:19:08 +0000 (10:19 +0100)]
Cygwin: timerfd: reduce size of shared mem region to a single page

The share section was created using the PAGE_SIZE constant,
but PAGE_SIZE is 64K.  Fix that by using wincap.page_size()
instead, which returns the desired actual page size of 4K.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: use NULL security descriptor in InitializeObjectAttributes
Corinna Vinschen [Mon, 25 Feb 2019 20:06:15 +0000 (21:06 +0100)]
Cygwin: use NULL security descriptor in InitializeObjectAttributes

Using sec_none{_nih} is just a roundabout way to specify a
NULL SD.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: rework implementation
Corinna Vinschen [Mon, 25 Feb 2019 19:58:12 +0000 (20:58 +0100)]
Cygwin: timerfd: rework implementation

timerfd_tracker and timerfd_shared classes:

- Just because handles are shared, we don't have to store them in
  shared memory.  Move share handles into timerfd_tracker class.

- Drop shared instance counter since it's not required anymore.
  timerfd_shared only stores the actual timer data.

- Drop timerfd_shared::create, just set clock id.

- Drop timerfd_shared::dtor, it's not required anymore.

- Drop timerfd_tracker::close, just call dtor where required.

- Rename timerfd_tracker::increment_instances to timerfd_tracker::dup.
  It's the only reason it exists...

- timerfd_tracker::dtor now checks the non-shared pointers for NULL
  before attempting to close them.

- timerfd_tracker::dtor handles decrementing the local instance count
  by itself.

- Add a method timerfd_tracker::init_fixup_after_fork_exec to set
  non-shared pointers to NULL.  Together with the dtor patches it
  fixes a problem with close_on_exec timerfd descriptors.

- Fix a bug in handling the thread synchronization event.  It's
  actually nice to create it before using it...

- Drop using sec_none{_nih} in InitializeObjectAttributes.  It's
  an unnecessary roundabout route just to get a NULL pointer.

- Slightly rework timechange window handling.

- Add more comments to explain what happens.

fhandler_timerfd:

- Drop cnew macro, it just hides what happens.

- fhandler_timerfd::fixup_after_exec now calls
  timerfd_tracker::init_fixup_after_fork_exec first, so a subsequent
  call to timerfd_tracker::dtor only works on valid handles.

- fhandler_timerfd::close directly calls timerfd_tracker::dtor now.

- Drop dtor call in fhandler_timerfd destructor.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: fix shared memory allocation in fork/exec
Corinna Vinschen [Sun, 24 Feb 2019 19:15:36 +0000 (20:15 +0100)]
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>
5 years agoCygwin: POSIX timers: Fix timer values returned for unarmed timer
Corinna Vinschen [Sun, 24 Feb 2019 09:12:03 +0000 (10:12 +0100)]
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>
5 years agoCygwin: Add 3.0.2 release file
Corinna Vinschen [Sat, 23 Feb 2019 22:07:42 +0000 (23:07 +0100)]
Cygwin: Add 3.0.2 release file

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: fix select always returning immediately
Corinna Vinschen [Sat, 23 Feb 2019 22:02:44 +0000 (23:02 +0100)]
Cygwin: timerfd: fix select always returning immediately

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCywin: user profile: unload impersonation user profile on exit
Corinna Vinschen [Sat, 23 Feb 2019 20:06:12 +0000 (21:06 +0100)]
Cywin: user profile: unload impersonation user profile on exit

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: seteuid: allow inheriting impersonation user profile handle
Corinna Vinschen [Sat, 23 Feb 2019 19:48:59 +0000 (20:48 +0100)]
Cygwin: seteuid: allow inheriting impersonation user profile handle

The child process needs access to the handle to be able to
unload it when switching user context.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: user profile: add debug output to unload_user_profile
Corinna Vinschen [Sat, 23 Feb 2019 19:46:48 +0000 (20:46 +0100)]
Cygwin: user profile: add debug output to unload_user_profile

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: user profile: Make an effort to unload unused user profiles
Corinna Vinschen [Sat, 23 Feb 2019 16:30:44 +0000 (17:30 +0100)]
Cygwin: user profile: Make an effort to unload unused user profiles

Does this work?  There's not much feedback given.

TODO: We might want to try unloading the user profile at process
exit as well, FWIW.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: cygheap: drop unnecessary code closing curr_primary_token
Corinna Vinschen [Sat, 23 Feb 2019 16:29:42 +0000 (17:29 +0100)]
Cygwin: cygheap: drop unnecessary code closing curr_primary_token

curr_primary_token is either NO_IMPERSONATION or the external_token
or the internal_token, so it's never required to be closed by itself.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: cygheap: better comment impersonation tokens
Corinna Vinschen [Sat, 23 Feb 2019 16:28:12 +0000 (17:28 +0100)]
Cygwin: cygheap: better comment impersonation tokens

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: seteuid32: don't use INVALID_HANDLE_VALUE
Corinna Vinschen [Sat, 23 Feb 2019 16:24:05 +0000 (17:24 +0100)]
Cygwin: seteuid32: don't use INVALID_HANDLE_VALUE

NULL is the natural state of an unused handle

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: user profile: fetch roaming profile path via LDAP
Corinna Vinschen [Sat, 23 Feb 2019 16:22:44 +0000 (17:22 +0100)]
Cygwin: user profile: fetch roaming profile path via LDAP

Commit 649911fb40e45bc9a1ad8a3c28d90eec78c9cb7f avoids the
calls to NetUserGetGroups and NetUserGetLocalGroups since
these can take a lot of time.  The same problem potentially
occurs when loading the user profile.  The code fetches
the roaming profile path calling NetUserGetInfo, which also
can be rather slow.

To avoid this problem, fetch the profile patch using LDAP.
Also, don't bail out early if the user's registry hive already
exists.  This may result in outdated information.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: get_user_groups: fetch a user's group list from identification token
Corinna Vinschen [Fri, 22 Feb 2019 17:31:03 +0000 (18:31 +0100)]
Cygwin: get_user_groups: fetch a user's group list from identification token

NetUserGetGroups and NetUserGetLocalGroups sometimes take a lot of time
(up to more than 2 mins) for no apparent reason.

Call s4uauth to generate an identification token for the user and fetch
the group list from there.  This is *much* faster.

Keep the old code only for the sake of WOW64 on Vista and Windows 7,
which don't implement MsV1_0S4ULogon.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: s4uauth: allow to be called for identification only
Corinna Vinschen [Fri, 22 Feb 2019 17:27:38 +0000 (18:27 +0100)]
Cygwin: s4uauth: allow to be called for identification only

s4uath was only callable to create an impersonation token so
far.  Rework the function to allow creating an identification
token for informational purposes even from untrusted processes.

Take domainname and username instead of a passwd pointer to be
more multi-purpose.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: drop unused parameter from get_user_local_groups
Corinna Vinschen [Fri, 22 Feb 2019 12:36:13 +0000 (13:36 +0100)]
Cygwin: drop unused parameter from get_user_local_groups

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: passwd/group: drop fetching case-correct group names from LDAP
Corinna Vinschen [Fri, 22 Feb 2019 10:04:34 +0000 (11:04 +0100)]
Cygwin: passwd/group: drop fetching case-correct group names from LDAP

Commit 4e34a39b5cdf4c3f889486b7460bea063e579d10 made sure all user and
group names are case-correct, but it introduced a hefty performance hit
on starting the first Cygwin process.

Adding an ldap call for each AD group in a user token takes its toll in
bigger AD environments with lots of groups in a user token.  Real-life
example: 300 groups w/ roundtrip time to the LDAP server of 0.25 secs
per call...

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agostdio: drop unused O_TEXT handling on non-Cygwin
Corinna Vinschen [Fri, 22 Feb 2019 20:52:22 +0000 (21:52 +0100)]
stdio: drop unused O_TEXT handling on non-Cygwin

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fetch local groups from local machine
Corinna Vinschen [Thu, 21 Feb 2019 23:13:57 +0000 (00:13 +0100)]
Cygwin: fetch local groups from local machine

...even for domain accounts, otherwise local group membership is ignored.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: bump version to 3.0.2
Corinna Vinschen [Thu, 21 Feb 2019 23:13:06 +0000 (00:13 +0100)]
Cygwin: bump version to 3.0.2

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: document secure_getenv cygwin-3_0_1-release
Yaakov Selkowitz [Tue, 19 Feb 2019 20:34:18 +0000 (14:34 -0600)]
Cygwin: document secure_getenv

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
5 years agoCygwin: add secure_getenv
Yaakov Selkowitz [Tue, 19 Feb 2019 05:06:11 +0000 (23:06 -0600)]
Cygwin: add secure_getenv

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
5 years agoCygwin: sys/mount.h: fix comment
Corinna Vinschen [Tue, 19 Feb 2019 18:34:40 +0000 (19:34 +0100)]
Cygwin: sys/mount.h: fix comment

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoDefine u_register_t if __BSD_VISIBLE
Sebastian Huber [Mon, 18 Feb 2019 08:41:13 +0000 (09:41 +0100)]
Define u_register_t if __BSD_VISIBLE

Add u_register_t definition for FreeBSD compatibility.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
5 years agoChange register_t definition
Sebastian Huber [Mon, 18 Feb 2019 08:39:02 +0000 (09:39 +0100)]
Change register_t definition

On 64-bit targets, the register_t type must be a 64-bit integer.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
5 years agoFix comment in <sys/types.h>
Sebastian Huber [Mon, 18 Feb 2019 08:38:36 +0000 (09:38 +0100)]
Fix comment in <sys/types.h>

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
5 years agoMove RTEMS and XMK specific type definitions
Sebastian Huber [Wed, 13 Feb 2019 12:42:57 +0000 (13:42 +0100)]
Move RTEMS and XMK specific type definitions

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
5 years agoCygwin: s4uauth: convert token to primary token
Corinna Vinschen [Mon, 18 Feb 2019 20:45:34 +0000 (21:45 +0100)]
Cygwin: s4uauth: convert token to primary token

Up to Vista CreateProcessAsUser only worked with primary tokens,
so convert S4U impersonation token to primary token.  MSDN still
documents it that way, but actually an impersonation token is
sufficient since Windows 7.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: re-enable create_token for older systems
Corinna Vinschen [Mon, 18 Feb 2019 20:00:59 +0000 (21:00 +0100)]
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>
5 years agoCygwin: s4uauth: make sure to fetch correct package id
Corinna Vinschen [Mon, 18 Feb 2019 16:59:56 +0000 (17:59 +0100)]
Cygwin: s4uauth: make sure to fetch correct package id

for domain accounts we try KerbS4ULogon first, MsV1_0S4ULogon
second.  But we only fetch the package id for the supporting
authentication package (Kerberos/MsV1_0) once at the start.

Duplicate LsaLookupAuthenticationPackage call and move into the
Kerb/MsV1_0 branches so that it fetches the correct package id
for the method we call next.

Curious enough this worked before.  Apparently both methods
work with the MICROSOFT_KERBEROS_NAME_A package id.  However,
requesting and using the right authentication package id is
the prudent thing to do.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCYgwin: bump API minor for MOUNT_BINARY -> MOUNT_TEXT change
Corinna Vinschen [Mon, 18 Feb 2019 10:04:38 +0000 (11:04 +0100)]
CYgwin: bump API minor for MOUNT_BINARY -> MOUNT_TEXT change

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: utils: MOUNT_BINARY -> MOUNT_TEXT
Corinna Vinschen [Mon, 18 Feb 2019 10:00:06 +0000 (11:00 +0100)]
Cygwin: utils: MOUNT_BINARY -> MOUNT_TEXT

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoRevert "Cygwin: passwd/group: allow specifying "." as local computername"
Corinna Vinschen [Mon, 18 Feb 2019 09:13:35 +0000 (10:13 +0100)]
Revert "Cygwin: passwd/group: allow specifying "." as local computername"

This reverts commit 7c34811440be0bf1e749d9f075f54320c706cb4b.

This potentially allows to circumvent OpenSSHs user/group name matching,
unless the Admin knows to add every local user twice or to use patterns,
e.g.:

  Match user MACHINE+user,.+user
  Match user *+user

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: mount: define binary mount as default
Corinna Vinschen [Mon, 18 Feb 2019 09:12:07 +0000 (10:12 +0100)]
Cygwin: mount: define binary mount as default

Commit c1023ee353705671aa9a8e4e1179022277add2aa 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>
5 years agoCygwin: mount: remove unused method mount_info::set_flags_from_win32_path
Corinna Vinschen [Mon, 18 Feb 2019 09:03:19 +0000 (10:03 +0100)]
Cygwin: mount: remove unused method  mount_info::set_flags_from_win32_path

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: utils: kill: revert erroneously removed optind correction
Corinna Vinschen [Sun, 17 Feb 2019 21:59:36 +0000 (22:59 +0100)]
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
8de660271fe75a6993f1c9888d24b824bb7f999d.  Revert that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fork: add PROCESS_VM_OPERATION to child process permissions
Corinna Vinschen [Sun, 17 Feb 2019 21:51:21 +0000 (22:51 +0100)]
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>
5 years agoCygwin: passwd/group: allow specifying "." as local computername
Corinna Vinschen [Sat, 16 Feb 2019 17:36:21 +0000 (18:36 +0100)]
Cygwin: passwd/group: allow specifying "." as local computername

Convenience only.  The resulting passwd/group antry is still
fully qualified.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: bump version to 3.0.1
Corinna Vinschen [Sat, 16 Feb 2019 17:11:16 +0000 (18:11 +0100)]
Cygwin: bump version to 3.0.1

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: passwd/group: store account name case correct, take 2 cygwin-3_0_0-release
Corinna Vinschen [Wed, 13 Feb 2019 12:16:15 +0000 (13:16 +0100)]
Cygwin: passwd/group: store account name case correct, take 2

The solution from commit  9a3cc77b2afc52a2faa5e4daeb59dfd4506c0693
didn't work for foreign domain accounts.  Rather than calling
LookupAccountSid we now use the info when we fetch it anyway
via LDAP or Net*GetInfo.  Only in case of domain groups we have
to add an LDAP call explicitly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: ldap.cc: fix formatting
Corinna Vinschen [Wed, 13 Feb 2019 11:43:25 +0000 (12:43 +0100)]
Cygwin: ldap.cc: fix formatting

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: passwd/group: rename get_group_name to get_account_name
Corinna Vinschen [Wed, 13 Feb 2019 11:42:56 +0000 (12:42 +0100)]
Cygwin: passwd/group: rename get_group_name to get_account_name

The function is the same for user and grou accounts.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: passwd/group: raise local name buffer size
Corinna Vinschen [Wed, 13 Feb 2019 11:41:55 +0000 (12:41 +0100)]
Cygwin: passwd/group: raise local name buffer size

Make sure a domain+username fits into the local name buffer.
The former buffer size didn't take adding a domain name to
a really_really_long_user_name into account.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: passwd/group: store account name case correct
Corinna Vinschen [Wed, 13 Feb 2019 10:10:55 +0000 (11:10 +0100)]
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>
This page took 0.068669 seconds and 5 git commands to generate.