Commit Graph

11059 Commits

Author SHA1 Message Date
Corinna Vinschen 2b174636e5 Add commit 5807ba83e release message to documentation
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-10 20:47:33 +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
Jon Turney 930474058e faq: Sort BLODA list and update advice on fixing fork failures
* faq-using.xml (bloda): Alphabetically sort BLODA list for ease
	of finding things in it.
	(fixing-fork-failures): Update to suggest rebase-trigger rather
	than running rebaseall via dash yourself.  Mention detect_bloda
	CYGWIN token.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-03-08 14:39:41 +00: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
Alexey Sokolov bf45e12fb6 Mention 64-bit Cygwin as another remedy for fork() failures. 2016-03-04 22:02:35 +01:00
Patrick Bendorf 2cd76694e1 ccwrap: fix build with non-english locale set (v2)
after some discussion on irc and the list i'm resubmitting a simpler
version of the patch.
setting the locale on cygwin to 'C.UTF-8' is not needed, so i'm always
setting it to 'C' which is sufficient for the build process and the
most simple fix.
2016-02-29 14:44:23 +01:00
Patrick Bendorf 5b88b62562 ccwrap: fix build with non-english locale set
short explanation: after setting up cygwin on my systems the default
locale is set to "de_DE.UTF-8". this leads to ccwrap not picking up
certain "-isystem" arguments, which in turn leads to "stddef.h: no such
file or directory". this breaks the build process for systems having non
english locale.

ccwrap scans the output of the first compiler invocation (line 21) for
some specific english output on and around line 43.

i changed the patch to check uname -o for cygwin string and set the
locale to either C or C.UTF-8
2016-02-29 13:56:03 +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
Jon Turney 658caa7640 ssp: Fixes for 64-bit
Fix various 32/64-bit portability issues in ssp, the single-step profiler, and
also build it for 64-bit.

This didn't turn out to actually be very useful for what I wanted to use it for,
so it's only been lightly tested.

It appears that on x86_64, single-step exceptions occur for much more of the
code in system DLLs, unlike x86, so ssp may take much, much longer to profile
some programs.  There is existing code to use breakpoints to mitigate this, but
that is currently disabled.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-02-20 11:26:50 +00: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
Corinna Vinschen b76de0deaa cyglsa: Drop code handling Windows 2000 and earlier
* cyglsa.c (must_create_logon_sid): Remove.
	(LsaApInitializePackage): Drop checking version and setting
	must_create_logon_sid accordingly.
	(LsaApLogonUserEx): Drop code setting login SID only required on
	Windows 2000 and earlier.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-17 16:08:59 +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 10e0db58e4 Document pthread_barrier* functions as implemented
posix.xml (std-susv4): Add pthread_barrier* functions.
	(std-notimpl): Remove here.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-13 17:03:36 +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
Corinna Vinschen a16ab1751c get_posix_access: Fix primary group handing when multiple ACEs exist
Handle additional ACE for primary group only as another GROUP
	entry if it's an allow ACE.  Deny ACEs don't qualify.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-28 14:34:11 +01:00
Corinna Vinschen fcda8810a2 Don't use LoadLibraryEx(..., LOAD_LIBRARY_SEARCH_SYSTEM32). It hangs
Observed running hexchat under X.  For some reason the call to
	LoadLibraryEx(..., LOAD_LIBRARY_SEARCH_SYSTEM32) in dll_load
	hangs when trying to autoload MsgWaitForMultipleObjectsEx in
	select.cc after hexchat forks to run DNS calls.  Dropping the
	call and just using full paths as in 2.3.1 fixes the issue.

	* autoload.cc (dll_load): Drop call to LoadLibraryEx with
	LOAD_LIBRARY_SEARCH_SYSTEM32 flag.
	* wincap.h (wincaps::has_load_lib_search_flags): Remove.
	* wincap.cc (wincaps::has_load_lib_search_flags): Drop handling
	this flag.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-27 15:43:15 +01:00
Corinna Vinschen 78549742de Drop has_broken_fnoi flag
* mount.cc (fs_info::update): Don't set has_broken_fnoi.  It's
	unused anyway.
	* mount.h (class fs_info): Remove has_broken_fnoi status flag.
	* path.h (class path_conv): Remove has_broken_fnoi method.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-27 15:39:11 +01:00
Corinna Vinschen d9accb0079 Make select wait state more readable
Rename "res" to "wait_state" and change its type to
	select_stuff::wait_states.  Use select_stuff::wait_states
	values instead of ints throughout. 	Rearrange a few comments.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-27 15:37:53 +01:00
Corinna Vinschen 11a37290c6 Fix missing 'user' in usertemp docs
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-27 15:37:46 +01:00
Corinna Vinschen 69f98f5f18 Add 2.4.1 release message file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-23 22:33:31 +01:00
Corinna Vinschen 79b1b77b1f cygpath: Avoid returning SysWOW64
On Cygwin 32 running under WOW64:

	When case-correcting the path fetched with -S, the underlying
	Windows function fetching the normalized path returns the real
	path C:\Windows\SysWOW64 instead of the path redirection
	enabled C:\Windows\System32 path.  This breaks using the result
	of `cygpath -S' to fetch the POSIX path of the network related
	files under SYSTEMROOT\drivers\etc.  This path is in fact under
	the *real* C:\Windows\System32 and only mapped into the 32 bit
	C:\Windows\System32 (aka C:\Windows\SysWOW64) via path redirection.
	Sounds messy?

	This patch checks if we're running under WOW64.  If so, it
	changes the path returned by GetSystemDirectoryW from "system32"
	to "Sysnative".  This in turn is changed to "System32" by
	NtQueryInformationFile, so we're back to what we need.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-21 18:40:30 +01:00
Corinna Vinschen b5c80f5a59 cygwin_logon_user: Return non-privileged token as well
If the calling process doesn't have sufficient privileges to
	fetch the linked token of an admin-user token, cygwin_logon_user
	fails.  This patch changes that by returning the original,
	unprivileged token of the admin user to allow authentication
	and calling setuid for the current process.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-21 18:32:16 +01:00
Corinna Vinschen d44ec01ea1 Fix formatting in sec_auth.cc
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-21 18:27:05 +01:00
Corinna Vinschen 3a720bf3f0 Bump cygwin version to 2.4.1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-16 12:57:53 +01:00
Jon Turney 9c8a6e5646 faq: Update FAQ question and answer about gdb and signals
* faq-programming.xml: Update question and answer about gdb and signals.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-01-15 14:59:07 +00:00
Corinna Vinschen d2216272f5 get_posix_access: Fix group deny bits leaking into file type attribute bits
* sec_acl.cc (get_posix_access): Fix bracketing in expression
	constructing POSIX group permissions so as not leaking deny bits
	into POSIX file type bits.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-15 15:13:11 +01:00
Corinna Vinschen fc449e1c1f Initialize handle in dll_load to avoid compiler warning
* autoload.cc (dll_load): Initialize h to NULL.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-12 15:45:17 +01:00
Corinna Vinschen 8cd1ff7a45 Use MAKEWORD macro in WSAStartup call per documentation
* autoload.cc (wsock_init): Use MAKEWORD macro to create requested
	version rather than handcrafted expression.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-12 15:25:15 +01:00
Corinna Vinschen 15d6f564cd Try loading with safe path using LOAD_LIBRARY_SEARCH_SYSTEM32 first
* autoload.cc (dll_load): Move safe loading from std_dll_init here.
	Add code to handle systems supporting LOAD_LIBRARY_SEARCH flags.
	Add comments to explain what the code is doing.  Fix up comment
	preceeding this function.
	(std_dll_init): Move safe loading code to dll_load.
	* wincap.h (wincaps::has_load_lib_search_flags): New element.
        * wincap.cc: Implement above element throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-12 15:23:14 +01:00
Corinna Vinschen 27086d628e Fix previous fix for generating unique inode numbers for sockets
* fhandler.h (fhandler_base::get_plain_ino): New inline method.
	Add comment to explain what it's supposed to be used for.
	* fhandler_socket.cc (fhandler_socket::get_proc_fd_name): Create
	filename using inode number.
	(fhandler_socket::fstat): Generate inode number from filename if
	ino is not set (that's the case in a stat(2) call).
	* pipe.cc: Throughout, use get_plain_ino when appropriate.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-11 19:10:45 +01:00
Corinna Vinschen b4cf3f454d Revert "autoload.cc: Drop using full paths for system DLLs"
This reverts commit 4b104ce070.

The DLLs always guaranteed to be loaded from the system dir are only
those in the KnownDLLs list.  We're using some DLLs not in that list on
all supported OSes, thus we need to make sure to use full paths.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-11 18:46:01 +01:00
Corinna Vinschen a10d969231 Return unique inode numbers when calling stat/fstat on pipes and IP sockets
* fhandler.h (class fhandler_base): Convert unique_id to int64_t.
        (fhandler_base::set_ino): New protected inline method.
        (fhandler_base::get_unique_id): Convert to int64_t.
        (fhandler_base::set_unique_id): New inline method taking int64_t.
        (fhandler_pipe::fstat): Declare.
        (fhandler_pipe::init): Take extra parameter.
        (fhandler_pipe::create): Ditto.
        * fhandler_socket.cc (fhandler_socket::init_events): Set inode number
        to serial number.
        (fhandler_socket::fstat): Set device to DEV_TCP_MAJOR.  Create st_ino
        from get_ino.
        * include/cygwin/signal.h (struct _sigcommune): Replace
        _si_pipe_fhandler with _si_pipe_unique_id.
        * pinfo.h (_pinfo::pipe_fhandler): Take unique id instead of HANDLE.
        * pinfo.cc (commune_process): Accommodate change to _si_pipe_unique_id.
        (_pinfo::commune_request): Ditto.
        (_pinfo::pipe_fhandler): Ditto.
        * pipe.cc (fhandler_pipe::init): Take unique id as argument and set
        inode number and unique_id from there.
        (fhandler_pipe::open): Rework to find any matching pipe from unique
        id in filename.
        (fhandler_pipe::get_proc_fd_name): Create filename using inode number.
        (fhandler_pipe::create): Generate and return unique id from process pid
        and pipe_unique_id.  In outer method, call init with additional unique
        id as parameter.
        (fhandler_pipe::fstat): New method.
        (pipe_worker): Accommodate using 64 bit inode number in filename.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-11 12:35:41 +01:00
Corinna Vinschen 20ddde2f55 select(2): Drop checking descriptors in case of immediate timeout.
* select.cc (select): Call sel.poll only if sel.wait returned
	select_ok.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-11 10:36:33 +01:00
Corinna Vinschen e3b230b043 Add release message for previous commit
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-09 15:05:21 +01:00
Corinna Vinschen 3069a93fbe select: Don't timeout without setting descriptor arrays to all zero
* select.cc (copyfd_set): Remove.
        (select): Don't copy local wait fd arrays over to returned fd arrays
        since bits set there are not accounted for in return value.  Zero out
        returned fd arrays instead.  Always call sel.poll even in case of a
        timeout.  Always zero out fd array when timing out.  Convert while/do
        to do/while for clarity.  Use dedicated variable as return value to
        decouple return value from artificial return code from sel.wait.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-09 14:53:06 +01:00
Johannes Schindelin e0d4e3fec7 Do not treat the command line or environment like paths
* dcrt0.cc (dll_crt0_1), environ.cc (environ_init, getwinenveq,
	build_env), strfuncs.cc (sys_wcstombs, sys_wcstombs_alloc),
	wchar.c (sys_wcstombs, sys_wcstombs_alloc): avoid mis-conversions
	of text that does not, actually, refer to a path or file name

Detailed explanation:

Our WCS -> UTF conversion handles the private Unicode page specially
to allow for otherwise invalid file names. However, this handling makes
no sense for command-lines, nor environment variables, which we would
rather convert verbatim.

As a stop-gap solution, let's just introduce a version of the
sys_wcstombs() function that specifically excludes that file name
conversion magic.

The proper solution is to change sys_wcstombs() to assume that it is not
a path that wants to be converted, and introduce sys_wcstombs_path()
that does, but that is a bigger task which we leave for another patch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-01-08 15:17:52 +01:00
Corinna Vinschen 9ee2624240 Deprecate all winsup ChangeLog files
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-07 21:16:01 +01:00
Corinna Vinschen e70dbe774a cygpath: Try to return system directories with correct case
* cygpath.cc (do_sysfolders): Drop lame workaround to fix case of
	directory returned by GetSystemDirectoryW.  Try to fix case of
	any path returned by this function in case it has to return a
	POSIX path to support case-sensitivity.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-07 21:07:56 +01:00
Corinna Vinschen 9614a29f17 select: Set exceptfd bit if fetching mailslot info fails
* select.cc (peek_mailslot): Set except_ready if GetMailslotInfo fails.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-07 18:01:44 +01:00
Corinna Vinschen 8be00880a0 select.cc: Fit comments into 80 columns
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-07 18:00:39 +01:00
Corinna Vinschen 80a800978b Convert utmp{x}name to int, return useful value. Define _PATH_UTMPX
* syscalls.cc (utmpname): Convert to int.  Return 0 if strdup
	worked, -1 otherwise.
	* include/utmpx.h (_PATH_UTMPX): Define as _PATH_UTMP.
	(utmpxname): Declare as int function.
	* include/sys/utmp.h (utmpname): Ditto.
	* include/cygwin/version.h: Bump API minor version.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-07 15:40:40 +01:00
Corinna Vinschen b8f9d8de2c Drop use of not yet available type acl_perm_t
* sec_acl.cc (__aclcalcmask): Use mode_t instead of acl_perm_t

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-07 13:28:12 +01:00
Corinna Vinschen a2d0100644 Deprecate Cygwin ChangeLog file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-07 13:23:05 +01:00
Corinna Vinschen 8607476cf2 setfacl: Remove unused local variable
* setfacl.cc (delacl): Remove unused local variable.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-25 21:41:52 +01:00
Corinna Vinschen e983bd6aa4 Only request WRITE_DAC rights when writing an ACL
* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Only request
        query_write_dac rather than query_write_control access when writing
        an ACL.  Fix a comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-25 21:40:51 +01:00
Corinna Vinschen ed3c07215c aclsort: Honor calclass argument and allow recalculating ACL mask.
* sec_acl.cc (__aclcalcmask): New function to recalculate ACL masks.
        (aclsort32): Honor calclass argument.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-24 00:48:20 +01:00
Corinna Vinschen 7a1ac642f6 aclfromtext: Actually return aclcnt parameter
* sec_acl.cc (aclfromtext32): Return missing aclcnt parameter.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-24 00:39:45 +01:00
Corinna Vinschen 3b8372c1f2 Use TLS buffer in ACL<->text conversion
* sec_acl.cc (acltotext32): Use tmp_pathbuf rather than stack buffer.
        (aclfromtext32): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-24 00:32:54 +01:00
Corinna Vinschen 62fe4404a7 sec_acl.cc: Cosmetic changes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-24 00:24:39 +01:00
Corinna Vinschen bb231f6a62 setfacl(1): Fix handling of -m and -x on a single commandline
* setfacl.cc (delace): New helper function to delete a single ACE.
        (delacl): Call delace.
        (modacl): Ditto, if entry is supposed to get deleted.  Align comments.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-21 18:15:57 +01:00
Corinna Vinschen ddb7e770dd setfacl(1): Rewrite support for mask recomputation
* setfacl.cc (modacl): Move recomputing mask into new function.
        (check_got_mask): New function checking if mask is in input.
        (recompute_mask): New function to recompute mask.
        (addmissing): Align mask computation to Linux setfacl.
        (setfacl): Call check_got_mask and recompute_mask on Set, Delete and
        Modify actions.
        (usage): Rename --substitute to --set.
        (longopts): Add --set option.

        * utils.xml (setfacl): Rename --substitute to --set.
        * new-features.xml (ov-new2.4): Rephrase setfacl changes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-21 13:05:41 +01:00
Houder f5ad6fbb66 setfacl --mask/--no-mask really don't need an argument
* setfacl.cc (longopts): Drop accidentally requiring an argument to
        the --mask and --no-mask options.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-20 13:14:57 +01:00
Houder f97241dcb4 Fix missing arg requirement for setfacl -x option
* setfacl.cc (opts): Add colon to x option.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-19 21:01:59 +01:00
Corinna Vinschen ac39f7b4e8 Drop sys_cp_wcstombs and save two arguments per call
* strfuncs.cc (sys_cp_wcstombs): Delete and move functionality into
        sys_wcstombs.
        * wchar.h (sys_cp_wcstombs): Drop declaration.
        * fhandler_console.cc (dev_console::con_to_str): Call sys_wcstombs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-18 12:42:40 +01:00
Corinna Vinschen 1abcd49f0d Add release message for previous commit
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-16 12:35:08 +01:00
Corinna Vinschen c7432b13fa Fix crash reading invalid SIDs from passwd and group files
* grp.cc (pwdgrp::parse_group): Only copy the SID if it's valid.
        * passwd.cc (pwdgrp::parse_passwd): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-16 12:25:27 +01:00
Corinna Vinschen 4fbb2eb2c0 Add usertemp to 2.4.0 release text 2015-12-15 11:25:23 +01:00
Sebastian Huber 01885f533d FreeBSD compatibility for <sys/select.h>
* libc/include/sys/_sigset.h: New.
	* libc/include/sys/select.h: Do not include <sys/types.h> and
	<sys/time.h> to avoid cyclic header file dependencies.  Include
	specialized header files instead.
	(sigset_t): Conditionally define.
	* libc/include/sys/signal.h (sigset_t): Likewise.
	* libc/include/sys/time.h: Include <sys/select.h> if
	__BSD_VISIBLE.
	* libc/include/sys/types.h: Likewise.
2015-12-14 15:39:44 +01:00
Ken Brown ecfba2bb2c Fix regparm attribute of fhandler_base::fstat_helper
* winsup/cygwin/fhandler_disk_file.cc (fhandler_base::fstat_helper):
Align regparm attribute to declaration in fhandler.h.
2015-12-14 10:22:12 +01:00
Corinna Vinschen eed35efbe6 Fetch and store FileAllInformation rather than FileNetworkOpenInformation
* path.h (class path_conv_handle): Use FILE_ALL_INFORMATION instead of
        FILE_NETWORK_OPEN_INFORMATION.  Use definitions from ntdll.h since it's
        included anyway.
        (path_conv_handle::fai): Change name from fnoi.
        (path_conv::fai): Ditto.
        (file_get_fai): Change name from file_get_fnoi.  Drop second parameter.
        * path.cc (file_get_fai): Ditto.  Fetch FileAllInformation rather than
        FileNetworkOpenInformation.  Convert STATUS_BUFFER_OVERFLOW to
        STATUS_SUCCESS.  Remove workaround to fetch FileBasicInformation and
        FileStandardInformation on filesystems with broken
        FileNetworkOpenInformation handling.
        (symlink_info::check): Accommodate above changes.  In case of using
        the NtQueryDirectoryFile fallback, fetch FileIdBothDirectoryInformation
        to get inode number as well.
        * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Drop outdated
        comment.  Accommodate change to using FileAllInformation.  Drop
        extra function calls to fetch NumberOfLinks and IndexNumber.  Set ino
        directly from IndexNumber stored in pc.fai().  Drop second argument
        from call to fstat_helper.
        (fhandler_base::fstat_by_name): Drop second argument from call to
        fstat_helper.
        (fhandler_base::fstat_helper): Drop second parameter.  Accommodate
        the fact that we access a FILE_ALL_INFORMATION structure now.
        (fhandler_base::open_fs): Set ino directly from IndexNumber stored in
        pc.fai().
        * fhandler.h (fhandler_base::fstat_helper): Fix declaration accrdingly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-10 00:02:34 +01:00
Corinna Vinschen a0e7563eb0 Drop unused path_conv::ndisk_links method
* fhandler_disk_file.cc (path_conv::ndisk_links): Drop unused method.
        (fhandler_base::fstat_helper): Drop unused call to ndisk_links.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-09 23:56:47 +01:00
Corinna Vinschen ab73edc056 Use fii instead of fai for FILE_INTERNAL_INFORMATION vars
* fhandler_disk_file.cc (path_conv::get_ino_by_handle): Rename fai to
        fii for clearness.
        (fhandler_disk_file::readdir): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-09 23:51:48 +01:00
Corinna Vinschen 3da81956e2 In FILE_ID_BOTH_DIR_INFORMATION it's actually FileId, not IndexNumber
* ntdll.h (FILE_ID_BOTH_DIR_INFORMATION): Revert IndexNumber to FileId
        since it's actually right here.
        * fhandler_disk_file.cc: Accommodate above change.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-09 18:11:47 +01:00
Corinna Vinschen 6c3a5d263f Remove unnecessary locking in pthread_setcancelstate/pthread_setcanceltype
* thread.cc (pthread::setcancelstate): Remove unnecessary locking.
        (pthread::setcanceltype): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-08 17:55:33 +01:00
Corinna Vinschen d0f5f4c422 Rename FileId to IndexNumber in NT structures to align with upstream
* ntdll.h (FILE_ID_BOTH_DIR_INFORMATION): Rename FileId to IndexNumber
        to align with Microsoft naming scheme.
        (FILE_INTERNAL_INFORMATION): Ditto.
        * fhandler_disk_file.cc: Rename FileId to IndexNumber throughout.
        * syscalls.cc: Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-08 14:33:07 +01:00
Corinna Vinschen 87db9e0680 Fix minor style issue in _dll_crt0.
Fix missing space.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-07 18:41:15 +01:00
Johannes Schindelin fb71716d2c Introduce the 'usertemp' filesystem type
* mount.cc (mount_info::from_fstab_line): Support mounting the current
	user's temp folder as /tmp/.  This is particularly useful a feature
	when Cygwin's own files are write-protected.

	* pathnames.xml: document the new usertemp file system type

Detailed explanation:

In the context of Windows, there is a per-user directory for temporary
files, by default specified via the environment variable %TEMP%. Let's
allow to use that directory for our /tmp/ directory.

With this patch, we introduce the special filesystem type "usertemp":
By specifying

	none /tmp usertemp binary,posix=0 0 0

in /etc/fstab, the /tmp/ directory gets auto-mounted to the directory
specified by the %TEMP% variable.

This feature comes handy in particularly in scenarios where the
administrator might want to write-protect the entire Cygwin directory
yet still needs to allow users to write into the /tmp/ directory.
This is the case in the context of Git for Windows, where the
Cygwin (MSys2) root directory lives inside C:\Program Files and hence
/tmp/ would not be writable otherwise.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-12-07 17:37:44 +01:00
Corinna Vinschen 08184b362e Move fd_stuff from sys/types.h to sys/select.h
* libc/include/sys/types.h: Move definitions of NBBY and howmany to
	sys/param.h.  Move definitions of select(2) macros to sys/select.h.
	* libc/include/sys/param.h: See above.
	* libc/include/sys/select.h: Move Cygwin's sys/select.h here.

	* include/sys/select.h: Move select(2) macros from newlib's sys/types.h
	here.  Rename howmany to _howmany to unclutter namespace. Move file to
	newlib.
	* libc/rexex.cc: Add declaration for cygwin_gethostname.
	* poll.cc: Include sys/param.h and locale select.h.
	* select.h (cygwin_select): Declare.
	* uname.cc: Declare cygwin_gethostname.
	* winsup.h: Drop declarations of cygwin_select and cygwin_gethostname.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-07 16:28:22 +01:00
Corinna Vinschen e753e4129a Always allocate main thread stack from pthread stack area on x86_64.
* dcrt0.cc: Semi-revert commit 12743c2d5d.
        (dll_crt0_0): Drop setting wow64_needs_stack_adjustment on 64 bit.
        (_dll_crt0): Split out 64 bit code again and always create new main
        thread stack, unless forked off from the non main thread in the parent.
        Call create_new_main_thread_stack with parent stack commitsize if
        started from the parent's main thread.
        Only call child_info_fork::alloc_stack for the latter case on 64 bit.
        Slightly rearrange moving rsp and rbp to new stack and document how.
        Revert 32 bit wow64 handling to its former self.
        * miscfunc.cc (create_new_main_thread_stack): Take a commitsize
        parameter and use it if it's not 0.  Don't set _main_tls here, it's
        done in the caller _dll_crt0 anyway.  Return stackbase - 16 bytes,
        rather than stacklimit (which was very wrong anyway).
        * miscfuncs.h (create_new_main_thread_stack): Accommodate declaration
        to aforementioned change.
        * wincap.h (wincaps::has_3264_stack_broken): Remove element.
        * wincap.cc: Ditto, throughout.
        * wow64.cc: Semi-revert to pre-12743c2d5d2721f3a80b4d7671a349be03c1f520
        but keep architecture-agnostic type changes intact.  Fix formatting.
        * wow64.h: Revert to pre-12743c2d5d2721f3a80b4d7671a349be03c1f520.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-07 16:10:55 +01:00
Corinna Vinschen 5aa8817e3a Allow cygwin_conv_path(3) and cygpath(1) to emit /proc/cygdrive prefixed path
* include/sys/cygwin.h (CCP_PROC_CYGDRIVE): New flag.
        * mount.cc (mount_info::cygdrive_posix_path): Take flag values rather
        than just a trailing_slash_p bool.  Emit /proc/cygdrive path if
        CCP_PROC_CYGDRIVE flag is given.
        (mount_info::conv_to_posix_path): Take flag values rather than just
        a keep_rel_p bool.  Rename _p variables.  Print flag value as hex in
        debug_printf.  Call cygdrive_posix_path with flag values.
        * mount.h (mount_info::cygdrive_posix_path): Accommodate above change
        in declaration.
        (mount_info::conv_to_posix_path): Ditto.
        * fhandler_process.cc (format_process_exename): Accommodate change to
        mount_info::conv_to_posix_path.
        * path.cc (cygwin_conv_path): Ditto.

        * cygpath.cc (absolute_flag): Initialize to CCP_RELATIVE to simplify
        expressions.
        (cygdrive_flag): New global flag.
        (long_options): Add --proc-cygdrive option.
        (options): Add -U option.
        (usage): Add description for -U option.
        (do_sysfolders): Or cygdrive_flag to cygwin_conv_path call.
        (do_pathconv): Simply or absolute_flag to conv_func.  Or
        cygdrive_flag to conv_func.
        (do_options): Initalize absolute_flag to CCP_RELATIVE.  Initialize new
        cygdrive_flag.  Set absolute_flag to CCP_ABSOLUTE on -a.  Set
        cygdrive_flag to CCP_PROC_CYGDRIVE on -U.

        * new-features.xml (ov-new2.4): Document cygpath -U option.
        * utils.xml (cygpath): Ditto.
        * path.xml (func-cygwin-path): Add CCP_PROC_CYGDRIVE description.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-06 17:25:48 +01:00
Corinna Vinschen f71d48d06f Add release message for workaround added with previous commits
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-03 23:09:03 +01:00
Corinna Vinschen 12743c2d5d On 64 bit, only create new thread stack if started from 32 bit process on affected platforms
* dcrt0.cc (dll_crt0_0): On 64 bit, set wow64_needs_stack_adjustment
        if not started from a 64 bit process.
        (_dll_crt0): Enable wow64_needs_stack_adjustment branch on 64 bit
        as well.  Remove 64 bit only code.  Introduce CREATE_STACK and
        FIX_STACK macros to conditionalize the code.  Rearrange and
        partially rewrite comments.
        * wincap.h (wincaps::has_3264_stack_broken): New element.
        * wincap.cc: Implement above element throughout.
        (wincapc::init): Set has_3264_stack_broken to false on 32 bit.
        * wow64.cc: Enable functionality on 64 bit architecture, except for
        wow64_revert_to_original_stack.  Enhance comments to explain.
        (wow64_eval_expected_main_stack): Make 64 bit clean.
        (wow64_test_for_64bit_parent): Ditto.
        * wow64.h: Export wow64_revert_to_original_stack on 32 bit only,
        everything else on all architectures.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-03 22:56:44 +01:00
Corinna Vinschen 8f4da28eb6 Fix thinko in /proc/<PID>/maps TEB detection on W10 1511
* fhandler_process.cc (thread_info::thread_info): Accommodate the fact
        that TEBs take two pages.
        (thread_info::fill_if_match): Rewrite the method for post W10 1511 TEB
        detection.
        (format_process_maps): Add a state member to region.  Fix the code
        to handle PEB/TEB region since W10 1511.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-03 16:54:29 +01:00
Corinna Vinschen f1ed5bfa83 Fix /proc/<PID>/maps output for PEB and TEBs on W10 1511
* fhandler_process.cc (heap_info::fill_if_match): Return NULL, not 0.
        (thread_info::fill_if_match): Ditto.
        (thread_info::fill_if_match): New method to extract TEB info from
        PEB/TEB region since W10 1511.
        (format_process_maps): Drop outdated FIXME comment.  Add code to handle
        PEB/TEB region since W10 1511.
        * mmap.cc (posix_madvise): Align comment to new W10 1511 version.
        * wincap.h (wincaps::has_new_pebteb_region): New element.
        * wincap.cc: Implement above element throughout.
        (wincap_10_1511): New global wincaps to support Windows 10 since 1511.
        (wincapc::init): Use wincap_10_1511 for W10 builds >= 10586.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-03 13:33:43 +01:00
Corinna Vinschen 8a14e51901 Always move 64 bit main thread stack to defined pthread stack area
x86_64 only:
        * dcrt0.cc (_dll_crt0): Always move stack to pthread stack area.
        Explain why.
        * miscfuncs.cc (create_new_main_thread_stack): New function to create
        OS-like stack for main thread in pthread stack area.
        * miscfuncs.cc (create_new_main_thread_stack): Declare.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-03 13:31:18 +01:00
Corinna Vinschen 81e6c7515d Cleanup in dcrt0.cc and fork.cc
* dcrt0.cc (child_info_fork::alloc_stack): Fix formatting.
        * fork.cc (frok::parent): Fix formatting.
        (child_copy): Change type of res to BOOL.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-03 13:30:51 +01:00
Corinna Vinschen 111f32f4ba Always restore full TEB stack info in forkee
* dcrt0.cc (dll_crt0_1): Always restore the TEB stack info.  Especially
        restore DeallocationStack.  Fix comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-03 13:28:32 +01:00
Corinna Vinschen 600c445127 Add missing dcrt0.cc patch to previous commit
* dcrt0.cc (child_info_fork::alloc_stack): Don't set stackaddr to 0.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-03 13:26:34 +01:00