Commit Graph

7962 Commits

Author SHA1 Message Date
Corinna Vinschen 49505a907f Cygwin: pthread_cond_wait: Do as Linux and BSD do.
POSIX states as follows about pthread_cond_wait:
If a signal is delivered to a thread waiting for a condition variable,
upon return from the signal handler the thread resumes waiting for the
condition variable as if it was not interrupted, or it returns zero
due to spurious wakeup.

Cygwin so far employs the latter behaviour, while Linux and BSD employ
the former one.

Align Cygwin behaviour to Linux and BSD.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-07 15:15:47 +01:00
Corinna Vinschen 88443b0a22 cwdstuff: Don't leave from setting the CWD prematurely on init
There are certain, very obscure scenarios, which render the Windows
CWD handle inaccessible for reopening.  An easy one is, the handle can
be NULL if the permissions of the CWD changed under the parent processes
feet.

Originally we just set errno and returned, but in case of init at
process startup that left the "posix" member NULL and subsequent
calls to getcwd failed with EFAULT.

We now check for a NULL handle and change the reopen approach
accordingly.  If that doesn't work, try to duplicate the handle instead.
If duplicating fails, too, we set the dir handle to NULL and carry on.
This will at least set posix to some valid path and subsequent getcwd
calls won't fail.  A NULL dir handle is ok, because we already do this
for virtual paths.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-03 13:55:55 +01:00
David Allsopp 226f69422a Preserve order of dlopen'd modules in dll_list::topsort
This patch alters the behaviour of dll_list::topsort to preserve the
order of dlopen'd units.

The load order of unrelated DLLs is reversed every time fork is called,
since dll_list::topsort finds the tail of the list and then unwinds to
reinsert items. My change takes advantage of what should be undefined
behaviour in dll_list::populate_deps (ndeps non-zero and ndeps and deps
not initialised) to allow the deps field to be initialised prior to the
call and appended to, rather than overwritten.

All DLLs which have been dlopen'd have their deps list initialised with
the list of all previously dlopen'd units. These extra dependencies mean
that the unwind preserves the order of dlopen'd units.

The motivation for this is the FlexDLL linker used in OCaml. The FlexDLL
linker allows a dlopen'd unit to refer to symbols in previously dlopen'd
units and it resolves these symbols in DllMain before anything else has
initialised (including the Cygwin DLL). This means that dependencies may
exist between dlopen'd units (which the OCaml runtime system
understands) but which Windows is unaware of. During fork, the
process-level table which FlexDLL uses to get the symbol table of each
DLL is copied over but because the load order of dlopen'd DLLs is
reversed, it is possible for FlexDLL to attempt to access memory in the
DLL before it has been loaded and hence it fails with an access
violation. Because the list is reversed on each call to fork, it means
that a subsequent call to fork puts the DLLs back into the correct
order, hence "even" invocations of fork work!

An interesting side-effect is that this only occurs if the DLLs load at
their preferred base address - if they have to be rebased, then FlexDLL
works because at the time that the dependent unit is loaded out of
order, there is still in memory the "dummy" DONT_RESOLVE_DLL_REFERENCES
version of the dependency which, as it happens, will contain the correct
symbol table in the data section. For my tests, this initially appeared
to be an x86-only problem, but that was only because the two DLLs on x64
should have been rebased.

Signed-off-by: David Allsopp <david.allsopp@metastack.com>
2017-02-28 16:12:03 +01:00
Corinna Vinschen 45d3296d0d Add 2.7.1 release file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-02-24 20:57:02 +01:00
Corinna Vinschen fa9d3148bf Bump Cygwin version to 2.7.1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-02-24 20:51:50 +01:00
Michael Haubenwallner 829aaa7352 fix parallel build for version.cc and winver.o
Creating both version.cc and winver.o at once really should run once only.
2017-02-16 21:14:39 +01:00
Yaakov Selkowitz e704ab2470 Cygwin: create separate bits/byteswap.h
Match glibc behaviour to expose the public bswap_* macros only with an
explicity #include <byteswap.h>; #include'ing <endian.h> should not expose
them.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-02-08 17:01:34 -06:00
Corinna Vinschen a9f4b71e8e Add release message for commit 609d2b2
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-02-03 21:54:25 +01:00
Corinna Vinschen 609d2b22af Fix limited Internet speeds caused by inappropriate socket buffering
Don't set SO_RCVBUF/SO_SNDBUF to fixed values, thus disabling autotuning.

Patch modeled after a patch suggestion from Daniel Havey <dhavey@gmail.com>
in https://cygwin.com/ml/cygwin-patches/2017-q1/msg00010.html:

At Windows we love what you are doing with Cygwin.  However, we have
been getting reports from our hardware vendors that iperf is slow on
Windows.  Iperf is of course compiled against the cygwin1.dll and we
believe we have traced the problem down to the function fdsock in
net.cc.  SO_RCVBUF and SO_SNDBUF are being manually set.  The comments
indicate that the idea was to increase the buffer size, but, this code
must have been written long ago because Windows has used autotuning
for a very long time now.  Please do not manually set SO_RCVBUF or
SO_SNDBUF as this will limit your internet speed.

I am providing a patch, an STC and my cygcheck -svr output.  Hope we
can fix this.  Please let me know if I can help further.

Simple Test Case:
I have a script that pings 4 times and then iperfs for 10 seconds to
debit.k-net.fr

With patch
$ bash buffer_test.sh 178.250.209.22
usage: bash buffer_test.sh <iperf server name>

Pinging 178.250.209.22 with 32 bytes of data:
Reply from 178.250.209.22: bytes=32 time=167ms TTL=34
Reply from 178.250.209.22: bytes=32 time=173ms TTL=34
Reply from 178.250.209.22: bytes=32 time=173ms TTL=34
Reply from 178.250.209.22: bytes=32 time=169ms TTL=34

Ping statistics for 178.250.209.22:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 167ms, Maximum = 173ms, Average = 170ms
------------------------------------------------------------
Client connecting to 178.250.209.22, TCP port 5001
TCP window size: 64.0 KByte (default)
------------------------------------------------------------
[  3] local 10.137.196.108 port 58512 connected with 178.250.209.22 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec   768 KBytes  6.29 Mbits/sec
[  3]  1.0- 2.0 sec  9.25 MBytes  77.6 Mbits/sec
[  3]  2.0- 3.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  3.0- 4.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  4.0- 5.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  5.0- 6.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  6.0- 7.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  7.0- 8.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  8.0- 9.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  9.0-10.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  0.0-10.0 sec   154 MBytes   129 Mbits/sec

Without patch:
dahavey@DMH-DESKTOP ~
$ bash buffer_test.sh 178.250.209.22

Pinging 178.250.209.22 with 32 bytes of data:
Reply from 178.250.209.22: bytes=32 time=168ms TTL=34
Reply from 178.250.209.22: bytes=32 time=167ms TTL=34
Reply from 178.250.209.22: bytes=32 time=170ms TTL=34
Reply from 178.250.209.22: bytes=32 time=169ms TTL=34

Ping statistics for 178.250.209.22:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 167ms, Maximum = 170ms, Average = 168ms
------------------------------------------------------------
Client connecting to 178.250.209.22, TCP port 5001
TCP window size:  208 KByte (default)
------------------------------------------------------------
[  3] local 10.137.196.108 port 58443 connected with 178.250.209.22 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec   512 KBytes  4.19 Mbits/sec
[  3]  1.0- 2.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  2.0- 3.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  3.0- 4.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  4.0- 5.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  5.0- 6.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  6.0- 7.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  7.0- 8.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  8.0- 9.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  9.0-10.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  0.0-10.1 sec  14.1 MBytes  11.7 Mbits/sec

The output shows that the RTT from my machine to the iperf server is
similar in both cases (about 170ms) however with the patch the
throughput averages 129 Mbps while without the patch the throughput
only averages 11.7 Mbps.  If we calculate the maximum throughput using
Bandwidth = Queue/RTT we get (212992 * 8)/0.170 = 10.0231 Mbps.  This
is just about what iperf is showing us without the patch since the
buffer size is set to 212992 I believe that the buffer size is
limiting the throughput.  With the patch we have no buffer limitation
(autotuning) and can develop the full potential bandwidth on the link.

If you want to duplicate the STC you will have to find an iperf server
(I found an extreme case) that has a large enough RTT distance from
you and try a few times.  I get varying results depending on Internet
traffic but without the patch never exceed the limit caused by the
buffering.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-02-03 21:51:45 +01:00
Jon Turney 06e7f0074c Add release message for commit a1529738
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2017-01-31 20:16:37 +00:00
Corinna Vinschen aade9a4fe1 Add release message for commit 095cac4
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-31 15:40:03 +01:00
Corinna Vinschen 095cac4b8d Cygwin: Add IUTF8 termios iflag
The termios code doesn't handle erasing of multibyte characters
in canonical mode, it always erases a single byte.  When entering
a multibyte character and then pressing VERASE, the input ends up
with an invalid character.

Following Linux we introduce the IUTF8 input flag now, set by
default.  When this flag is set, VERASE or VWERASE will check
if the just erased input byte is a UTF-8 continuation byte.  If
so, it erases another byte and checks again until the entire
UTF-8 character has been removed from the input buffer.

Note that this (just as on Linux) does NOT work with arbitrary
multibyte codesets.  This only works with UTF-8.

For a discussion what happens, see
https://cygwin.com/ml/cygwin/2017-01/msg00299.html

Sidenote: The eat_readahead function is now member of fhandler_termios,
not fhandler_base.  That's necessary to get access to the terminal's
termios flags.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-31 15:36:24 +01:00
Corinna Vinschen dfbc941f7e Add release message for commit ca3e3bc
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-20 10:33:12 +01:00
Corinna Vinschen ef00718487 Cleanup fhandler_console::read for readability
- Drop virtual_key_code (only used once)
- Convert macros wch and control_key_state to const vars
  unicode_char and  ctrl_key_state.
- Fix formatting

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:58:05 +01:00
Corinna Vinschen dd7c87ae87 miscfuncs.cc: Revert exclusion of inclusion of exception.h
x86 still needs it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:51:38 +01:00
Corinna Vinschen 3b7b65b2f8 Simplify check for Alt-Numpad
Create two new inline functions is_alt_numpad_key(PINPUT_RECORD) and
is_alt_numpad_event(PINPUT_RECORD) which contain the actual checks.
Call these functions from fhandler_console::read and peek_console for
better readability.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:42:10 +01:00
Corinna Vinschen 9985cf66e9 miscfuncs.h: Drop now unneeded getentropy declaration
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:35:12 +01:00
Corinna Vinschen 19f9a9799f miscfuncs.cc: Drop unneeded includes and unused global variable
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:11:55 +01:00
Corinna Vinschen 946cd7df28 check_iovec: Change test to be more robust against invalid iovcnt values
Stop running wild if iovcnt is < 0 to begin with.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:11:22 +01:00
Corinna Vinschen e2ab9b71fa Don't assert on sum of iov_len overflowing an ssize_t
Rather return EINVAL per POSIX.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:08:53 +01:00
Corinna Vinschen abfcf32732 Move string functions from miscfunc.cc to strfuncs.cc
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:02:16 +01:00
Corinna Vinschen bbf6993a2d Move getentropy/getrandom into own file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 20:58:06 +01:00
Corinna Vinschen e6e66224f3 Fix copy/paste buglet in comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 19:22:47 +01:00
Corinna Vinschen dd353aa688 Add release message for commit 4652cc4
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 19:01:09 +01:00
Corinna Vinschen 4652cc4384 Handle Alt+Numpad key sequences in console input and select
{p}select/{p}poll completely ignored Alt+Numpad key sequences in console
input which results in newer readline using pselect to fail handling such
sequences correctly.  See https://cygwin.com/ml/cygwin/2017-01/msg00135.html

During debugging and testing it turned out that while reading console
input, single key presses during an Alt+Numpad sequences where not
ignored, so ultimately a sequence like

  Alt-down Numpad-1 Numpad-2 Numpad-3

whihc is supposed to result in a single character in the input stream
will actually result in 4 chars in the input stream, three control
sequences and the actual character.

Both problems should be fixed by this patch.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 18:59:48 +01:00
Corinna Vinschen 411882e2fa Add release message for commit 688d943
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-14 16:47:47 +01:00
Corinna Vinschen 688d943a52 Always try to write complete incoming buffer on pipes and fifos
This patch fixes the following problem:

Commit 9636c426 refactored the pipe code especially to make sure
to call WriteFile only with chunks matching the maximum atomic write
count.  This accidentally introduced a small change in behaviour
on blocking pipes due to the success case falling through into the
error case.  Rather then writing atomic chunks until all bytes are
written, the code immediately broke from the loop after writing
the first chunk, basically the same as in case of non-blocking
writes.  This behaviour is not compliant to POSIX which requires

 "Write requests to a pipe or FIFO [...]

  * If the O_NONBLOCK flag is clear, a write request may cause the
    thread to block, but on normal completion it shall return nbyte."

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-14 16:29:06 +01:00
Corinna Vinschen 677ffdc247 Add release message for commit 6ed4753
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-12 22:46:21 +01:00
Corinna Vinschen 6ed4753e77 rename: Refactor "new file already exists and rename fails" case
If newfile already exists and is in use, trying to overwrite it with
NtSetInformationFile(FileRenameInformation) fails exactly as if we
don't have the permissions to delete it.  Unfortunately the return code
is the same STATUS_ACCESS_DENIED, so we have no way to distinguish
these cases.  What we do here so far is to start a transaction to delete
newfile.  If this open fails with a transactional error we stop the
transaction and retry opening the file without transaction.

But, here's the problem: If newfile is in use, NtOpenFile(oldfile)
naturally does NOT fail with a transactional error.  Rather, the
subsequent call to unlink_nt(newfile) does, because there's another
handle open to newfile outside a transaction.  However, the code does
not check if unlink_nt fails with a transactional error and so fails
to retry without transaction.

This patch recifies the problem and checks unlink_nt's status as well.

Refactor code to get rid of goto into another code block.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-12 22:42:11 +01:00
Johannes Schindelin e5cadbfdcd FAST_CWD: adjust the initial search scope
A *very* recent Windows build adds more code to the preamble of
RtlGetCurrentDirectory_U() so that the previous heuristic failed to find
the call to the locking routine.

This only affects the 64-bit version of ntdll, where the 0xe8 byte is
now found at offset 40, not the 32-bit version. However, let's just
double the area we search for said byte for good measure.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-01-12 09:10:30 +01:00
Corinna Vinschen 171046da73 Fix formatting in pinfo.cc
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-10 16:38:01 +01:00
Corinna Vinschen 0a4ec0cc93 Document latest Cygwin changes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-10 16:33:21 +01:00
Erik M. Bray 5bebfa17c5 Add a /proc/<pid>/environ proc file handler, analogous to /proc/<pid>/cmdline. 2017-01-10 16:24:50 +01:00
Erik M. Bray 578bbc3a29 Add a _pinfo.environ() method analogous to _pinfo.cmdline(), and others.
Returns the process's environment concatenated into a single block of
null-terminated strings, along with the length of the environment block.

Adds an associated PICOM_ENVIRON commune_process handler.
2017-01-10 16:24:50 +01:00
Erik M. Bray 7fd70a9706 Move the core environment parsing of environ_init into a new win32env_to_cygenv function.
win32env_to_cygwenv handles converting wchar to char and some other
minor taks.  Optionally it handles converting any paths in variables to
posix paths.

This will be useful for implementing /proc/<pid>/environ
2017-01-10 16:24:50 +01:00
Erik M. Bray 387521976d Return the correct value for getsockopt(SO_REUSEADDR) after setting setsockopt(SO_REUSEADDR, 1). 2017-01-09 17:50:39 +01:00
Corinna Vinschen 838cfa352c Don't free statically allocated sys_privs
commit 67fd2101 introduced a bad bug.  Changing sys_privs to a static
area and just returning a pointer is nice... *if* the calling code doesn't
call free() on it.  Make sure callers check pointer for sys_privs and
refrain from calling free, if so.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-09 14:02:19 +01:00
Corinna Vinschen 4e75d7f504 Export getentropy and getrandom calls
getentropy per OpenBSD

  http://man.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man2/getentropy.2

getrandom per Linux

  http://man7.org/linux/man-pages/man2/getrandom.2.html

  Note that GRND_NONBLOCK is not handled
2016-12-16 23:10:19 +01:00
Corinna Vinschen 86fc4bf065 Define RtlGenRandom correctly in ntsecapi.h wrapper
Include ntsecapi.h where required and just redefine RtlGenRandom
correctly in the ntsecapi.h wrapper.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-12-14 14:14:28 +01:00
Corinna Vinschen 74f7872f89 Rearrange RNG code slightly
In preparation of exporting getentropy/getrandom to userspace, rearrange
code a bit:

- Define RtlGenRandom in ntdll.h.

- Drop calls to getentropy in favor of RtlGenRandom (fhandler_socket,
  fhandler_dev_random).

- Add try/except blocks in fhandler_dev_random to return EFAULT rather
  than crashing if buffer pointer is invalid.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-12-13 22:59:31 +01:00
Corinna Vinschen 80f4987f02 Cygwin: Add release messages for last two checkins
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-12-13 12:49:02 +01:00
Corinna Vinschen 563dda8259 Fix incorrect path conversion on non-existent files on network shares
NtOpenFile/NtCreateFile on non-existent paths on network drives has a
bug.  Assuming a path Z:\dir\file.  Further assuming that Z:\dir does
not exist.

The first NtOpenFile("Z:\dir\file") correctly returns
STATUS_OBJECT_PATH_NOT_FOUND.  Subsequent calls incorrectly
return STATUS_OBJECT_NAME_NOT_FOUND.

This appears to be some kind of caching behaviour.  Waiting a while
before repeating the call correctly returns STATUS_OBJECT_PATH_NOT_FOUND
again.

This patch works around the observed misbehaviour.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-12-13 12:48:05 +01:00
Corinna Vinschen 937a2d92e2 Check for .exe file in cygwin_conv_path
So far, when converting from POSIX to Windows notation, cygwin_conv_path
fails to check for .exe suffix, so /path/foo did not return /path/foo.exe
even if this file exists.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-12-13 12:21:27 +01:00
Corinna Vinschen 72ee64045b Cygwin 2.6.1: Add missing release text
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-12-06 16:11:04 +01:00
Corinna Vinschen f0ae353a4f path_conv: When encountering a ".(/)+" sequence, skip *all* slashes
The original code only skipped the "./", but missed to test if more
trailing slashes are present.  This in turn leads to invalid conversion.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-28 12:33:40 +01:00
Corinna Vinschen 1c54541172 regex: Fix typo in CHaddrange
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 16:09:31 +01:00
Corinna Vinschen 59ab07f170 _pinfo::set_ctty: Check potential NULL pointer in debug_printf statement
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 15:06:51 +01:00
Corinna Vinschen 1dfffe8ef4 Eliminate unused parameter from path_conv::eq_worker
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 15:06:05 +01:00
Corinna Vinschen 6a6ae087e8 Remove redundant check for NULL pointer in cygwin_exception::dump_exception
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 14:46:57 +01:00
Corinna Vinschen 284bec3174 Fix copy/paste typo in fhandler_console::scroll_buffer_screen
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 14:43:52 +01:00
Corinna Vinschen f993cb708b Don't allow sending invalid signals from user space
Don't allow signal 0 in signal(2), sigaction(2), siginterrupt(3).
Don't allow any signal in sigqueue(3) but explicitely handle
signal 0 as in kill(2).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 14:24:07 +01:00
Corinna Vinschen e1913d218d raise: Add missing extern "C"
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 14:03:11 +01:00
Corinna Vinschen d3becf4318 login_tty: Rewrite following FreeBSD's traces
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 12:06:29 +01:00
Corinna Vinschen b56179f83a fcwd_access_t: Add missing breaks in f_cwd pointer computation
Fixes Coverity CIDs 59893/59894

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 10:53:08 +01:00
Corinna Vinschen 5d09711b1d Add comments to intentional switch fallthroughs
Clarify Coverity "Missing break in switch" messages.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 10:51:32 +01:00
Corinna Vinschen 40668dcc7c Add length check creating domain\group strings
Fix Coverity CID 153932

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 10:40:14 +01:00
Sebastian Huber 9fbd510569 Provide <memory.h>
Provide <memory.h> for all standard Newlib targets and remove
Cygwin-specific header.  Most POSIX like systems provide this historic
header.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-11-22 14:21:35 +01:00
Sebastian Huber e655d3d34b Move pthread types to <sys/_pthreadtypes.h>
This makes it possible provide operating system specific types for
<pthread.h>.  It is in line with the FreeBSD header file structure and
allows a future cleanup of <pthread.h> to not expose unrelated things
via <sys/types.h> and <unistd.h>.  Glibc uses the similar
<bits/pthreadtypes.h> for this purpose.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-11-17 11:33:15 +01:00
Corinna Vinschen ff3d980d32 Add release note for commit 8a32c24
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-17 11:11:11 +01:00
Erik M. Bray 8a32c24a7b Use allocation granularity as the 'page_size' in /proc/<pid>/status as well, for consistency with /proc/<pid>/statm 2016-11-16 15:58:15 +01:00
Erik M. Bray 6477a48cd1 statm should report memory as multiples of allocation_granularity instead of page_size
that ensures that values in statm mupltiplied by POSIX _SC_PAGESIZE give the correct values
2016-11-16 15:58:08 +01:00
Corinna Vinschen 11b7f94212 Fix ShellExecuteW comment
ShellExecuteW long path behaviour is now stable: It doesn't work since
Windows 8.1.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-24 11:23:55 +02:00
Ken Brown dda82d1a7b Add _PC_CASE_INSENSITIVE to [f]pathconf
Update the getconf utility to support the new flag as well as
_PC_POSIX_PERMISSIONS and _PC_POSIX_SECURITY.  These were previously
unsupported, probably as an oversight.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-21 13:39:02 +02:00
Jon Turney 93374181cb Fix SetThreadName with gdb 7.10 on x86
Additionally to eccefd97, we need to ensure the exception handler is
installed for the _ljfault used to implement _try/_except to get called.

Also use the correct macro for x86 conditional compilation.

Addresses https://cygwin.com/ml/cygwin/2016-09/msg00143.html

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-10-20 13:12:20 +01:00
Corinna Vinschen e3ccb68610 Don't check directories always case-insensitive in rename(2)
Long-standing problem in one of the corner cases of rename(2):
If we rename a directory a check is performed to see if newpath is
identical to oldpath or a subdir of oldpath. This check is
(accidentally? no hints anywhere in ChangeLogs or code) performed
case-insensitive for as long as we use Unicode paths and NT functions.
This leads to the problems described in
https://cygwin.com/ml/cygwin/2016-09/msg00264.html

Change this to be conditional case-sensitive as all other checks but
let's take this with a grain of salt.  There may be corner-cases in
this corner-case which require to chek parts of the path always
case-insensitive.  Off the top of my head I can't construct such a
case but that's no proof they don't exist :}

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-19 13:26:03 +02:00
Corinna Vinschen e1824aea27 Add release msg for 5a3496c
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-19 12:53:58 +02:00
Corinna Vinschen 5a3496c3e3 Fix regression in console charset handling
Commit d16a5630 dropped usage of cygheap's locale functions
	in favor of local on-the-fly usage of UTF-8 instead of ASCII.
	This allowed to use the current local rather than a fixed
	system-wide locale set at startup time.  d16a5630 just missed
	to add the ASCII->UTF-8 conversion in the console as well.

	Fixes https://cygwin.com/ml/cygwin/2016-10/msg00000.html

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-19 12:52:14 +02:00
Corinna Vinschen ba2851eeca Bump Cygwin version to 2.6.1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-19 12:52:14 +02:00
Michael Haubenwallner f763e2dc88 dlopen: on x/lib search x/bin if exe is in x/bin
On 09/02/2016 11:03 AM, Corinna Vinschen wrote:
> On Sep  2 10:46, Michael Haubenwallner wrote:
>> On 09/01/2016 03:32 PM, Corinna Vinschen wrote:
>>> You could just use the global variable program_invocation_name.  If in
>>> doubt, use the Windows path global_progname and convert it to full POSIX
>>> via cygwin_conv_path.
>>
>> Patch updated, using global_progname now.
>
> Looks good and you're right to do it this way since I just noticed
> that program_invocation_name may return a relative pathname.

Yep.

> Btw., in other calls which require the full POSIX path we use
> mount_table->conv_to_posix_path instead of cygwin_conv_path (see
> e. g. fillout_pinfo()).  It's a bit faster.  Maybe something for a
> followup patch.

No problem - attached.
This renders the original patch 4/4 valid again.

> Note for some later improvement:  I really wonder why we don't store
> the absolute POSIX path of the current executable globally yet...

Same here.

Thanks!
/haubi/

>From f7255edd33cb4abe34f27188aab8dccdfa5dd2a0 Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
Date: Wed, 31 Aug 2016 18:05:11 +0200
Subject: [PATCH 3/4] dlopen: on x/lib search x/bin if exe is in x/bin

citing https://cygwin.com/ml/cygwin-developers/2016-08/msg00020.html
> Consider the file /usr/bin/cygz.dll:
> - dlopen (libz.so)            success
> - dlopen (/usr/bin/libz.so)   success
> - dlopen (/usr/lib/libz.so)   fails

* dlfcn.c (dlopen): For dlopen("x/lib/N"), when the application
executable is in "x/bin/", search for "x/bin/N" before "x/lib/N".
2016-09-08 13:36:32 +02:00
Michael Haubenwallner b37c3ed5e5 dlopen (pathfinder): try each basename per dir
Rather than searching all search dirs per one basename,
search for all basenames within per one search dir.

pathfinder.h (check_path_access): Interchange dir- and basename-loops.
2016-09-08 13:36:31 +02:00
Michael Haubenwallner 97974e3076 dlopen: switch to new pathfinder class
Instead of find_exec, without changing behaviour use new pathfinder
class with new allocator_interface around tmp_pathbuf and new vstrlist
class.
* pathfinder.h (pathfinder): New file.
* vstrlist.h (allocator_interface, allocated_type, vstrlist): New file.
* dlfcn.cc (dlopen): Avoid redundant GetModuleHandleExW with RTLD_NOLOAD
and RTLD_NODELETE.  Switch to new pathfinder class, using
(tmp_pathbuf_allocator): New class.
(get_full_path_of_dll): Drop.
2016-09-08 13:36:29 +02:00
Corinna Vinschen 472e5439e7 Fix passwd getting error 1265 when running on newer Windows
On Windows 8.1 and later, the NetUserChangePassword call apparently
doesn't accept the usual "\\server" string anymore, but requires to
use the "domain" instead, otherwise it emits en error code 1265,
ERROR_DOWNGRADE_DETECTED.  Since this is accepted by pre-8.1 as well,
use the domain indiscriminately when calling NetUserChangePassword
from passwd(1).

While at it, do some minor cleanup in passwd.c.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-31 12:08:34 +02:00
Yaakov Selkowitz abd37f0c79 Add release message for commit 3d3ab82
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-08-30 10:53:35 -05:00
Corinna Vinschen e97109184a Drop global __ctype_ptr__ entirely in favor of using locale_t::ctype_ptr
Keep __ctype_ptr__ available on Cygwin only, for backward compatibility
with existing apps referencing it via the ctype macros.

Otherwise initialize __global_locale.ctype_ptr and __C_locale.ctype_ptr
and use them throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-25 14:18:31 +02:00
Corinna Vinschen 988629da1d Fix formatting
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-25 12:06:17 +02:00
Jon Turney eccefd9704 Fix SetThreadName with current gdb
Wrap SetThreadName()'s call to RaiseException() in __try/__except/__endtry,
so that if the attached debugger doesn't know about MS_VC_EXCEPTION (e.g.
current gdb and probably strace as well) and continues exception processing,
we ignore it, rather than dying due an unhandled exception.

Also remove an unnecessary cast in the RaiseException() invocation.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-08-25 10:06:47 +01:00
Corinna Vinschen 2fd2f308e2 Include winsup.h prior to including other headers
Otherwise _GNU_SOURCE is not set when needed in sys/features.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-24 10:19:53 +02:00
Corinna Vinschen 801fffcb7e Add missing LF in release text
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 18:57:16 +02:00
Corinna Vinschen 2ea3993619 Export and document strerror_l, strptime_l, wcsftime_l from Cygwin
Bump Cygwin API minor number.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 17:51:14 +02:00
Corinna Vinschen 0ecb846d2b Implement GNU extension strptime_l
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 17:51:14 +02:00
Corinna Vinschen e636fe3d48 Implement GNU extension wcsftime_l
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 17:51:14 +02:00
Corinna Vinschen 463a8afaa5 Implement missing POSIX-1.2008 function strerror_l
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 17:51:14 +02:00
Jon Turney 9e0f9ec7ae Send thread names to debugger
GDB since commit 24cdb46e [1] can report and use these names.

Add utility function SetThreadName(), which sends a thread name to the
debugger.

Use that:
- to set the default thread name for main thread and newly created pthreads.
- in pthread_setname_np() for user thread names.
- for helper thread names in cygthread::create()
- for helper threads which are created directly with CreateThread.

Note that there can still be anonymous threads, created by system or
injected DLLs.

[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=24cdb46e9f0a694b4fbc11085e094857f08c0419
2016-08-23 15:07:42 +01:00
Jon Turney fdb7df230d Add pthread_getname_np and pthread_setname_np
This patch adds pthread_getname_np and pthread_setname_np.

These were added to glibc in 2.12[1] and are also present in some form on
NetBSD and several UNIXes.

The code is based on NetBSD's implementation with changes to better match
Linux behaviour.

Implementation quirks:

* pthread_setname_np with a NULL pointer segfaults (as linux)

* pthread_setname_np returns ERANGE for names longer than 16 characters (as
linux)

* pthread_getname_np with a NULL pointer returns EFAULT (as linux)

* pthread_getname_np with a buffer length of less than 16 returns ERANGE (as
linux)

* pthread_getname_np truncates the thread name to fit the buffer length.
This guarantees success even when the default thread name is longer than 16
characters, but means there is no way to discover the actual length of the
thread name. (Linux always truncates the thread name to 16 characters)

* Changing program_invocation_short_name changes the default thread name (on
linux, it has no effect on the default thread name)

I'll leave it up to you to decide if any of these matter.

This is implemented via class pthread_attr to make it easier to add
pthread_attr_[gs]etname_np (present in NetBSD and some UNIXes) should it
ever be added to Linux (or we decide we want it anyway).

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS
2016-08-23 15:07:42 +01:00
Corinna Vinschen 2fb5e3dfb2 Reference __global_locale only via __get_global_locale.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 12:38:28 +02:00
David Wohlferd 113abc27a6 Avoid truncating from long double to double in sinhl().
This routine makes a call to fabs instead of fabsl(), causing truncation.

Clang complains (warning: absolute value function 'fabs' given an argument of type 'long double' but has parameter of type 'double' which may cause truncation of value).

Signed-off-by: David Wohlferd <dw@LimeGreenSocks.com>
2016-08-22 14:18:39 +02:00
Ray Donnelly 96fc528397 sqrt: Fix NaN propagation for IEEE Std 754-2008
The R language has some hacks specifically for mingw-w64 that
were caused by our handling of NaNs in sqrt(x). R uses a
special valued NaN to mean 'Not Available' and expects it to
be retained through various calculations. Our sqrt(x) doesn't
do this, instead it normalises such a NaN (retaining sign).

From:

http://wwwf.imperial.ac.uk/~drmii/M3SC_2016/IEEE_2008_4610935.pdf

"6.2.3 NaN propagation

An operation that propagates a NaN operand to its result and
has a single NaN as an input should produce a NaN with the
payload of the input NaN if representable in the destination
format."

There might even be a slight speed-up from this too.

Thanks to Duncan Murdoch for finding the reference.
2016-08-22 14:17:58 +02:00
Corinna Vinschen 0df76cbd63 Document nl_langinfo_l and separate POSIX from GNU extensions in release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-20 17:24:16 +02:00
Corinna Vinschen 216054fa77 Implement missing POSIX function nl_langinfo_l
Change nl_langinfo to nl_langinfo_l using locale given as argument.
Remove outdated TRANSITION_PERIOD_HACK.  The codeset is stored in
the locale for quite some time now.  For !MB_CAPABLE targets, just
return "US_ASCII" as codeset.

Implement nl_langinfo by calling nl_langinfo_l.  Export nl_langinfo_l
from Cygwin DLL and bump minor API version number.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-20 17:22:41 +02:00
Corinna Vinschen 7630e38462 Introduce __current_locale_charset/__locale_charset
The former __locale_charset always fetched the current locale's charset.
We need the per-locale charset, too, in future. Rename __locale_charset
to __current_locale_charset and change __locale_charset to take a
locale_t as parameter.  Accommodate througout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-20 17:14:56 +02:00
Corinna Vinschen 06ac671811 Only define __getreent inline function when building newlib or Cygwin
Commit 6f3943b erroneously removed the `#ifdef _COMPILING_NEWLIB'
guarding the __getreent inline function.  This patch ignored the
fact that config.h is included when building applications, and the
code in question requires internal, auto-generated headers to be
available which are not exposed to user-space.

Reinstantiate defined(_COMPILING_NEWLIB) test and alternatively
check for defined (__INSIDE_CYGWIN__), otherwise we'd have to
reinstantiate the __getreent macro in cygtls.h which is really
confusing.

While testing it turned out that a low number of source codes inside
Cygwin won't see the inline __getreent due to a missing __INSIDE_CYGWIN__
definition.  For malloc.cc this was actually deliberate to get different
definitions from including cygmalloc.h.  Change this by defining
__INSIDE_CYGWIN__ in malloc.cc but changing the test in cygmalloc.h
to test for defined(DLMALLOC_VERSION).  This might need a change if we
ever get around to replace dlmalloc with a newer, more threading-aware
malloc implementation.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-20 17:14:55 +02:00
Corinna Vinschen 5e9b414e1c Add release message for commit eb61113
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-19 17:25:31 +02:00
Corinna Vinschen 3a2f654379 Add release message for commit a871644
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-19 16:54:56 +02:00
Corinna Vinschen a8716448ce Simplify "Windows-standard-like" permissions
Commit 97d0449 left a bit to be desired.  First, the fact that any
new-style ACL couldn't be "standard ACL" anymore was very much over
the top.  On one hand Admins and SYSTEM ACEs are not supposed to be
masked, but on the other hand we *must* create the CLASS_OBJ
because otherwise we don't have information about masking the
execute perms for both groups.  The ACL would also fail aclcheck.

And while get_posix_access now returns the "is standard acl" flag,
it hasn't been utilized by set_created_file_access.  Rather,
set_created_file_access has simply continued to check for
nentries > MIN_ACL_ENTRIES, which led to all kinds of weird group
and CLASS_OBJ perms.  The new code now always manipulates CLASS_OBJ
perms if a CLASS_OBJ is present, and it always manipulates group perms
if the ACL has been marked as "standard" ACL.

Another problem (not related to commit 97d0449) is the order
get_posix_access adds missing perms.  CLASS_OBJ perms are computed
*before* missing GROUP_OBJ perms have been added.  Thus the CLASS_OBJ
perms could be too tight and led to additional, buggy DENY ACEs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-19 16:50:15 +02:00
Corinna Vinschen 3e8f833df0 Fix outdated S_JUSTCREATED comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-19 16:27:07 +02:00
Corinna Vinschen 6f3943bca1 Reinstantiate Cygwin function called `__getreent'
This partially reverts commit 10a30e7 as far as the Cygwin version of
the __getreent function is concerned.  Remove _COMPILING_NEWLIB guard
only allowing to use __getreent inline function when building newlib,
since we wan to use it in Cygwin as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Stefan Assmann <sassmann@redhat.com>
2016-08-18 15:24:42 +02:00
Corinna Vinschen 3bbc40af2a Revert "Fix __getreent function for Cygwin"
This reverts commit 4de8596.  It worked around a problem which was
actually introduced by patch 10a30e7 a few weeks ago.  Rather than
adding special code to the newlib version of __getreent, the followup
patch reinstantiates the original, Cygwin-only implementation of
__getreent.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Stefan Assmann <sassmann@redhat.com>
2016-08-18 15:24:18 +02:00
Corinna Vinschen eb61113daf Workaround AzureAD shortcomings
No real domain, no DC, no infos via NetUserGetInfo... nothing.  Just nothing.

Use fixed uid 0x1000 (4096) for AzureAD user and gid 0x1001 (4097) for
AzureAD group.  Note that this group is part of the user token, but it's
not the primary group.  The primary group SID is, unfortunately, the
user's SID.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-18 10:27:28 +02:00
Corinna Vinschen 4de8596b8e Fix __getreent function for Cygwin
So far the lib function __getreent always returned _impure_ptr.  On Cygwin
this is only correct after _impure_ptr got initialized.  The inline
function in include/cygwin/config.h always returns the right _reent ptr,
though.

After introducing per-thread locales, the __getreent function is called
prior to initialization of _impure_ptr (from dll_crt0_0) to access the
locale pointer, which leads to a crash.

Fix the __getreent lib function for Cygwin to return the correct _reent
pointer all the time.  Rename inline function to __inline_getreent
and introduce a macro __getreent calling the inline function.  Change
the lib function __getreent to call __inline_getreent on Cygwin.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-18 10:27:14 +02:00
Corinna Vinschen 8443fcd625 Add release message for commit c02ac89
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-17 11:17:26 +02:00
Corinna Vinschen a867598373 Rephrase release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-16 12:41:34 +02:00
Corinna Vinschen de09bb4d32 Fix typo in release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-16 11:22:26 +02:00
Corinna Vinschen 5dc306cf97 Add release text for Cygwin 2.6.0
Move release/2.5.3 to release/2.6.0.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 21:26:01 +02:00
Corinna Vinschen 238455adfa Implement strto[dflu]_l/wcsto[dflu]_l
Implement GNU extensions strtod_l, strtof_l, strtol_l, strtold_l, strtoll_l,
strtoul_l, strtoull_l, wcstod_l, wcstof_l, wcstol_l, wcstold_l, wcstoll_l,
wcstoul_l, wcstoull_l.

Export from Cygwin, fix posix.xml.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 17:35:21 +02:00
Corinna Vinschen 8f1378b19f Make sure alloca is called even when optimizing, fully init _REENT
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen 7156bf842e Add sys/_locale.h header and fix up headers
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen 91ebe04042 Bump CygwinAPI minor.
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen 765d2c0bac Implement strfmon_l
Use latest code from FreeBSD

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen 542b970d4e Rename __get_locale_XXX to __get_XXX_locale to use unified naming scheme
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen c1b7d9d93d Implement per-locale string functions
strcasecmp_l, strcoll_l, strncasecmp_l, strxfrm_l,
wcscasecmp_l, wcscoll_l, wcstrncasecmp_l, wcstrxfrm_l,
strftime_l.

Add missing CHEWOUT_FILES from previous patch.

TODO: strfmon_l.

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:58 +02:00
Corinna Vinschen 8493c16316 Implement all per-locale ctype functions
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen 1afa0fe4b3 Fix memory handling in functions called from loadlocale
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen aefd8b5b51 Implement newlocale, freelocale, duplocale, uselocale
Add global const __C_locale for reference purposes.

Bump Cygwin API minor number and DLL major version number to 2.6.0.

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen 53f84bb5ac Rearrange struct __locale_t pointers into an array
This allows looping through the structs and buffers.  Also
rearrange definitions to follow order of LC_xxx values.

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen 1498c79db8 Change loadlocale to fill a __locale_t given as parameter
Don't use global variables.  This allows to call loadlocale from
the yet to be created newlocale().

Rename _thr_locale_t to __locale_t (these locales are not restricted
to threads so the name is misleading).

Along these lines, fix _set_ctype to take a __locale_t as parameter.

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen d16a56306d Consolidate wctomb/mbtowc calls for POSIX-1.2008
- Remove charset parameter from low level __foo_wctomb/__foo_mbtowc calls.
- Instead, create array of function for ISO and Windows codepages to point
  to function which does not require to evaluate the charset string on
  each call.  Create matching helper functions.  I.e., __iso_wctomb,
  __iso_mbtowc, __cp_wctomb and __cp_mbtowc are functions returning the
  right function pointer now.
- Create __WCTOMB/__MBTOWC macros utilizing per-reent locale and replace
  calls to __wctomb/__mbtowc with calls to __WCTOMB/__MBTOWC.
- Drop global __wctomb/__mbtowc vars.
- Utilize aforementioned changes in Cygwin to get rid of charset in other,
  calling functions and simplify the code.
- In Cygwin restrict global cygheap locale info to the job performed
  by internal_setlocale.  Use UTF-8 instead of ASCII on the fly in
  internal conversion functions.
- In Cygwin dll_entry, make sure to initialize a TLS area with a NULL
  _REENT->_locale pointer.  Add comment to explain why.

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:57 +02:00
Corinna Vinschen 88208d3735 POSIX-1.2008 per-thread locales, groundwork part 2
Move all locale category structure definitions into setlocale.h and remove
other headers in locale subdir.  Create inline accessor functions for
current category struct pointers and use throughout.  Use pointers to
"C" locale category structs by default in __global_locale.

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:56 +02:00
Corinna Vinschen a6a477fa81 POSIX-1.2008 per-thread locales, groundwork part 1
Introduce first cut of struct _thr_locale_t used for the locale_t definition.
Introduce global instance called __global_locale used by default.
Introduce internal inline functions __get_global_locale, __get_locale_r,
__get_current_locale.

Remove usage of global variables in favor of accessor functions pointing to
__global_locale for now.  Include all local headers in locale subdir from
setlocale.h to get single include for internal locale access.

Introduce __CTYPE_PTR macro to replace direct access to __ctype_ptr__
and use throughout in isxxx functions.

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15 10:56:56 +02:00
Corinna Vinschen 9169111acf Remove unused import/rexec.c accidentally imported by commit b6e90a06
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-12 14:52:09 +02:00
Erik Bray 86f79af827 kill(pid, sig) before waitpid() returns -1 for sig != 0
This is a followup to a report back in 2011 about essentially the same issue:

https://cygwin.com/ml/cygwin/2011-04/msg00031.html

The same test program in that report demonstrates the issue, but with
kill sending any non-zero signal.  To reiterate, the problem here is
POSIX compliance with respect to sending signals to zombie processes.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/kill.html
claims:

  Existing implementations vary on the result of a kill() with pid
  indicating an inactive process (a terminated process that has not been
  waited for by its parent). Some indicate success on such a call
  (subject to permission checking), while others give an error of
  [ESRCH].  Since the definition of process lifetime in this volume of
  POSIX.1-2008 covers inactive processes, the [ESRCH] error as described
  is inappropriate in this case. In particular, this means that an
  application cannot have a parent process check for termination of a
  particular child with kill().  (Usually this is done with the null
  signal; this can be done reliably with waitpid().)

In response to the originally issue, this was fixed *specifically* for
the case of kill(pid, 0).  But my reading of the above is that kill()
should return 0 in this case regardless of the signal (modulo
permissions, etc.).  On Linux, for example, when calling kill with pid
of a zombie process the kernel will happily deliver the signal to the
relevant task_struct; it will just never be acted on since the task
will never run again.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-11 15:57:53 +02:00
Corinna Vinschen 9c4113f0c7 Workaround for filesystems with broken FileAllInformation info class (NcFsd)
See discussion starting at https://cygwin.com/ml/cygwin/2016-07/msg00350.html

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-05 10:47:37 +02:00
Corinna Vinschen 99a3f266c1 Fix console clear screen if buffer is full
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-03 14:34:01 +02:00
Corinna Vinschen 05847ad6e9 Fix console clear screen in case of partial scrolling
Commit d7586cb incorrectly checked only for the new cursor position
beyond the old cursor position to decide if we have to correct for user
scrolling.  Since this situation is handled just fine if the cursor is
still visible, only perform the subsequent correction if the cursor is
not in the visible console window.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-01 12:42:54 +02:00
Corinna Vinschen 11dcf9cb5c Open process with PROCESS_QUERY_INFORMATION to fetch maps
Commit ba58e5f lowered permission requirements when opening threads
and processes to {PROCESS,THREAD}_QUERY_LIMITED_INFORMATION.  However,
when creating the /proc/<PID>/maps file, the call to VirtualQueryEx
requires PROCESS_QUERY_INFORMATION access

Note: It seems PROCESS_QUERY_LIMITED_INFORMATION is sufficient starting
with Windows 8.1, but this is neither documented on MSDN, nor is it a
safe bet.  It may have to do with a fixed implementation of the UAC
trust levels.  Let's better follow the docs for now.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-01 11:52:30 +02:00
Corinna Vinschen d7586cb66c Fix clear screen behaviour of console when user scrolled up or down
We must call SetConsoleCursorPosition prior to SetConsoleWindowInfo,
otherwise the scroll bars will not be updated by the OS.  Make sure
to scroll the console window by just the right amount to have the
new cursor position one line after the used console buffer area at
the top of the console window, no matter the scroll state.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-29 12:07:46 +02:00
Corinna Vinschen 08da3bfc41 Fix buffer scrolling when performing a "clear screen"
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-28 08:50:09 +02:00
Corinna Vinschen 32b668d966 Don't raise SIGTTIN from poll/select
SIGTTIN should be raised when read() is made on a tty in a backgrounded
process, but not when it's tested with poll()/select().

I guess poll()/select() does need to call bg_check(), in order to detect the
error conditions that notices (that is, if bg_check() returns bg_eof or
bg_error, then fd is ready as an error condition exists) so add an optional
parameter to fhandler_base::bg_select() to indicate that signals aren't
desired.

See https://cygwin.com/ml/cygwin-developers/2016-07/msg00004.html
2016-07-27 17:02:08 +01:00
Corinna Vinschen 10a30e7a25 Remove redundant macro and function called `__getreent'
Just rely on the inline version in include/cygwin/config.h

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-27 14:00:30 +02:00
Corinna Vinschen 25cb82a55e Change "nodomain+nobody" to "no+body"
Per https://cygwin.com/ml/cygwin-apps/2016-07/msg00059.html

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-22 09:41:23 +02:00
Corinna Vinschen 1a988fc6ba Handle WinFSP nobody account
Per discussion started at
https://cygwin.com/ml/cygwin/2016-06/msg00347.html

S-1-0-65534 == uid/gid 65534 == nodomain+nobody

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-19 11:14:50 +02:00
Corinna Vinschen 642c48095c Fix typo
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-18 22:03:37 +02:00
Corinna Vinschen 2082bcec41 Add release message for commit 71df3bf
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-18 22:03:00 +02:00
Corinna Vinschen 71df3bfd51 truncl: Fix setting rounding bits in FPU control word
Mingw-w64, which is the source of this code, uses different
definitions of the rounding bits FE_TONEAREST and friends.
They immediately reflect the bit values in the FPU control word,
while on Cygwin they are shifted down to become the values 0-3.

Fix the bit computing expression to account for the difference.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-18 22:00:17 +02:00
Eric Blake 7475b656f4 Put previous doc in correct section
SSIZE_MAX was a bug fix, not a huge change.

Signed-off-by: Eric Blake <eblake@redhat.com>
2016-07-14 13:26:29 -06:00
Corinna Vinschen 863952f273 Add release message for commit fe9e3b4
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-14 20:55:04 +02:00
Corinna Vinschen fe9e3b4498 Transform all special chars in relative Windows path string
get_nt_native_path handles the transposition of chars not allowed
in Windows pathnames.  However, it never starts transposition at
the start of the string, which is wrong for relative paths.  Fix it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-14 20:52:04 +02:00
Eric Blake 6795ef7d37 Fix 32-bit SSIZE_MAX
POSIX requires that SSIZE_MAX have the same type as ssize_t, but
on 32-bit, we were defining it as a long even though ssize_t
resolves to an int.  It also requires that SSIZE_MAX be usable
via preprocessor #if, so we can't cheat and use a cast.

If this were newlib, I'd have had to hack _intsup.h to probe the
qualities of size_t (via gcc's __SIZE_TYPE__), similar to how we
already probe the qualities of int8_t and friends, then cross our
fingers that ssize_t happens to have the same rank (most systems
do, but POSIX permits a system where they differ such as size_t
being long while ssize_t is int).  Unfortunately gcc gives us
neither __SSIZE_TYPE__ nor __SSIZE_MAX__.  On the other hand, our
limits.h is specific to cygwin, so we can just shortcut to the
correct results rather than being generic to all possible ABI.

Signed-off-by: Eric Blake <eblake@redhat.com>
2016-07-14 12:38:49 -06:00
Corinna Vinschen 87076a3a83 Add release message for commit 82e0649
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-14 19:11:45 +02:00
Ray Donnelly 82e06490de machine/_types.h: __blkcnt_t should be signed
[1] states: "blkcnt_t and off_t shall be signed integer types."

This causes pacman to fail when the size requirement
of the net update operation is negative, instead it
calculated a huge positive number.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html
2016-07-14 19:02:57 +02:00
Corinna Vinschen a5d197eb48 Add release message for commit 8cff156
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-06 19:16:05 +02:00
Corinna Vinschen 8cff1569fc strace: Make sure strace timer isn't copied to child process
At fork time the .data and .bss segments of the Cygwin DLL are copied
over to the child process.  This also copies the strace timer since
it's in the .bss segment so far.  Fix that by moving the strace timer
out into the .data_cygwin_nocopy segment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-06 19:12:59 +02:00
Corinna Vinschen a68ca43b90 Redefine locale info in struct _reent for per-thread locales
The _reent members _current_category and _current_locale are not
used at all.  _current_locale is set to "C" in various points of
the code but its value is just as unused as _current_category.

This patch redefines these members without changing the size of the
structure to allow for an implementation of per-thread locales per
POSIX-1.2008 (i.e. uselocale and usage of the per-thread locale in
subsequent function calls).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-06 15:41:35 +02:00
Corinna Vinschen 29600e04e3 Make sure to use the Winsock definition of FIONREAD in ioctlsocket call
Commit b1b46d45 introduced a regression.  After redefining FIONREAD
as part of restructuring newlib/Cygwin headers, the call to ioctlsocket
in the FIONREAD branch of fhandler_socket::ioctl should have been
changed to use the Winsock definition of FIONREAD, which I neglected.
This only affects 64 bit Cygwin.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-07-01 16:56:07 +02:00
Corinna Vinschen c920bf0b01 Reformat some too-long lines
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-27 18:00:56 +02:00
Corinna Vinschen 532ecdd36f Add comment to point out missing access right per documentation
In get_mem_values we open the process without PROCESS_VM_READ access
and are *still* able to request working set information, despite
MSDN claiming we need it for this purpose.  Instead of adding this
access right, just add an comment to point this out for now.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-27 18:00:01 +02:00
Corinna Vinschen ba58e5f20c Use PROCESS/THREAD_QUERY_LIMITED_INFORMATION where appropriate
Using PROCESS/THREAD_QUERY_INFORMATION may limit the number of
processes/threads we can inspect depending on their integrity level.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-27 17:56:16 +02:00
Corinna Vinschen 084253081a Add release message for commit b2867a6
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-27 13:21:19 +02:00
Jon Turney d3297c3304 Revert "Use .DELETE_ON_ERROR"
This reverts commit 62b0bf0b8b.
2016-06-25 17:08:18 +01:00
Jon Turney 62b0bf0b8b Use .DELETE_ON_ERROR
Use .DELETE_ON_ERROR
Make the fact that we are running dllfixdbg less obscure
2016-06-25 17:03:57 +01:00
Corinna Vinschen 6ef3cc7da3 Remove leftover useless copyright hints
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-25 13:36:52 +02:00
Corinna Vinschen 2a18fb4b94 Clarify setting of child_info::msv_count in child_info.h
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-25 10:21:45 +02:00
Corinna Vinschen cb34fffe07 Remove CYGWIN=detect_bloda option 2016-06-25 00:43:01 +02:00
Corinna Vinschen da5b48ef3c No longer support "Interact with desktop"
Always create child user window station and desktop, unless only
spawning with restricted token.  Also fix formatting of a few comments
in child_info_spawn::worker.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-25 00:42:36 +02:00
Corinna Vinschen cd93c771ef Fix comments for AI_ADDRCONFIG and AI_V4MAPPED 2016-06-24 23:35:13 +02:00
Corinna Vinschen 7c84bfdb5f syscalls.cc: Merge desktop_ini_ext into desktop_ini 2016-06-24 23:34:33 +02:00
Corinna Vinschen f4aaa21441 fhandler_pty_master::pty_master_thread: Always check for correct pid 2016-06-24 23:33:48 +02:00
Corinna Vinschen ceab4452f1 Remove unused GetTickCount_ns 2016-06-24 23:33:01 +02:00
Corinna Vinschen 00e9bf2bb3 Fix various OS-related comments
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-24 23:32:39 +02:00
Corinna Vinschen bb0fc7a2c0 cygheap_domain_info::init: Fix comment 2016-06-24 23:21:48 +02:00
Corinna Vinschen 0f5afe895f net.cc (fdsock): Fix comment 2016-06-24 22:50:12 +02:00
Corinna Vinschen ba8d6a595a child_info.h: Fix a comment 2016-06-24 22:50:00 +02:00
Corinna Vinschen b87224fba5 child_info::child_info: Fix a comment 2016-06-24 22:49:48 +02:00
Corinna Vinschen ecea753689 sec_auth.cc: Drop prototype for CreateProfile, don't expect failed autoload 2016-06-24 22:49:18 +02:00
Corinna Vinschen bfb5d3ffbb include/cygwin/if.h: Fix a comment 2016-06-24 22:48:58 +02:00
Corinna Vinschen 8b7c4f67c6 fhandler_disk_file::opendir: Fix a comment 2016-06-24 22:48:40 +02:00
Corinna Vinschen 81031e6850 eval_start_address: Fix comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-24 21:58:46 +02:00
Corinna Vinschen 8cfa64140d fhandler_dev_floppy::get_drive_info: fix comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-24 21:56:34 +02:00
Corinna Vinschen a361f44c97 symlink_info::check fixup comment and two test for non-XP 2016-06-24 21:07:39 +02:00
Corinna Vinschen e855447fd2 Drop autoloading transaction functions from ntdll 2016-06-24 21:07:39 +02:00
Corinna Vinschen 9d163cf80c Drop autoloading kernel32 symbols available since Vista 2016-06-24 21:07:39 +02:00
Corinna Vinschen 450b2dc8ed Drop autoloading of CancelSynchronousIo 2016-06-24 21:07:39 +02:00
Corinna Vinschen 67fd2101ab Drop max_sys_priv wincap
Convert sys_privs to const struct with TOKEN_PRIVILEGES layout.
Drop function get_system_priv_list.  Just use pointer to sys_privs.

Dropping max_sys_priv from wincaps requires to make sure that the
bitfield is 8 byte aligned on x86_64, otherwise gcc (5.3 only?)
apparently breaks access to the bitfield (off by 4 bytes).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-24 21:00:04 +02:00
Corinna Vinschen b15d129559 Drop accidentally leftover comment from wincapc::init 2016-06-24 16:02:41 +02:00
Corinna Vinschen c7fe56dd65 Default to latest wincap 2016-06-24 16:02:41 +02:00
Corinna Vinschen b47a67e493 Drop Windows XP/2003 wincaps 2016-06-24 16:02:40 +02:00
Corinna Vinschen 8dd446a7b1 Drop has_broken_rtl_query_process_debug_information flag 2016-06-24 16:02:40 +02:00
Corinna Vinschen 2467e6f99b Drop terminate_thread_frees_stack flag 2016-06-24 16:02:40 +02:00
Corinna Vinschen 0bf159ab72 Drop has_pipe_reject_remote_clients flag 2016-06-24 16:02:40 +02:00
Corinna Vinschen 23a556f2c5 Drop has_set_thread_stack_guarantee flag 2016-06-24 16:02:40 +02:00
Corinna Vinschen 8b8c6c014b Drop has_program_compatibility_assistant flag 2016-06-24 16:02:40 +02:00
Corinna Vinschen c356901f0d Rename if_indextoname to cygwin_if_indextoname (analag for if_nametoindex)
Just call OS functions
2016-06-24 16:02:39 +02:00
Corinna Vinschen bd4339e2a2 Drop wow64_has_secondary_stack flag 2016-06-24 15:49:45 +02:00
Corinna Vinschen 105f79b489 Drop use_dont_resolve_hack flag
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-24 15:42:06 +02:00
Corinna Vinschen 807a628ec6 Drop has_restricted_raw_disk_access flag 2016-06-24 14:31:56 +02:00
Corinna Vinschen 166d3ddf5a Fix major device check when locking partitions
The change introduced in commit b2867a6 contains a faulty check for
the major device number in fhandler_dev_floppy::lock_partition.
Fix this.  Also fix comments.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-24 13:40:02 +02:00
Corinna Vinschen 9aab8eb5b6 Drop has_transactions flag 2016-06-24 13:12:20 +02:00
Corinna Vinschen ffcef702e7 Drop has_fast_cwd flag 2016-06-24 13:08:36 +02:00
Corinna Vinschen 288df6f818 Add support for certain newer locales only available with Script
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-24 12:11:42 +02:00
Corinna Vinschen 94f98f18db Drop has_localenames flag 2016-06-23 22:21:23 +02:00
Corinna Vinschen ed0ff4b940 Drop has_always_all_codepages flag 2016-06-23 22:21:23 +02:00
Corinna Vinschen e931b1a0eb Drop has_broken_udf flag 2016-06-23 22:21:23 +02:00
Corinna Vinschen 222e412f8d Drop has_sendmsg flag 2016-06-23 22:21:23 +02:00
Corinna Vinschen aacc4f63d0 Drop has_mandatory_integrity_control flag 2016-06-23 22:21:23 +02:00
Corinna Vinschen 380b9affd1 Drop has_restricted_stack_args flag 2016-06-23 22:21:23 +02:00
Corinna Vinschen 6f560555bd Drop supports_all_posix_ai_flags 2016-06-23 22:21:23 +02:00
Corinna Vinschen a759558418 Drop has_gaa_on_link_prefix flag and remove obsolete functions thusly 2016-06-23 22:18:42 +02:00
Corinna Vinschen 2fb0813caa Drop has_recycle_dot_bin 2016-06-23 22:01:14 +02:00
Corinna Vinschen 0c8bbd5888 Add release message for commit 733af66
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-23 21:58:38 +02:00
Corinna Vinschen 733af66c6e Remove support for SUNWNFS file system 2016-06-23 21:30:15 +02:00
Corinna Vinschen b2867a68b9 Handle up to 63 partitions per drive
Revamp device parsing code.  Introducing support for more partitions
into the shilka-generated parser has the unfortunate side-effect of
raising the size of the DLL by almost 2 Megs.  Therefore we split out
the handling for /dev/sdXY devices into a tiny bit of hand-written
code.

While at it, remove some unused cruft from devices.* and generally
clean up the device class to provide access methods instead of direct
access to members.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-23 16:56:41 +02:00