Commit Graph

7962 Commits

Author SHA1 Message Date
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
Corinna Vinschen bceb8ebebb Bump DLL minor version
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-23 15:21:44 +02:00
Corinna Vinschen 6e623e9320 Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option
Bump GPLv2+ to GPLv3+ for some files, clarify BSD 2-clause.

Everything else stays under GPLv3+.

New Linking Exception exempts resulting executables from LGPLv3 section 4.

Add CONTRIBUTORS file to keep track of licensing.

Remove 'Copyright Red Hat Inc' comments.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-23 10:09:17 +02:00
Corinna Vinschen 94e3a561d0 Add release message for commit 2c83227
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-21 13:43:53 +02:00
Corinna Vinschen 2c83227112 Drop useless calls to path_conv.isgood_inode
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-21 13:39:35 +02:00
Corinna Vinschen 4965cdc9ad Use correct file info (especially inode number) for newly created files
fhandler_base::open_fs has two problems:
- When newly creating a file, the file info in the path_conv is
  incorrect.  It points to info for the parent dir, not to info
  for the file itself (which, naturally, wasn't available before).
- Fetching the file's inode number only worked for non-NFS.

Both problems should be fixed now by reloading file info if the file
has just been created, as well as using the new FS-agnostic
path_conv::get_ino method.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-21 13:39:04 +02:00
Corinna Vinschen 36d4eb12b5 Use new path_conv_handle functions to access file info
This avoids having to call nfs_fetch_fattr3/file_get_fai depending
on FS type as well as having to extract the info FS dependent.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-21 13:28:12 +02:00
Corinna Vinschen f91865c8cf Improve encapsulation of FS type behind path_conv cover
Rather than having to check for the FS type in the caller and having
to call different functions whether FS is NFS or not, encapsulate the
info in path_conv_handle/path_conv methods to allow FS type agnostic
calling from upper level functions.

This patch only implements the methods.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-21 13:25:38 +02:00
Corinna Vinschen 747b3f44e3 uinfo.cc: More comment fixes, remove unused testing code.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-15 19:48:43 +02:00
Corinna Vinschen 5881f0c0c8 uinfo.cc: Fix comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-15 18:04:00 +02:00
Corinna Vinschen b1f63ce874 Fix typos in comments and debug output in select_stuff::wait
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-08 11:02:50 +02:00
Corinna Vinschen ffac52c1ab Add release message for commit 7239bb7b3d
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-06 19:02:08 +02:00
Corinna Vinschen 0177f12cf6 Add release message for select(2) changes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-06 17:24:39 +02:00
Corinna Vinschen 7186b657e7 Improve timer handling in select.
Commit a23e6a35d8 introduced a timer
object to the WFMO handling in select_stuff::wait to allow sub-tickcount
timeout values in select.

Problems with this patch: The timer was created and destroyed on every
invocation of select_stuff::wait, thus potentially multiple times per
select.  Also, since the timer was prepended to the WFMO hande list,
the timer handle could shadow actual events on other objects, given that
WFMO checks the objects in the order they have been specified in the
HANDLE array.  The timer was also created/destroyed and added to the
HANDLE array even if it was not required.

This patch drops the local timer HANDLE and recycles the cw_timer HANDLE
in the cygtls area instead.  Thus we typically don't need to create the
timer in select at all, and we never have to destroy it.

The timer HANDLE is now also appended as last object to the HANDLE array,
and it's only added if actually needed.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-06 16:48:38 +02:00
Corinna Vinschen 83834110a0 Fix condition in select which results in busy loop.
The check for current timestamp > start timestamp has an unwelcome
side effect:  The loop is not left as long as the current timestamp
hasn't been incremented.  This leads to busy loops of about one tick
(10 to 16 ms per MSDN).

This fixes https://cygwin.com/ml/cygwin/2016-05/msg00327.html

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-06 16:18:53 +02:00
Takashi Yano 7239bb7b3d Return at most one line of input in canonical mode
'man termios' says:
"A read(2) returns at most one line of input" in canonical mode.

On cygwin 2.5.1, read(2) returns all data in buffer if the buffer
size specified is large enough. This behaviour is correct in
noncanonical mode, but is not correct in canonical mode.

While checking this problem, I found a bug of tcflush().  tcflush()
flushes only partial data in the buffer.  The patch also fixes this bug.

The patch has also been tested against the problem reported in
https://cygwin.com/ml/cygwin/2016-05/msg00318.html.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-06 15:10:25 +02:00
Ken Brown 97349b7870 Allow 'make distclean' to clean winsup/cygwin
But don’t let it remove source files.
2016-06-06 11:52:19 +02:00
Corinna Vinschen 7abe634731 Only regenerate tlsoffsets{64}.h if cygtls.h can be compiled
The rule to make tlsoffset{64}.h has a flaw.  If cygtls.h can't be
built for whatever reason, it *still* regenerates tlsoffsets{64}.h,
just with size 0.  If the bug is not in cygtls.h itself, this behaviour
breaks further building, because fixing the problem won't result in
regenerating tlsoffset{64}.h.  Manual intervention is required.

Fix that by removing tlsoffsets{64}.h if gentls_offsets fails.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-06 11:44:54 +02:00
Yaakov Selkowitz f4edc7fd6d cygwin: include sys/types.h in sys/xattr.h
Using libattr's <xattr/xattr.h> requires consumers to explicitly include
<sys/types.h> first, but glibc's header in sys/ already contains the include.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-06-03 03:34:11 -05:00
Corinna Vinschen b0b99e39dc sched.cc: Use PROCESS_QUERY_INFORMATION for now
Temporarily revert to use PROCESS_QUERY_INFORMATION instead of
PROCESS_QUERY_LIMITED_INFORMATION to make sure every aspect of the
next release is still XP/2003 compatible.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-03 10:28:44 +02:00
Corinna Vinschen 211a942ad2 Revert "Cygwin hangs up if several keys are typed during outputting a lot of texts."
This reverts commit 252a07b0ad.

This change introduced a hang in certain scenarios, for an example
see https://cygwin.com/ml/cygwin/2016-05/msg00318.html
2016-06-01 17:04:24 +02:00
Corinna Vinschen 8a31aa37bc dlopen: Add dot to filename if no slash is present
We're appending a dot to the filename before calling LoadLibrary to
override ".dll" automagic.  This only worked for paths, not for simple
filenames since it required a slash in the pathname.  Fix that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-01 13:12:22 +02:00
Corinna Vinschen c496a068cf Cygwin: Add release messages for previous two commits
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-31 16:37:53 +02:00
Corinna Vinschen 5c759ab2f4 realpath: Handle Win32 and NT long path prefixes
So far drive letter paths have been handled special since path_conv
leaves the incoming path untouched except for converting backslashes
to forward slashes.  However, if the incoming path starts with a
long path prefix, the same problem occurs.  Therefore handle all
paths starting with a backslahs the same way.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-31 16:33:21 +02:00
Corinna Vinschen 030d86d04d TZ: Replace unreliable isupper calls on wchars
In case the TZ variable is empty, Cygwin fetches timezone info from
Windows.  Extracting the timezone short name uses isupper on wide chars.
Replace with explicit check for A <= character <= Z to be independent
of undefined behaviour.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-25 12:13:03 +02:00
Corinna Vinschen 4e434bf223 Add release message for previous mmap fix
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-20 21:50:41 +02:00
Corinna Vinschen 0aa738220b mmap: Fix size restriction of maps due to using 32 bit size type
Throughout mmap, size-related variables and parameters are still using
DWORD as type, which disallows mapping ranges > 4Gigs.  Fix this by
using SIZE_T throughout for those vars and parameters.
Also, drop unused off parameter from 1st variant of mmap_record::map_pages.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-20 21:48:10 +02:00
Corinna Vinschen 2e62d68ba5 Add release message for scheduler fixes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-20 18:01:11 +02:00
Corinna Vinschen 4b51e4c142 Fix thread priority handling
So far pthread::postcreate() only sets the thread priority at all, only
if the inherit-scheduler attribute is PTHREAD_EXPLICIT_SCHED.  This
completely ignores the PTHREAD_INHERIT_SCHED case, since in contrast
to POSIX, a thread does not inherit its priority from the creating
thread, but always starts with THREAD_PRIORITY_NORMAL.

pthread_getschedparam() only returns what's stored in the thread attributes,
not the actual thread priority.

This patch fixes both problems.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-20 17:45:24 +02:00
Corinna Vinschen 450f557fee Rewrite scheduler functions getting and setting process and thread priority
So far the scheduler priority handling is not POSIX compatible.
The priorities use a range of -14 up to +15, which means it's not clear
if the POSIX-required return value of -1 in case of an error is *really*
an error or just the valid priority value -1.  Even more confusing, -14
is the *max* value and 15 is the *min* value.  Last but not least this
range doesn't match the POSIX requirement of at least 32 priority values.

This patch cleans up scheduler priority handling and moves the valid
priority range to 1 (min) - 32 (max).  It also adds a function
sched_get_thread_priority() which will help to make thread priority
more POSIX-like.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-20 17:38:22 +02:00
John Hood 6dd601af66 Miscellaneous style cleanup, whitespace only. 2016-05-20 12:11:18 +02:00
John Hood e5665d8c93 Improve and simplify select().
* select.h: Eliminate redundant select_stuff::select_loop state.
* select.cc (select): Eliminate redundant
  select_stuff::select_loop state.  Eliminate redundant code for
  zero timeout.  Do not return early on early timer return.
  (select_stuff::wait): Eliminate redundant
  select_stuff::select_loop state.
2016-05-20 12:00:58 +02:00
John Hood a23e6a35d8 Use high-resolution timebases for select().
* select.h: Change prototype for select_stuff::wait() for larger
  microsecond timeouts.
* select.cc (pselect): Convert from old cygwin_select().
  Implement microsecond timeouts.
  (cygwin_select): Rewrite as a wrapper on pselect().
  (select): Implement microsecond timeouts.
  (select_stuff::wait): Implement microsecond timeouts with a timer
  object.
2016-05-20 12:00:38 +02:00
Corinna Vinschen f6d9d8a182 Bump Cygwin DLL version to 2.5.2
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-18 21:27:57 +02:00
Sebastian Huber 51062c856b Always provide register_t via <sys/types.h>
Always provide register_t via <sys/types.h> for glibc and BSD
compatibility.  Define __BIT_TYPES_DEFINED__ to 1 like glibc for legacy
header files.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-21 10:28:13 +02:00
Corinna Vinschen 8cb99e8ba4 Remove cygwin/types.h 2016-04-21 10:12:02 +02:00
Sebastian Huber 9bb91b6c6b Resurrect <machine/types.h> for <sys/types.h>
Resurrect <machine/_user_types.h> for use in <sys/types.h>.  Newlib
targets may provide an own version of <machine/types.h> in their machine
directory to add custom user types for <sys/types.h>.  Check the
_SYS_TYPES_H header guard to prevent a direct include of
<machine/types.h>, since the <machine/types.h> file is a Newlib
speciality.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-21 10:08:19 +02:00
Corinna Vinschen 1f02aa08d1 Add release message for commit 9409c53 2016-04-20 12:34:07 +02:00
Corinna Vinschen 9409c5335b Don't test pthread objects for being already initialized at init time
For all pthread init functions, POSIX says

  Results are undefined if pthread_FOO_init() is called specifying an
  already initialized pthread_FOO object.

So far our pthread init functions tested the incoming object if it's
already an initialized object and, if so, returned EBUSY.  That's ok
*iff* the object was already initialized.  However, as the example in
https://cygwin.com/ml/cygwin/2016-04/msg00473.html shows, an uninitialized
pthread object could also accidentally look like an initialized object
and then returning EBUSY is not ok.

Consequentially, all those tests are dangerous.  Per POSIX, an application
has to know what its doing when calling any of the pthread init functions
anyway, and re-initializing the object is just as well as undefined
behaviour as is returning EBUSY on already initialized objects.

	* thread.cc (pthread_attr_init): Drop check for already initialized
	object.
	(pthread_condattr_init): Ditto.
	(pthread_rwlockattr_init): Ditto.
	(pthread_mutexattr_init): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-20 12:31:45 +02:00
Sebastian Huber 7d22dc338d Provide in_port_t via <sys/types.h>
Provide in_port_t via <sys/types.h> if __BSD_VISIBLE for BSD
compatibility.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-19 23:40:53 +02:00
Sebastian Huber 3ce1e7901e Provide in_addr_t via <sys/types.h>
Provide in_addr_t via <sys/types.h> if __BSD_VISIBLE for BSD
compatibility.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-19 17:21:38 +02:00
Sebastian Huber e03a7056a6 Introduce __sa_family_t for BSD compatibiliy
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-19 17:06:49 +02:00
Sebastian Huber cb376b255d Introduce __socklen_t for BSD compatibility
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-19 16:51:00 +02:00
Sebastian Huber 76a2110b47 BSD compatibility for <machine/endian.h>
Introduce <machine/_endian.h> to let target based customization of
<machine/endian.h> via

 * _LITTLE_ENDIAN,
 * _BIG_ENDIAN,
 * _PDP_ENDIAN, and
 * _BYTE_ORDER.

defines.  Add definitions expected by FreeBSD to
<machine/endian.h> like

 * _QUAD_HIGHWORD,
 * _QUAD_LOWWORD,
 * __bswap16(),
 * __bswap32(),
 * __bswap64(),
 * __htonl(),
 * __htons(),
 * __ntohl(), and
 * __ntohs().

Also, if __BSD_VISIBLE

 * LITTLE_ENDIAN,
 * BIG_ENDIAN,
 * PDP_ENDIAN, and
 * BYTE_ORDER.

Targets that define __machine_host_to_from_network_defined in
<machine/_endian.h> must provide their own implementation of

 * __htonl(),
 * __htons(),
 * __ntohl(), and
 * __ntohs(),

otherwise a default implementation is provided by <machine/endian.h>.
In case of GCC defines to builtins are used.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-19 16:36:51 +02:00
Corinna Vinschen 7a5b452443 Disallow S_ISGID on directories without default ACL entries
We can't handle the S_ISGID bit if the child didn't inherit a NULL SID
ACE with the S_ISGID bit set.  On directories without default ACL
entries we would have to add an inheritable NULL SID ACE and nothing else.
This in turn results in permission problems when calling set_file_sd
from set_created_file_access.  That's fixable, but it would only work
for files created from Cygwin while files created from native Windows
tools end up with really ugly permissions.

This patch only makes sure that the S_ISGID bit is reset for a directory
if it has no inheritable ACEs.  Still having the 's' bit shown in ls or
getfacl output would be misleading.  So, calling `setfacl -k' on a dir
also removes the S_ISGID bit now.

	* sec_acl.cc (set_posix_access): Drop S_ISGID bit on directories
	without inheritable ACEs.  Explain why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-19 10:23:49 +02:00
Corinna Vinschen 97d0449325 Handle permissions a bit closer to POSIX 1003.1e
So far we tweaked ACL_GROUP_OBJ and ACL_MASK values the same way when
creating a file.  We now do what POSIX requires, namely just change
ACL_MASK if it's present, otherwise ACL_GROUP_OBJ.  Note that we only
do this at creation time.  Chmod still tweaks both to create less
surprising results for the unsuspecting user.

Additionally make sure to take umask only into account if no ACL_MASK
value is present.  That has been missed so far.

	* sec_acl.cc (set_posix_access): Perform check for non-existant
	default	ACEs earlier.  Ignore umask also if ACL_MASK is present.
	Only set owner_eq_group if we're actually handling a user entry.
	Mention chmod in a comment.
	* security.cc (set_created_file_access): Perform group/mask
	permission setting as required by POSIX 1003.1e.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-18 20:43:00 +02:00
Corinna Vinschen 12cc8290e8 Also create NULL SID ACE if special POSIX bits are set
Commit e2ea143 forgot to take special POSIX bits into account.

	* sec_acl.cc (set_posix_access): Make sure to create NULL SID
	ACE if any special POSIX permission bits are set.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-18 15:36:34 +02:00
Corinna Vinschen c36070f2f6 Add release message for commit e2ea143 2016-04-18 12:09:18 +02:00
Corinna Vinschen e2ea143083 Fix attempt to create ACLs without NULL SID
Commit f75114fc was supposed to drop NULL SIDs in case the permissions
are simple enough not to require mask values or special POSIX bits
(S_ISVTX, etc).  The check was incorrect.  This patch is supposed to
fix the problem.

	* sec_acl.cc (set_posix_access): Fix condition under which we
	write a NULL SID.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-18 12:07:04 +02:00
Corinna Vinschen ea58e20c0e Cygwin: Drop definition and usage of _mode_t in favor of __mode_t
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-15 14:51:40 +02:00
Sebastian Huber f3e587d30a Provide POSIX defined fsblkcnt_t and fsfilcnt_t
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-15 14:51:40 +02:00
Sebastian Huber c5d5030aea Provide POSIX defined blksize_t in <sys/types.h>
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-15 14:51:40 +02:00
Sebastian Huber 57d2718c0e Provide POSIX defined blkcnt_t in <sys/types.h>
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-15 14:51:40 +02:00
Sebastian Huber eba91a5d0a Define mode_t via __mode_t
Use __uint32_t to avoid the use of GCC-specific _ST_INT32.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-15 14:51:39 +02:00
Sebastian Huber e77040b2bf Add BSD guard for ino_t in <sys/types.h>
Introduce internal type __ino_t.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-15 14:51:39 +02:00
Sebastian Huber eeded3c170 Provide POSIX defined id_t in <sys/types.h>
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-15 14:51:39 +02:00
Sebastian Huber 8a5af1a184 Use __machine_*_t_defined for internal types
Newlib defines defaults for internal types via <sys/_types.h> and uses
<machine/_types.h> to let targets define their own type if necessary.

Previously for example

	#ifndef __dev_t_defined
	typedef short __dev_t;
	#endif

However, the __*_t_defined pattern conflicts with the glibc type guard
pattern for user types, e.g. dev_t in this example.  Introduce a
__machine_*_t_defined pattern for internal types (defined by
<machine/_types.h>, used by <sys/_types.h>).  For example

	#ifndef __machine_dev_t_defined
	typedef short __dev_t;
	#endif

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-15 14:51:39 +02:00
Corinna Vinschen 7b39124400 Get rid of some special cases for Cygwin in sys/types.h
Remove off_t typedef from cygwin/types.h thus relying on sys/types.h.
Introduce winsup/cygwin/machine/_types.h and move some types shared
with newlib into it.  Get rid of their definition in cygwin/types.h.
Add same handling for __key_t/key_t as for the other types.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-13 21:00:17 +02:00
Sebastian Huber 477463a201 Eliminate use of Newlib-specific <machine/types.h>
This change solves a glibc/BSD compatibility problem.

glibc and BSD use double underscore types for internal types.  The Linux
port of Newlib uses some glibc provided internal type definitions which
are not protected by guard defines, e.g. __off_t.  To avoid a conflict
Newlib uses single underscore types for some internal types, e.g.
_off_t.  However, for BSD compatibility we have to define the internal
types with double underscore names in <sys/_types.h>.

The header file <machine/types.h> is Newlib-specific.  It was used
instead of <sys/_types.h> to provide the internal type definitions
_CLOCK_T, _TIME_T_, _CLOCKID_T_, _TIMER_T_, and __suseconds_t.  Move
these definitions to <sys/_types.h> (there exist two instances of this
file, one for Linux and one for all other targets).  This makes the
_HAVE_SYSTYPES configuration define obsolete (could possibly break the
__RDOS__ target).  Use the standard <sys/_types.h> include throughout.

Move __loff_t defintion to default (non-Linux) <sys/_types.h>.  Define
it via _off64_t to avoid a dependency on the compiler.

Provide the __off_t definition via default (non-Linux) <sys/_types.h>
based on _off_t for all systems except Cygwin.  For Cygwin use _off64_t.
Define off_t via __off_t.

Provide the __pid_t definition via default (non-Linux) <sys/_types.h>.
This prevents a potential __pid_t and pid_t incompatibility.  Add BSD
guard defines for pid_t.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-13 13:30:27 +02:00
Corinna Vinschen eb6f1d7b77 Add Cygwin 2.5.1 release message file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-12 15:26:53 +02:00
Corinna Vinschen 002c9b468d Reformat comments in Cygwin's version.h, remove very outdated info
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-12 15:23:41 +02:00
Corinna Vinschen 308de2a1d4 Bump Cygwin DLL version to 2.5.1.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-12 15:18:29 +02:00
Corinna Vinschen e185421106 strxfrm/wcsxfrm: Always return length of the transformed string
Cygwin's strxfrm/wcsfrm treated a too short output buffer as an error
condition and always returned the size value provided as third parameter.
This is not as it's documented in POSIX.1-2008.  Rather, the only error
condition is an invalid input string(*).

Other than that, the functions are supposed to return the length of the
resulting sort key, even if the output buffer is too small.  In the latter
case the content of the output array is unspecified, but it's the job
of the application to check that the return value is greater or equal to
the provided buffer size.

(*) We have to make an exception in Cygwin:  strxfrm has to call the
    UNICODE function LCMapStringW for reasons outlined in a source comment.
    If the incoming multibyte string is so large that we fail to malloc
    the space required to convert it to a wchar_t string, we have to
    ser errno as well since we have nothing to call LCMapStringW with.

	* nlsfuncs.cc (wcsxfrm): Fix expression computing offset of
	trailing wchar_t NUL.  Compute correct return value even if
	output buffer is too small.
	(strxfrm): Handle failing malloc.  Compute correct return value
	even if	output buffer is too small.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-12 15:06:05 +02:00
Johannes Schindelin 03ecfb9280 Be truthful about reporting whether readahead is available
In 7346568 (Make requested console reports work, 2016-03-16), code was
introduced to report the current cursor position. It works by using a
pointer that either points to the next byte in the readahead buffer, or
to a NUL byte if the buffer is depleted, or the pointer is NULL.

These conditions are heeded in the fhandler_console::read() method, but
the condition that the pointer can point at the end of the readahead
buffer was not handled properly in the get_cons_readahead_valid()
method.

This poses a problem e.g. in Git for Windows (which uses a slightly
modified MSYS2 runtime which is in turn a slightly modified Cygwin
runtime) when vim queries the cursor position and immediately goes on to
read console input, erroneously thinking that the readahead buffer is
valid when it is already depleted instead. This condition results in an
apparent freeze that can be helped only by pressing keys repeatedly.

The full Git for Windows bug report is here:

	https://github.com/git-for-windows/git/issues/711

Let's just teach the get_cons_readahead_valid() method to handle a
depleted readahead buffer correctly.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-04-05 19:20:10 +02:00
Corinna Vinschen 8d67708a08 Add latest changes to release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-05 10:35:05 +02:00
Corinna Vinschen 41abcc5825 Revert "Refactor to avoid nonnull checks on "this" pointer."
This reverts commit 0008bdea02.

This patch introduced a regression.  Calling FOO=$(...) in zsh hangs
indefinitely and has to be killed forcefully.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-05 10:30:28 +02:00
Yaakov Selkowitz 959d58ea7c cygwin: update sysconf for new features
POSIX spawn and thread barriers have since been added.  Also fix a typo in
_POSIX2_C_DEV (result is the same).

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-04-04 10:25:36 -05:00
Yaakov Selkowitz 929be8005c cygwin/math: make isinf functions signed
glibc returns -1 for negative infinity:

http://man7.org/linux/man-pages/man3/isinfl.3.html
https://sourceware.org/bugzilla/show_bug.cgi?id=15367

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-04-04 10:25:34 -05:00
Yaakov Selkowitz b3acb347c4 Feature test macros overhaul: Cygwin pthread.h
As a Cygwin-specific header, there is no need to guard functions based on
capability macros.  Instead, guard several blocks based on additions or
removals in later versions of POSIX.1, along with a few which are only
XSI or GNU extensions.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-04-04 10:25:32 -05:00
Peter Foley 0008bdea02 Refactor to avoid nonnull checks on "this" pointer.
G++ 6.0 asserts that the "this" pointer is non-null for member
functions.
Refactor methods that check if "this" is non-null to resolve this.

winsup/cygwin/ChangeLog:
external.cc (cygwin_internal): Check for a null pinfo before calling
cmdline.
fhandler_dsp.cc (Audio::blockSize): Make static.
fhandler_dsp.cc (Audio_in): add default_buf_info.
fhandler_dsp.cc (Audio_out): Ditto.
fhandler_dsp.cc (Audio_out::buf_info): Refactor method to call
default_buf_info if dev_ is null.
fhandler_dsp.cc (Audio_in::buf_info): Ditto.
fhandler_dsp.cc (fhandler_dev_dsp::_ioctl): Call Audio_out::default_buf_info if audio_out_ is null.
fhandler_dsp.cc (fhandler_dev_dsp::_ioctl): Call Audio_in::default_buf_info if audio_in_ is null.
fhandler_process.cc (format_process_fd): Check if pinfo is null.
fhandler_process.cc (format_process_root): Ditto.
fhandler_process.cc (format_process_cwd): Ditto.
fhandler_process.cc (format_process_cmdline): Ditto.
signal.cc (tty_min::kill_pgrp): Ditto.
signal.cc (_pinfo::kill0): Ditto.
sigproc.cc (pid_exists): Ditto.
sigproc.cc (remove_proc): Ditto.
times.cc (clock_gettime): Ditto.
times.cc (clock_getcpuclockid): Ditto.
path.cc (cwdstuff::override_win32_cwd): Check if old_cwd is null.
path.cc (fcwd_access_t::Free): Factor null check of "this" out to
caller(s).
pinfo.cc (_pinfo::exists): Ditto.
pinfo.cc (_pinfo::fd): Ditto.
pinfo.cc (_pinfo::fds): Ditto.
pinfo.cc (_pinfo::root): Ditto.
pinfo.cc (_pinfo::cwd): Ditto.
pinfo.cc (_pinfo::cmdline): Ditto.
signal.cc (_pinfo::kill): Ditto.
pinfo.cc (_pinfo::commune_request): remove non-null check on "this", as
this method is only called from pinfo.cc after null checks
pinfo.cc (_pinfo::pipe_fhandler): remove non-null check on "this", as
this method is only called from pipe.cc (fhandler_pipe::open) after a null check.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-04-04 16:46:51 +02:00
Peter Foley e7e6119241 Rename without-mingw-progs to with-cross-bootstrap
Rename without-mingw-progs to with-cross-bootstrap, since it now
disables additional checks that are problematic for cross-compilers.

When cross-compiling a toolchain targeting cygwin, building cygwin1.dll
requires libgcc.
However, building libgcc requires the cygwin headers to be
installed.
Configuring cygwin requries the mingw-crt libraries, which require the
cygwin headers to be installed.
Work around this circular dependency by making the
--with-cross-bootstrap configure option skip cygwin's configure checks
for valid mingw-crt libraries. Cygwin will still properly link against
these libraries if they exist, but this allows configure to succeed even
if the libraries have not been built yet.
Since the mingw-crt libraries only require the cygwin headers to be
installed, this allows us to successfully configure cygwin so that we
can only install the headers without trying to build any
libraries.

winsup/ChangeLog
configure.ac: rename without-mingw-progs option to with-cross-bootstrap
configure: regenerate
winsup/cygserver/ChangeLog
configure.ac: don't check AC_WINDOWS_LIBS when using with-cross-bootstrap
configure: regenerate
winsup/cygwin/ChangeLog
configure.ac: don't check AC_WINDOWS_LIBS when using with-cross-bootstrap
configure: regenerate

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-04-04 16:39:41 +02:00
Corinna Vinschen 8e732f7f7f Remove MALLOC_CHECK and calls to it entirely
MALLOC_CHECK got useless with commit b259af5.  Remove it throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-01 14:04:09 +02:00
Peter Foley b259af51b8 Remove remnants of never-defined MALLOC_DEBUG and NEWVFORK
MALLOC_DEBUG and NEWVFORK haven't been defined since 2008 (4616253751).
Remove all references to tem.

winsup/cygwin/ChangeLog:
acconfig.h: delete
dcrt0.cc (dll_crt0_1): remove NEWVFORK code.
dcrt0.cc (do_exit): ditto.
debug.h: ditto.
dtable.h: ditto.
winsup.h: ditto.
globals.cc: ditto.
malloc_wrapper.cc: ditto.
malloc_wrapper.cc (malloc_init): ditto.
spawn.cc (spawnve): ditto.
syscalls.cc (setsid): ditto.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-04-01 13:53:25 +02:00
Peter Foley 02cfe00445 Don't use deprecated acconfig.h for DEBUGGING
Use the 3-arg form of AC_DEFINE.

winsup/cygwin/ChangeLog:
acconfig.h: Remove DEBUGGING define.
configure.ac: Add description to DEBUGGING define.
config.h.in: Regenerate.
configure: Ditto.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-04-01 13:46:04 +02:00
Peter Foley 5d89883790 Remove leftover cruft from config.h.in
HAVE_BUILTIN_MEMTEST and AC_ALLOCA were removed in 4bd8eb7d1b.
Cleanup leftover references.

winsup/cygwin/ChangeLog
acconfig.h: remove HAVE_BUILTIN_MEMTEST
config.h.in: regenerate

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-04-01 13:44:11 +02:00
Corinna Vinschen c8022ae3f0 mkvers.sh: Reformatting for better readability
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-30 17:06:50 +02:00
Peter Foley 4eca5e6a3f Use just-built gcc for windres
When building cygwin in a combined tree with binutils,
the just-built windres cannot find the just-buit gcc automatically.
Parse the CC env variable to use the correct compiler, rather then
falling back to the build-system's gcc which does not define the proper
preprocessor macros.

winsup/cygwin/ChangeLog
mkvers.sh: Manually specify preprocessor based on $CC

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-30 16:52:36 +02:00
Peter Foley 31dfc51a36 fix typo in netinit/ip.h
The type for the ip_tos member was typoed, fix it.

winsup/cygwin/ChangeLog:
include/netinet/ip.h: fix type of ip_tos

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-30 16:51:40 +02:00
Corinna Vinschen d6c651040d Add dependencies to tlsoffsets file
After `make clean', the build can fail because the dependencies don't
require the tlsoffsets file to exist before building obejct files.
This patch fixes it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-30 14:35:46 +02:00
Corinna Vinschen 6436024c4c Replace AC_CANONICAL_SYSTEM with AC_CANONICAL_TARGET, fix AC_INIT usage
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-30 14:09:19 +02:00
Corinna Vinschen 279aaeb5c7 fenv.h: Change fexcept_t to integral type for compatibility
On Linux and in Mingw-w64, fexcept_t is defined as type unsigned short.
There are packages in the wild which rely on the fact that fexcept_t is
an integral type.  We're changing the internal handling to use the bits
just as in GLibc, so only the 6 lowest bits are used to reflect the hw
bits.  We even change the header file guard to reflect GLibc for compatibility.

	* include/fenv.h (_FENV_H): Rename from _FENV_H_ and set to 1 as in
	GLibc's header.
	(fexcept_t): Change to __uint16_t to be an integral type as in GLibc.
	* fenv.cc (fegetexceptflag): Align to the *flagp's type change.
	(fesetexceptflag): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-30 12:55:42 +02:00
Corinna Vinschen a638b8580b Add missing nanl
* Makefile.in (MATH_OFILES): Add nanl.o.
	* common.din (nanl): Export.
	* math/nanl.c: New file.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-29 17:39:17 +02:00
Corinna Vinschen 63e4f1291c Add release message for 792e51b
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-29 14:59:18 +02:00
Corinna Vinschen 792e51b721 Add missing long double functions to Cygwin
This patch adds the long double functions missing in newlib to Cygwin.
Apart from some self-written additions (exp10l, finite{f,l}, isinf{f,l},
isnan{f,l}, pow10l) the files are taken from the Mingw-w64 math lib.
Minor changes were required, e.g. substitue _WIN64 with __x86_64__ and
fixing __FLT_RPT_DOMAIN/__FLT_RPT_ERANGE for Cygwin.

Cygwin:
	* math: New subdir with math functions.
	* Makefile.in (VPATH): Add math subdir.
	(MATH_OFILES): List of object files collected from building files in
	math subdir.
	(DLL_OFILES): Add $(MATH_OFILES).
	${CURDIR}/libm.a: Add $(MATH_OFILES) to build.
	* common.din: Add new functions from math subdir.
	* i686.din: Align to new math subdir.  Remove functions now commonly
	available.
	* x86_64.din: Ditto.
	* math.h: math.h wrapper to define mingw structs used in some files in
	math subdir.
	* include/cygwin/version.h: Bump API minor version.

newlib:
	* libc/include/complex.h: Add prototypes for complex long double
	functions.  Only define for Cygwin.
	* libc/include/math.h: Additionally enable prototypes of long double
	functions for Cygwin.  Add Cygwin-only prototypes for dreml, sincosl,
	exp10l and pow10l.  Explain why we don't add them to newlib.
	* libc/include/tgmath.h: Enable long double handling on Cygwin.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-29 14:43:55 +02:00
Corinna Vinschen 087aca6163 Fix Cygwin setstate definition
setstate is supposed to take a char *, not a const char *.

	* random.cc (setstate): Unconstify parameter to align to stdlib.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-29 13:41:11 +02:00
Yaakov Selkowitz 660f84b15b cygwin: export __getpagesize
The inclusion of <sys/cygwin.h> by <sys/shm.h>, besides causing namespace
pollution, also makes it very difficult to get the WINVER-dependent parts
of the former.  This affects code (such as x11vnc -unixpw_nis) which use
both SysV shared memory (e.g. the X11 MIT-SHM extension) and user password
authentication.

getpagesize is the simplest function to retreive this information, but it
is a legacy function and would also pollute the global namespace. The LSB
lists another form which is in the implementation-reserved namespace:

http://refspecs.linuxfoundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/baselib---getpagesize.html

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-29 12:14:18 +02:00
Joel Sherrill ecf453f963 Add simple versions of random() and srandom()
Prototypes also added for initstate() and setstate() but they
were not implemented in the shared newlib code.

	* newlib/libc/include/cygwin/stdlib.h: Prototypes added.
	* winsup/cygwin/include/cygwin/stdlib.h: Prototypes removed.
	* newlib/libc/stdlib/random.c: New file.
	* newlib/libc/machine/epiphany/machine/stdlib.h: Removed
	* newlib/libc/stdlib/Makefile.am: Added random.c.
	* newlib/libc/stdlib/stdlib.tex: Added random.def.
	* newlib/libc/stdlib/Makefile.in: Regenerated.
2016-03-28 22:39:50 -05:00
Corinna Vinschen a0c4772429 Add release text for 373f81d and 3e446e9
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-26 20:38:30 +01:00
Corinna Vinschen acc5f02ce8 Throughout Cygwin, use u_intN_t or uintN_t
Don't use u_char, u_short, u_int or u_long in Cygwin, unless it refers
to the Winsock types.  Use u_intN_t in BSD-based sources, unsigned char
where strings are concerned, uintN_t otherwise.  Also:

	* net.cc: Fix comment, we're not using u_long anymore.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-24 16:39:15 +01:00
Corinna Vinschen 6ba2b53c53 Change definition of b64_pton from K&R to ANSI
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-24 16:25:00 +01:00
Corinna Vinschen 34adefae7f Fix return type of get_routedst
* net.cc (get_routedst): Correctly return in_addr_t.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-24 16:23:50 +01:00
Corinna Vinschen c133a6a3d1 Remove unused function convert_ifr_flags
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-24 16:22:30 +01:00
Corinna Vinschen 977912ff93 Fix FIONBIO comments
FIONBIO is defined in sys/termios.h and asm/socket.h.  Align the comments.
Remove unused REAL_FIONBIO.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-24 16:12:28 +01:00
Corinna Vinschen b1b46d4580 Drop usage of old-age BSD types in generically used Cygwin headers
u_char, u_short, u_int, u_long are BSD-only types.  Remove them from
Cygwin headers which are supposed to be used in a non-BSD scenario.
Drop special Cygwin handling of those types in sys/types.h.

newlib:
	* libc/include/sys/types.h (u_char,u_short,u_int,u_long): Drop
	Cygwin exception.

cygwin:
	* fhandler_socket.cc (fhandler_socket::ioctl): Accommodate change
	in include/asm/socket.h.  Continue using u_long since that's the
	MS type here.
	* include/asm/socket.h: Since the type given in _IOR/_IOW macros
	is only used for its sizeof, replace u_long with equivalent long.
	* netdb.h (getnetbyaddr): Fix prototype.
	* netinet/ip.h: Replace old BSD-only types with generically defined
	old BSD types (u_char -> u_int8_t, etc).
	* netinet/tcp.h: Ditto.
	* netinet/udp.h: Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-24 15:55:25 +01:00
Corinna Vinschen db5bfdbd8a Define BSD u_intN_t types indiscriminately
The u_intN_t types are BSD types but sanctioned by POSIX.  They are
always defined when using Glibc headers so we follow suit.

newlib:
	* libc/include/sys/types.h: Drop outdated __INTTYPES_DEFINED__
	macro.  Always define u_intN_t types.

cygwin:
	* include/cygwin/types.h: Remove definition of u_intN_t types.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-24 15:51:14 +01:00
Corinna Vinschen 5b08c1bca1 Add release message for commit 59b3bd2 2016-03-23 18:11:38 +01:00
Corinna Vinschen 59b3bd2aa6 Only allow enabled groups as primary group
So far any group in the user's token could be used as primary group.
Windows doesn't check if the primary group is enabled or not, it just
has no meaning.  From a POSIXy point of view it can lead to weird
results though.

	* uinfo.cc (check_token_membership): New static function.
	(internal_getlogin): Only allow enabled groups as primary group.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-23 17:51:03 +01:00
Corinna Vinschen fc504453fd Use 64K buffers for TOKEN_GROUPS
A user token can be up to 64K in size.  Using 32K buffers for TOKEN_GROUPS
may be insufficient.

	* uinfo.cc (get_logon_sid): Use 64K buffers for the TOKEN_GROUPS
	array.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-23 17:42:04 +01:00
Corinna Vinschen 155a1ec5fb Allocate temporary TOKEN_GROUP arrays using TLS
A user token can be up to 64K in size.  The group list might take a lot
of that so use tmp_pathbuf allocated space rather than stack space
allocted via alloca.  In create_token the TOKEN_GROUP was allocated via
malloc, but the code is needlessly complicated.  Simplify by using
tmp_pathbuf as well.

	* sec_auth.cc (verify_token): Allocate TOKEN_GROUP via tmp_pathbuf.
	(create_token): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-23 17:40:24 +01:00
Corinna Vinschen 117737a7fa cxx.cc: Disable C++14 warning for new sized delete operator
As long as we're not building in C++14 mode, the definition of the
sized delete operator results in a compatibility warning.

	* cxx.cc (operator delete): Disable C++14 warning for sized	variant.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-23 11:58:21 +01:00
Peter Foley 93c13ec6cc Add c++14 sized deallocation operator
When compiling with -std=c++14 (the default for gcc 6.0+), the sized
deallocation operator must be defined to prevent undefined symbols when
linking.

winsup/cygwin/ChangeLog:
cxx.cc (operator delete(void *p, size_t)): Define.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-23 11:51:22 +01:00