Commit Graph

7489 Commits

Author SHA1 Message Date
Corinna Vinschen dcf31cdc99 Implement getentropy for Cygwin
* miscfuncs.cc (getentropy): Move fhandler_dev_random::crypt_gen_random
	here and rename to getentropy.  Fix type and return values to match
	getentropy requirements.
	* miscfuncs.h (getentropy): Add prototype.
	* fhandler.h (fhandler_dev_random::crypt_gen_random): Remove prototype.
	* fhandler_random.cc (fhandler_dev_random::crypt_gen_random): Drop.
	(fhandler_dev_random::write): Use getentropy instead.
	(fhandler_dev_random::read): Ditto.
	* fhandler_socket.cc (fhandler_socket::af_local_set_secret): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-18 14:46:20 +01:00
Corinna Vinschen e0fc33322d Delete Cygwin's arc4random in favor of new Newlib implementation
* Makefile.in (DLL_OFILES): Remove arc4random.o.
	* libc/arc4random.c: Remove file.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-18 14:41:33 +01:00
Yaakov Selkowitz 00d2fe1959 Cygwin: define byteswap.h inlines as macros
The bswap_* "functions" are macros in glibc, so they may be tested for
by the preprocessor (e.g. #ifdef bswap_16).

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:23 -05:00
Yaakov Selkowitz 3237fb31b3 Feature test macros overhaul: Cygwin headers
Use proper internal macros for BSD and GNU.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:22 -05:00
Yaakov Selkowitz 43e5ee83fe Feature test macros overhaul: time.h
Throughout, replace __STRICT_ANSI__ with the proper internal macros.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:10 -05:00
Yaakov Selkowitz 84ba25226c Feature test macros overhaul: stdlib.h
Throughout, simplify the C99/C11 conditionals, and replace
__STRICT_ANSI__ with the proper internal POSIX macros.  The _*_r
reentrant functions need not be guarded (and most haven't been) because
such names in the global scope are reserved to the implementation.

atoff is unique to newlib.

dtoa is not actually exported (_dtoa_r is used internally), is
nonstandard, and the declaration conflicts with the code included in
MySQL, NSPR, and SpiderMonkey.

mktemp was removed in POSIX.1-2001.

The qsort_r declarations are reordered so that the GNU version retains
precedence.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:06 -05:00
Yaakov Selkowitz 86a724b8c0 Feature test macros overhaul: limits.h
Simplify the C99 conditional, and use the internal macro for GNU extensions.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:08:57 -05:00
Yaakov Selkowitz d94d983d1b Feature test macros overhaul: fnmatch.h
Use the proper internal macro for GNU extensions.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:08:54 -05:00
Yaakov Selkowitz d2937299fa Feature test macros overhaul: dirent.h
MAXNAMLEN is a BSDism.

Use the proper internal macros instead of !_POSIX_SOURCE.  telldir and
seekdir are XSI, scandir and alphasort are POSIX.1-2008, and scandirat
is GNU.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:08:51 -05:00
Corinna Vinschen 446d0d355f add release message for commit 4c9bb3e
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-17 17:58:43 +01:00
Corinna Vinschen 4c9bb3e0f9 Propagate correct Windows error if executable can't be opened
* spawn.cc (av::setup): Set last Win32 error if NtOpenFile fails.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-17 17:46:11 +01:00
Thomas Wolff aa2d448093 Add release message for commit 7346568 2016-03-17 08:59:17 +01:00
Thomas Wolff 734656818a Make requested console reports work
cf https://cygwin.com/ml/cygwin-patches/2012-q3/msg00019.html

This enables the following ESC sequences:
ESC[c sends primary device attributes
ESC[>c sends secondary device attributes
ESC[6n sends cursor position report

    * fhandler.h (class dev_console): Add console read-ahead buffer.
    (class fhandler_console): Add peek function for it (for select).
    * fhandler_console.cc (fhandler_console::setup): Init buffer.
    (fhandler_console::read): Check console read-aheader buffer.
    (fhandler_console::char_command): Put responses to terminal
    requests (device status and cursor position reports) into
    common console buffer (shared between CONOUT/CONIN)
    instead of fhandler buffer (separated).
    * select.cc (peek_console): Check console read-ahead buffer.
2016-03-16 10:25:34 +01:00
Corinna Vinschen 7176a85cd4 cygwin_getaddrinfo: workaround Winsock getaddrinfo issue with broken DNS
Add experimental code to workaround the issue described in the thread
starting at

  https://cygwin.com/ml/cygwin/2015-07/msg00350.html

There's a hint in https://communities.vmware.com/message/2577858#2577858
that this problem is related to using the AI_ALL flag.

This patch checks if GetAddrInfoW returned with WSANO_RECOVERY and if
the AI_ALL flag was set, it retries GetAddrInfo without the AI_ALL flag.

	* net.cc (cygwin_getaddrinfo): Add experimental code to retry
	GetAddrInfoW without AI_ALL flag if it returned with WSANO_RECOVERY.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-14 17:57:22 +01:00
Corinna Vinschen f75114fc59 Don't write NULL SID ACE if it's not necessary.
If the ACL is supposed to reflect only standard POSIX permissions,
and if the permissions are so that user has more perms than group
and group has more perms than other, we don't really need the NULL
SID ACE.  If the permissions are that simple, get_posix_access will
not call AuthZ.

	* sec_acl.cc (set_posix_perms): Don't write NULL SID ACE if it's
	not required.  Explain why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-13 16:02:55 +01:00
Corinna Vinschen ddc91e5b2b Update Cygwin release message text with latest bugfixes.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-13 00:20:39 +01:00
Corinna Vinschen fcd8a0d4f4 Fix typo which might break permission evaluation
* sec_acl.cc (get_posix_access): Fix a typo checking for a_id
	rather than a_type.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-12 17:57:34 +01:00
Corinna Vinschen fc180edcf4 Fix reading/writing Samba ACLs using RFC2307 mapping
When using RFC2307 uid/gid-mapping on Samba shares, the POSIX ACL contains
the Windows SIDs.  When writing back such an ACL we have to map the
Windows SIDs back to the corresponding Samba SIDs representing the UNIX
uid/gid value.  When reading Samba SIDs, make sure never to evaluate a
UNIX user account as group.

	* sec_acl.cc (set_posix_access): Convert Windows SIDs to
	RFC2307-mapped Sambe UNIX SIDs.
	* sec_helper.cc (cygpsid::get_id): Skip UNIX user accounts when
	trying to evaluate a SID as group.  Skip UNIX group accounts when
	trying to evaluate a SID as user.
	* cygheap.h (cygheap_ugid_cache::reverse_get): New method to
	get nfs id from cygwin id.
	(cygheap_ugid_cache::reverse_get_uid): Wrapper for uids.
	(cygheap_ugid_cache::reverse_get_gid): Wrapper for gids.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-12 17:56:21 +01:00
Corinna Vinschen 018fa93e2b Add cygsid methods to create SIDs from scratch
So far creating cygsids requires to generate an "S-1-..." string
which is then converted to a SID by cygsid::getfromstr.

Add two new methods:

- cygsid::create (DWORD auth, DWORD subauth_count, ...)

    ... is a variable length list of subauth_count DWORD values being
    the actual subauths.

- cygsid::append (DWORD rid)

    allows to append a single RID to an alreaday constituted SID.

	* security.h (cygsid::create): Declare public.
	(cygsid::append): Ditto.
	* sec_helper.cc (cygsid::create): Implement.
	(cygsid::append): Implement.
	* uinfo.cc (pwdgrp::fetch_account_from_windows): Use both new
	methods as appropriate.  Drop setting csid from string.  Create
	SID strings for printing SIDs only.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-12 16:39:19 +01:00
Corinna Vinschen 5b972d5b29 gmon.h: Fix type of gmonparam state member
gmonparam::state is used in calls to Win32 Interlocked functions.
Having this defined as int breaks the build on i686.  Redefine as
LONG (same size and correct type on all platforms) to make gcc happy.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-11 22:50:24 +01:00
Václav Haisman b5476c81d2 Spinlock spin with pause instruction
Hi.

I have noticed that Cygwin's spinlock goes into heavy sleeping code
for each spin. It seems it would be a good idea to actually try to
spin a bit first. There is this 'pause' instruction which let's the
CPU make such busy loops be less busy. Here is a patch to do this.

--
VH
2016-03-11 14:01:25 +01:00
Corinna Vinschen bf81f082cd Add release message for commit 8b1ede3ce1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-10 20:48:04 +01:00
Corinna Vinschen 60fd26a4df Add release message for commit 5807ba83e4
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-10 20:42:42 +01:00
Mark Geisert 5807ba83e4 Support profiling of multi-threaded apps.
This patch set modifies Cygwin's profiling support to sample PC values
of all an app's threads, not just the main thread. There is no change
to how profiling is requested: just compile and link the app with "-pg"
as usual. The profiling info is dumped into file gmon.out as always.

A new facility enabled via the environment variable GMON_OUT_PREFIX.
This facility is intended to match an undocumented Linux glibc feature.
Exporting the variable with a non-empty value such as "foo" causes the
profiling info to go to a file named foo.$pid instead of the default.
With that, both resulting processes of a fork() can have their profiling
data captured in separate files. gprof already knows how to accumulate
data from multiple files if they all pertain to the same app.

There is no change to the normal Cygwin execution paths if profiling is
not enabled. And when it is enabled, only the one profiling thread per
profiled app is doing more work than it used to.

	* include/sys/cygwin.h: Add CW_CYGHEAP_PROFTHR_ALL.
	* cygheap.cc (cygheap_profthr_all): New C-callable function that
	runs cygheap's threadlist handing each pthread's thread handle in
	turn to profthr_byhandle().
	* external.cc (cygwin_internal): Add case CW_CYGHEAP_PROFTHR_ALL.
	* gmon.c (_mcleanup): Add support for multiple simultaneous
	gmon.out* files named via environment variable GMON_OUT_PREFIX.
	* gmon.h (struct gmonparam): Make state decl volatile.
	* mcount.c (_MCOUNT_DECL): Change stores into gmonparam.state to use
	Interlocked operations. Add #include "winsup.h", update commentary.
	* profil.c (profthr_byhandle): New function abstracting out the
	updating of profile counters based on a thread handle.
	(profthr_func): Update to call profthr_byhandle() to sample the main
	thread then call cygheap_profthr_all() indirectly through
	cygwin_internal(CW_CYGHEAP_PROFTHR_ALL) to sample all other threads.
	(profile_off): Zero targthr to indicate profiling was turned off.
	(profile_on): Fix handle leak on failure path.
	(profile_child): New callback func to restart profiling in child
	process after a fork if the parent was being profiled.
	(profile_ctl): Call pthread_atfork() to set profile_child callback.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-10 20:39:46 +01:00
Corinna Vinschen 65231f415a getifaddrs: Return pointer to extended interface info in ifa_data member
According to https://cygwin.com/ml/cygwin/2016-03/msg00124.html it's a
problem to collect friendlyname info using AF_INET6 sockets.  Fix problem
by exposing additional hardware info for all collected interfaces via the
pointer in the ifaddrs::ifa_data member.

	* include/ifaddrs.h (struct ifaddrs_hwdata): Define as struct of
	not yet exposed members of struct ifall, defined in net.cc.
	* net.cc (struct ifall): Replace hardware dta members with struct
	ifaddrs_hwdata.  Accommodate throughout.
	(get_ifs): Let ifaddrs ifa_data member point to ifall::ifa_hwdata
	member.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-10 18:00:00 +01:00
Corinna Vinschen f368589492 Revamp acl_extended_fd/acl_extended_file to avoid open(2) call
Calling open from acl_extended_file{_nofollow} indiscriminately may hang
if the file is a FIFO.  Ultimately the FIFO implementation needs a thorough
rewrite, but for the time being we better do what stat(2) and friends do:
Just create an fhandler directly.

	* sec_posixacl.cc (__acl_extended_fh): New static function calling
	fhandler::facl.
	(acl_extended_fd): Just call __acl_extended_fh.
	(__acl_extended_file): Take just a path_conv as parameter and
	create temporary fhandler to call __acl_extended_fh.
	(acl_extended_file): Create path_conv from incoming path and
	call __acl_extended_file on it.
	(acl_extended_file_nofollow): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-10 10:36:00 +01:00
Corinna Vinschen 48511f3d38 Overwite potentially faked kernel version with correct values
* ntdll.h (RtlGetNtVersionNumbers): Declare.
	* wincap.cc (wincapc::init): Overwrite kernel version info
	returned by RtlGetVersion with correct info returnd by
	RtlGetNtVersionNumbers.  Add comment.

Originally, using RtlGetVersion instead of GetVersionEx was supposed to
fix the fact that GetVersionInfo returns the wrong kernel version if the
executable has been built with an old manifest (or none at all), starting
with Windows 8.1.  Either this never really worked as desired and our
testing was flawed, or this has been changed again with Windows 10, so
that RtlGetVersion does the kernel faking twist as well.  Since we're
only reading the value in the first process in a process tree. the entire
process tree is running with a wrong OS version information in that case.

Fortunately, the (undocumented) RtlGetNtVersionNumbers function is not
affected by this nonsense, so we simply override the OS version info
fields with the correct values now.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-09 23:10:17 +01:00
Corinna Vinschen 264b5e137e Move definition of wsadata into wsock_init
The problem this patch fixes showed up after updating to gcc-5.3.0.  The
cuplrit is a change in gcc when emitting section attributes.  It only
shows up when building without optimization.  Effect in Cygwin: ws2_32
functions failed to load.

In the original code the definition of "NO_COPY wsadata" was preceeding
an __asm__ block (the definition of the _wsock_init wrapper), while the
definition of "NO_COPY here" immediately follows the same assembler
block.  When gcc-5.3.0 emits assembler code for the wsadata definition,
it emits the .data_cygwin_nocopy section attribute.

Next it emits the assembler output for the __asm_ block, entirely ignoring
its content.  The __asm__ block adds a .text section definition.

Eventually gcc emits assembler code for the here definition.  However,
apparently gcc still "knows" that it just emitted the .data_cygwin_nocopy
section attribute and so doesn't redefine it.  Remember the __asm__?  It
changed the section to .text.

So with gcc-4.9.3 we got:

    .section .data_cygwin_nocopy,"w"
  wsadata:

  __asm__ block:
    .text

    .section .data_cygwin_nocopy,"w"
  here:

With gcc 5.3.0 we now get:

    .section .data_cygwin_nocopy,"w"
  wsadata:

  __asm__ block:
    .text

  here:

So "here" is now in the .text segment which is read-only.  Hilarity ensues.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-09 22:55:28 +01:00
Corinna Vinschen c09e96fda0 Cygwin: Document new POSIX ACL API
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-08 17:33:08 +01:00
Corinna Vinschen e4ecb5b96a acl_create_entry: Don't invalidate existing entry_d and permset_d.
* sec_posixacl .cc (__acl_dup): Remove.
	(acl_dup): Fold __acl_dup functionality into this function.
	(acl_create_entry): Don't create new acl_t.  Just realloc
	acl->entry to make room for new aclent_t.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-08 13:56:40 +01:00
Corinna Vinschen 3d88f10983 __acltotext: Always append NUL
* sec_acl.cc (__acltotext): Append NUL unconditionally.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-08 13:56:40 +01:00
Corinna Vinschen 9ddf063921 Implement POSIX.1e ACL functions
* Makefile.in (DLL_OFILES): Add sec_posixacl.o.
	(SUBLIBS): Add libacl.a
	(libacl.a): New rule to create libacl.a.
	* common.din: Export POSIX ACL functions as well as most libacl.a
	extensions.
	* fhandler.h (fhander_base::acl_get): New prototype.
	(fhander_base::acl_set): Ditto.
	(fhandler_disk_file::acl_get): Ditto.
	(fhandler_disk_file::acl_set): Ditto.
	* include/acl/libacl.h: New file.
	* include/cygwin/version.h: Bump API minor version.
	* include/sys/acl.h: Drop including cygwin/acl.h.  Accommodate
	throughout Cygwin.  Add POSIX ACL definitions.
	* sec_acl.cc: Include sec_posixacl.h.  Replace ILLEGAL_UID and
	ILLEGAL_GID with ACL_UNDEFINED_ID where sensible.
	(__aclcheck): New internal acl check function to be used for
	Solaris and POSIX ACLs.
	(aclcheck32): Call __aclcheck.
	(__aclcalcmask): New function to compute ACL_MASK value.
	(__aclsort): New internal acl sort function to be used for Solaris
	and POSIX ACLs.
	(aclsort32): Call __aclsort.
	(permtostr): Work directly on provided buffer.
	(__acltotext): New internal acltotext function to be used for
	Solaris and POSIX ACLs.
	(acltotext32): Call __acltotext.
	(__aclfromtext): New internal aclfromtext function to be used for
	Solaris and POSIX ACLs.
	(aclfromtext32): Call __aclfromtext.
	* sec_posixacl.cc: New file implemeting POSIX ACL functions.
	* sec_posixacl.h: New internal header.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-08 13:56:40 +01:00
Corinna Vinschen edd7d93484 cygwin/acl.h: Don't clutter namespace
include/cygwin/acl.h: Change comments to /**/ style.  Reformat
	declarations.  Use underscores in argument names.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-08 13:56:40 +01:00
Yaakov Selkowitz 8b1ede3ce1 cygwin: Export clog10, clog10f
winsup/cygwin/
	* common.din: Add clog10, clog10f.
	* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.

	winsup/doc/
	* new-features.xml (ov-new2.5): Mention clog10, clog10f.
	* posix.xml (std-gnu): Add clog10, clog10f.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-02-22 14:45:37 -06:00
Corinna Vinschen b89d317cdc Fix comments in sec_acl.cc
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-22 10:54:13 +01:00
Corinna Vinschen 609feee9e5 Update Cygwin release notes.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-18 15:56:51 +01:00
Yaakov Selkowitz 7503575f1d cygwin: accept SIGIOT as alias of SIGABRT
winsup/cygwin/
	* include/cygwin/signal.h (SIGIOT): Define SIGIOT in terms of SIGABRT.
	* strsig.cc (struct sigdesc): Ditto.

	winsup/doc/
	* utils.xml (kill): Document SIGIOT.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-02-18 08:20:03 -06:00
Corinna Vinschen 2ceb202bc1 Drop temporary declaration of GetSystemTimePreciseAsFileTime.
* times.cc (GetSystemTimePreciseAsFileTime): Remove declaration
	and accompanying comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-18 12:38:24 +01:00
Corinna Vinschen 205862ed08 setuid: Create token from scratch without credentials of caller
* sec_auth.cc (get_token_group_sidlist): Drop auth_luid and
	auth_pos parameter.  Remove code adding a logon SID.
	(get_initgroups_sidlist): Drop auth_luid and auth_pos parameter.
	Drop in call to get_token_group_sidlist. Accommodate in callers.
	(get_setgroups_sidlist): Ditto.
	(create_token): Explicitely set auth_luid to ANONYMOUS_LOGON_LUID
	or LOCALSERVICE_LUID depending on OS.  Explain why.
	Remove handling of logon SID since we don't generate one anymore.
	(lsaauth): Drop now unused local variable auth_luid and auth_pos.
	* wincap.h (wincaps::has_broken_whoami): New element.
	* wincap.cc: Implement above element throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-18 11:22:12 +01:00
Mark Geisert 70e7f94e9f Silent relocation truncations considered harmful
This follows up from my msg re GMP-ECM failing its 'make check' on the
main list https://cygwin.com/ml/cygwin/2016-02/msg00147.html .

There's an error that ought to be reported during dynamic linking if the
linked-to address is too far from the relocation site.  However the error
is not reported if __OPTIMIZE__ was #defined when building the Cygwin DLL.
I can't see why optimization settings should affect this.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-17 10:55:28 +01:00
Corinna Vinschen 4c59f62ef9 cygwin_conv_path: Really always preserve trailing slash in conversion to POSIX path
* mount.cc (mount_info::conv_to_posix_path): Account for scenarios
	where the path is identical to a mount point in terms of preserving
	the trailing slash in the output.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-15 16:25:10 +01:00
John Hood 7eb13b33e4 Make buffered console characters visible to select(). 2016-02-15 13:28:56 +01:00
Corinna Vinschen c76954517f Remove local winbase.h (again).
Mingw32-w64 supports all required inline Interlocked functions in the
meantime.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-13 16:56:12 +01:00
Corinna Vinschen 9a25a76e7b Bump Cygwin version to 2.5.0
Add a release file.  Add release text to documentation.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-13 16:55:00 +01:00
Václav Haisman 813da84442 POSIX barrier implementation, take 3
The attached patch should address all of the review comments.

Modifed change log:

Newlib:

	* libc/include/sys/features.h (_POSIX_BARRIERS): Define for Cygwin.
	* libc/include/sys/types.h (pthread_barrier_t)
	(pthread_barrierattr_t): Do not define for Cygwin.

Cygwin:

	* common.din (pthread_barrierattr_init)
	(pthread_barrierattr_setpshared, pthread_barrierattr_getpshared)
	(pthread_barrierattr_destroy, pthread_barrier_init)
	(pthread_barrier_destroy, pthread_barrier_wait): Export.
	* include/cygwin/types.h (pthread_barrierattr_t)
	(pthread_barrier_t): Declare.
	* include/pthread.h (PTHREAD_BARRIER_SERIAL_THREAD)
	(pthread_barrierattr_init, pthread_barrierattr_setpshared)
	(pthread_barrierattr_getpshared, pthread_barrierattr_destroy)
	(pthread_barrier_init, pthread_barrier_destroy)
	(pthread_barrier_wait): Declare.
	* thread.h (PTHREAD_BARRIER_MAGIC)
	(PTHREAD_BARRIERATTR_MAGIC): Define.
	(class pthread_barrierattr, class pthread_barrier): Declare.
	* thread.cc (delete_and_clear): New local helper function.
	(class pthread_barrierattr, class pthread_barrier): Implement.
	* miscfuncs.h (likely, unlikely): New macros.

--
VH
2016-02-13 16:03:15 +01:00
Yaakov Selkowitz ef64aa4940 cygwin: work around GCC 5 preprocessor changes
GCC 5 adds #line directives (and hence extra newlines) for macros
expansions, which confuses cygmagic.  Using the -P flag avoids
them entirely.

https://cygwin.com/ml/cygwin-patches/2016-q1/msg00016.html

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-02-13 15:59:55 +01:00
Corinna Vinschen 919137b3d8 Bump Cygwin version to 2.4.2.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-12 21:23:20 +01:00
Yaakov Selkowitz c5f03820fc cygwin: fix errors with GCC 5
GCC 5 switched from C89 to C11 by default. This implies a change from
GNU to C99 inline by default, which have very different meanings of
extern inline vs. static inline:

https://gcc.gnu.org/onlinedocs/gcc/Inline.html

Marking these as gnu_inline retains the previous behaviour.

	winsup/cygwin/
	* exceptions.cc (exception::handle): Change debugging to int to fix
	an always-true boolean comparison warning.
	* include/cygwin/config.h (__getreent): Mark gnu_inline.
	* winbase.h (ilockcmpexch, ilockcmpexch64): Ditto.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-02-12 12:08:40 -06:00
Corinna Vinschen 8b83da2d55 cygwin_conv_path: Always preserve trailing backslashes in conversion to POSIX paths
* include/sys/cygwin.h (CCP_CONVFLAGS_MASK): Define.
	* mount.h (__CCP_APP_SLASH): Define.
	* mount.cc (mount_info::conv_to_posix_path): Handle __CCP_APP_SLASH
	flag.
	* path.cc (cygwin_conv_path): Use CCP_CONVFLAGS_MASK to evaluate
	"how" flag values.  Always add __CCP_APP_SLASH flag when calling
	mount_info::conv_to_posix_path.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-09 15:00:30 +01:00
Corinna Vinschen ac4648c13e Treat ACLs with extra ACEs for Admins and SYSTEM like a trivial ACL
POSIX.1e requires that chmod changes the MASK rather than the
	GROUP_OBJ value if the ACL is non-trivial.

	On Windows, especially on home machines, a standard ACL often
	consists of entries for the user, maybe the group, and additional
	entries for SYSTEM and the Administrators group.  A user calling
	chmod on a file with bog standard Windows perms usually expects
	that chmod changes the GROUP_OBJ perms, but given the rules from
	POSIX.1e we can't do that.

	However, since we already treat Admins and SYSTEM special in a
	ACL (they are not used in MASK computations) we go a step in the
	Windows direction to follow user expectations.  If an ACL only
	consists of the three POSIX permissions, plus entries for Admins
	and SYSTEM *only*, then we change the permissions of the GROUP_OBJ
	entry *and* the MASK entry.

	* fhandler_disk_file.cc (fhandler_disk_file::chmod): Drop unused
	code.  Add special handling for a "standard" Windows ACL.  Add
	comment to explain.
	* sec_acl.cc (get_posix_access): Allow to return "standard-ness"
	of an ACL to the caller.  Add preceeding comment to explain a bit.
	* security.h (get_posix_access): Align prototype.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-28 22:05:49 +01:00