Commit Graph

7560 Commits

Author SHA1 Message Date
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 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
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
Corinna Vinschen 89e86492b3 Safely recognize when fork is running from main thread or another pthread
* child_info.h (struct child_info): Add member from_main.
        * fork.cc (frok::child): Check from_main rather than stackaddr.
        (frok::parent): Set ch.from_main if running in the main thread.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-03 12:38:19 +01:00
Corinna Vinschen 8974e06da3 Rename parent stack members in child_info struct to align with OS names
* child_info.h (CURR_CHILD_INFO_MAGIC): Align to below change.
        (class child_info_fork): Rename stacktop to stacklimit.  Rename
        stackbottom to stackbase.  Accommodate name change throughout Cygwin.
        Rephrase comments to be clearer.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-02 12:31:40 +01:00
Corinna Vinschen 7b0c063f12 Drop using _tlsbase and _tlstop in favor of access via NtCurrentTeb.
* cygtls.h (_tlsbase): Remove.  Replace throughout with
        NtCurrentTeb()->Tib.StackBase.
        (_tlstop): Remove. Replace throughout with
        NtCurrentTeb()->Tib.StackLimit.
        * dcrt0.cc (child_info_fork::alloc_stack): Move definition of local
        teb variable up to be used throughout.
        * include/cygwin/config.h (__getreent): Use inline function on both
        architectures.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-02 12:11:06 +01:00
Corinna Vinschen 8e6213210d miscfuncs.cc: Fix typos in comment 2015-12-02 10:23:56 +01:00
Corinna Vinschen e7414a317a Only generate BUILTIN SIDs for uid/gid values <= 999
* uinfo.cc (pwdgrp::fetch_account_from_windows): Only create 1-5-32-x
	SIDs from ids for x <= 999.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-29 21:21:35 +01:00
Corinna Vinschen 47e7288769 Use correct gid value for Microsoft Account when /etc/group is in use
* sec_acl.cc (get_posix_access): In case owner SID == group SID, when
	encountering the group entry, change the value of `id' accordingly.
	Explain why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-29 20:26:48 +01:00
Corinna Vinschen bfe23aa437 Save and restore MXCSR register in delayed signal handling
* gendef (sigdelayed): Save and restore content of the MXCSR register
	on x86_64.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-28 11:10:41 +01:00
Corinna Vinschen a4d1cb1053 Belatedly create release notes for commits 2f4fef9 and 9471b0b 2015-11-27 15:56:01 +01:00
Corinna Vinschen c43e9340f1 Fix race condition when waiting for a signal
* cygtls.h (_cygtls::wait_signal_arrived): Renamed from
        set_signal_arrived.
        (_cygtls::set_signal_arrived): New function signalling signal_arrived.
        (_cygtls::reset_signal_arrived): Don't reset will_wait_for_signal.
        (_cygtls::unwait_signal_arrived): New function only resetting
        will_wait_for_signal.
        (class wait_signal_arrived): Rename from set_signal_arrived.
        Accommodate name change throughout Cygwin.
        (wait_signal_arrived::~wait_signal_arrived): Call
        _cygtls::unwait_signal_arrived.  Add comment.
        * cygserver_ipc.h (ipc_set_proc_info): Fetch signal_arrived handle
        via call to _cygtls::get_signal_arrived.
        * exceptions.cc (_cygtls::interrupt_setup): Signal signal_arrived via
        call to _cygtls::set_signal_arrived.
        (_cygtls::handle_SIGCONT): Ditto.
        * fhandler_socket.cc (fhandler_socket::wait_for_events): Generate
        WSAEVENT array prior to entering wait loop.  Add cancel event object
        if available.  Remove calls to pthread_testcancel and just call
        pthread::static_cancel_self if the cancel event object is signalled.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-27 14:39:11 +01:00
Corinna Vinschen 2f4fef955c Fix creating relative native symlinks in top-level directories
* path.cc (symlink_native): Fix index when looking for colon in path.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-26 12:12:52 +01:00
Corinna Vinschen 26a8b62e9a Fix numeric and monetary decimal point and thousands separator in fa_IR and ps_AF locales
* nlsfuncs.cc (setlocaleinfo): New macro calling __setlocaleinfo.
	(__setlocaleinfo): New function to set a locale-specific character
	to an explicit wchar_t value.
	(__set_lc_numeric_from_win): Handle fa_IR and ps_AF locales to return
	same decimal point and thousands separator characters as on Linux.
	(__set_lc_monetary_from_win): Ditto for monetary characters.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-21 16:51:12 +01:00
Corinna Vinschen 63613c3cb0 Mention strtold patch in Cygwin 2.4.0 release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-20 20:29:50 +01:00
Corinna Vinschen fbace81684 Import correctly working strtold from David M. Gay.
* libc/stdlib/Makefile.am (GENERAL_SOURCES): Add strtodg.c and
	strtorx.c.
	* libc/stdlib/Makefile.in: Regenerate.
	* libc/stdlib/strtodg.c: New file implementing generic string to long
	double conversion.
	* libc/stdlib/strtorx.c: New file, implementing IEEE format string to
	long double conversion.
	* libc/stdlib/mprec.h (_strtodg_r): Declare.
	(_strtorx_r): Declare.
	* libc/stdlib/gdtoa.h (__UShort): Define.
	* libc/stdlib/strtold.c (__flt_rounds): Define for i386 and x86_64
	target.
	(FLT_ROUNDS): Define, as 0 on platforms missing a __flt_rounds
	function.
	(_strtold_r): Converted from strtold.  Call _strtorx_r on targets
	supporting distinct long doubles.
	(strtold): Just call _strtold_r.
	* libc/include/stdlib.h (_strtold_r): Declare.
	* libc/stdlib/ldtoa.c (_strtold): Comment out.  Explain why.
	* libc/stdio/vfscanf.c (__SVFSCANF_R): Call _strtold_r instead of
	_strtold.
	* libc/machine/powerpc/vfscanf.c (__svfscanf_r): Ditto.

	* common.din (strtold): Drop redirection to _strtold.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-20 18:14:58 +01:00
Corinna Vinschen 396e8310b1 Document new ACL code
* new-features.xml (ov-new2.4): Add new ACL changes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 23:11:10 +01:00
Corinna Vinschen 90e006a63d get_posix_access: Skip merging permissions if user can't get more permissions
* sec_acl.cc (get_posix_access): Skip merging permissions if current
        user has rwx permissions anywa, or if the sum of all group and other
        permissions is less than or equal to the user's permissions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 22:56:38 +01:00
Corinna Vinschen a5d81afc71 get_posix_access: Fix computation of effective user permissions
* sec_acl.cc (get_posix_access): Fix computation of effective user
	permissions to handle current user, not only the file owner.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 22:55:19 +01:00
Corinna Vinschen 6459131096 Fix file type mode bit handling on object security.
* fhandler_tty.cc (fhandler_pty_slave::open): Add S_IFCHR flag
	in call to create_object_sd_from_attribute.
	(fhandler_pty_slave::fstat): Ditto in call to get_object_attribute.
	(fhandler_pty_slave::fchmod): Add an orig_mode flag and ditto for
	both calls.
	(fhandler_pty_master::setup): Ditto in call to
	create_object_sd_from_attribute.
	* security.cc (get_object_attribute): Never add S_IFCHR to mode
	here.  Let the caller decide.
	(create_object_sd_from_attribute): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 22:44:33 +01:00
Corinna Vinschen 911808dd5e Fix permission evaluation for !new_style ACLs
* security.h (authz_get_user_attribute): Declare bool.
	* sec_helper.cc (authz_ctx::get_user_attribute): Make bool method.
	Set S_IxOTH bits in returned attributes rather than S_IxUSR bits.
	(authz_get_user_attribute): Make bool function.
	* sec_acl.cc (get_posix_access): Introduce cygsid array to keep
	track of all SIDs in the ACL.  Move AuthZ calls into !new_style
	permission post processing.  When not using AuthZ, use
	CheckTokenMembership to collect group permissions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 22:30:38 +01:00
Corinna Vinschen 7edb6b8d3e Fix up POSIX permission handling
* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Disable
	deviation from POSIX 1003.1e in terms of GROUP_OBJ/CLASS_OBJ
	permissions.  Follow POSIX 1003.1e again.  Keep old code in
	for future reference.
	* sec_acl.cc: Accommodate changes in ACE creation in leading
	comment.
	(set_posix_access): Fix user deny ACE creation.  Split group
	deny ACE creation into two steps, one to reflect CLASS_OBJ,
	the other to reflect OTHER_OBJ.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 22:29:46 +01:00
Corinna Vinschen 7972e63402 Use Authz to fetch correct user permissions.
* sec_acl.cc (getacl): Use Authz to fetch correct user permissions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 22:28:40 +01:00
Corinna Vinschen 42fad6ffa5 Add Authz class to compute exact POSIX user perms in a security descriptor
* autoload.cc (AuthzAccessCheck): Import.
	(AuthzFreeContext): Import.
	(AuthzInitializeContextFromSid): Import.
	(AuthzInitializeContextFromToken): Import.
	(AuthzInitializeResourceManager): Import.
	* sec_helper.cc (get_sids_info): Remove.
	(class authz_ctx_cache_entry): New class.
	(class authz_ctx_cache): New class.
	(class authz_ctx): New class.
	(authz_get_user_attribute): New function.
	* security.h (get_sids_info): Drop prototype.
	(authz_get_user_attribute): Add prototype.
	* winlean.h (_AUTHZ_): Define.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 22:28:33 +01:00
Corinna Vinschen e2742d467a * sec_acl.cc (get_posix_access): Fix class_perm in !new_style case.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 22:28:27 +01:00
Corinna Vinschen bc444e5aa4 Reapply POSIX ACL changes.
- New, unified implementation of POSIX permission and ACL handling.  The
    new ACLs now store the POSIX ACL MASK/CLASS_OBJ permission mask, and
    they allow to inherit the S_ISGID bit.  ACL inheritance now really
    works as desired, in a limited, but theoretically equivalent fashion
    even for non-Cygwin processes.

    To accommodate Windows default ACLs, the new code ignores SYSTEM and
    Administrators group permissions when computing the MASK/CLASS_OBJ
    permission mask on old ACLs, and it doesn't deny access to SYSTEM and
    Administrators group based on the value of MASK/CLASS_OBJ when
    creating the new ACLs.

    The new code now handles the S_ISGID bit on directories as on Linux:
    Setting S_ISGID on a directory causes new files and subdirs created
    within to inherit its group, rather than the primary group of the user
    who created the file.  This only works for files and directories
    created by Cygwin processes.

2015-05-29  Corinna Vinschen  <corinna@vinschen.de>

	Reapply POSIX ACL changes.

	* utils.xml (setfacl): Show new option output.
	(getfacl): Show new option output.

	* sec_acl.cc (get_posix_access): Check for Cygwin "standard" ACL.
	Apply umask, if so.  Align comments.
	* security.cc (set_created_file_access): Fix permission masking by
	incoming requested file mode.

	* sec_acl.cc (set_posix_access): Apply mask only in terms of execute bit
	for SYSTEM and Admins group.

	* sec_acl.cc (set_posix_access): Don't create DENY ACEs for USER and
	GROUP entries if they are the same as USER_OBJ or GROUP_OBJ.

	* fhandler.h (fhandler_pty_slave::facl): Add prototype.
	* fhandler_tty.cc (fhandler_pty_slave::facl): New method.
	(fhandler_pty_slave::fchown): Fix uid/gid handling.
	* sec_acl.cc (set_posix_access): Drop superfluous class_idx variable.
	Simplify and move around code in a few places.  To improve ACL
	readability, add r/w permissions to Admins ACE appended to pty ACL.
	Add comment to explain Windows ACE Mask filtering being in the way of
	creating a real CLASS_OBJ.
	(get_posix_access): Fake CLASS_OBJ for ptys.  Explain why.
	* security.cc (get_object_attribute): Add S_IFCHR flag to attributes
	when calling get_posix_access.

	* sec_acl.cc (set_posix_access): Move merging group perms into owner
	perms in case of owner == group after mask has been computed.  Take
	mask into account when doing so to avoid unnecessary ACCESS_DENIED_ACE.

	* sec_acl.cc (get_posix_access): Only set saw_group_obj flag if we saw
	the ACCESS_ALLOWED_ACE.

	* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Deliberatly
	set GROUP_OBJ and CLASS_OBJ perms to new group perms.  Add comment
	to explain why.
	* security.cc (set_created_file_access): Ditto.

	* sec_acl.cc (set_posix_access): Replace previous patch.  Return
	EINVAL if uid and/or guid is invalid and not backed by an actual
	Windows account.

	* sec_acl.cc (set_posix_access): Workaround owner/group SIDs being NULL.

	* sec_acl.cc (set_posix_access): Handle files with owner == group.
	Rephrase switch statement checking against unfiltered a_type value.
	(get_posix_access): Handle files with owner == group.

	* sec_acl.cc (get_posix_access): Don't use GROUP_OBJ access to fix up
	CLASS_OBJ mask on old-style ACLs.  Fix a comment.

	* sec_acl.cc (set_posix_access): Always make sure Admins have
	WRITE_DAC and WRITE_OWNER permissions.
	* security.h (create_object_sd_from_attribute): Drop handle parameter
	from prototype.
	* security.cc (create_object_sd_from_attribute): Drop handle parameter.
	Just create the standard POSIXy security descriptor.
	(set_object_attribute): Accommodate dropped paramter in call to
	create_object_sd_from_attribute.
	* fhandler_tty.cc: Ditto, throughout.

	* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Fix typo in
	mask computation.

	* fhandler.cc (fhandler_base::open_with_arch): Call open with mode
	not umasked.
	(fhandler_base::open): Explicitely umask mode on NFS here.  Call new
	set_created_file_access rather than set_file_attribute.
	* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Reimplement
	setting permissions on filesystems supporting ACLs using the new
	set_posix_access call.
	(fhandler_disk_file::fchown): Ditto.
	(fhandler_disk_file::mkdir): Call new set_created_file_access rather
	than set_file_attribute.
	* fhandler_socket.cc (fhandler_socket::bind): Don't umask here.  Add
	WRITE_OWNER access to allow writing group in case of SGID bit set.
	Call new set_created_file_access rather than set_file_attribute.
	* path.cc (symlink_worker): Call new set_created_file_access rather
	than set_file_attribute.
	* sec_acl.cc (searchace): Un-staticize.
	(set_posix_access): New, complementary functionality to
	get_posix_access.
	(setacl): Implement in terms of get_posix_access/set_posix_access.
	(get_posix_access): Add handling for just created files requiring
	their first Cygwin ACL.  Fix new_style recognition.  Handle SGID
	bit.  For old-style ACLs, ignore SYSTEM and Administrators when
	computing the {DEF_}CLASS_OBJ perms.
	* security.cc (get_file_sd): Revamp comment.  Change and (hopefully)
	speed up inheritance processing for just created files.
	(alloc_sd): Remove.
	(set_security_attribute): Call set_posix_access instead of alloc_sd.
	(get_object_attribute): Fix return value.
	(create_object_sd_from_attribute): Call set_posix_access instead of
	alloc_sd.
	(set_file_attribute): Remove.
	(set_created_file_access): New function implemented in terms of
	get_posix_access/set_posix_access.
	* security.h (set_file_attribute): Remove prototype.
	(set_created_file_access): Add prototype.
	(searchace): Ditto.
	(set_posix_access): Ditto.
	* syscalls.cc (open): Call open_with_arch with mode not umasked.

	* sec_acl.cc: Change preceeding comment explaining new-style ACLs.
	Describe how to generate deny ACEs in more detail.  Accommodate the
	fact that a NULL deny ACE is used for {DEF_}CLASS_OBJ, rather than
	a special Cygwin ACE.  Improve further comments.
	(CYG_ACE_NEW_STYLE): Define.
	(get_posix_access): Change from Cygwin ACE to NULL deny ACE.  Fix
	CLASS_OBJ handling to generate CLASS_OBJ and DEF_CLASS_OBJ from a single
	NULL deny ACE if the inheritance flags say so.
	* sec_helper.cc (well_known_cygwin_sid): Remove.
	* security.h (well_known_cygwin_sid): Drop declaration.

	* sec_acl.cc (CYG_ACE_ISBITS_TO_WIN): Fix typo.
	(get_posix_access): Rename index variable from i to idx.  Define only
	once at top level.

	* security.cc (add_access_allowed_ace): Drop unused parameter "offset".
	Accommodate throughout.
	(add_access_denied_ace): Ditto.
	* sec_acl.cc: Accommodate above change throughout.
	* security.h (add_access_allowed_ace): Adjust prototype to above change.
	(add_access_denied_ace): Ditto.

	* sec_acl.cc (get_posix_access): Handle multiple ACEs for the
	owner and primary group of the file.  Handle the default primary
	group ACE as DEF_GROUP_OBJ entry if the directory has the S_ISGID bit
	set.  Add comments.  Minor code rearrangements.

	Preliminary read side implementation of new permission handling.
	* acl.h (MAX_ACL_ENTRIES): Raise to 2730.  Add comment to explain.
	* sec_acl.cc:  Add leading comment to explain new ACL style.
	Add definitions and macros to use for bits in new Cygwin ACL.
	(DENY_RWX): New mask value for all temporary deny bits.
	(getace): Add bool parameter to decide when leaving all bits intact,
	rather than filtering them per the already set bits.
	(get_posix_access): New function, taking over functionality to read
	POSIX ACL from SECURITY_DESCRIPTOR.
	(getacl): Just call get_posix_access.
	* sec_helper.cc (well_known_cygwin_sid): Define.
	* security.cc (get_attribute_from_acl): Remove.
	(get_info_from_sd): Remove.
	(get_reg_sd): Call get_posix_access instead of get_info_from_sd.
	(get_file_attribute): Ditto.
	(get_object_attribute): Ditto.
	* security.h (well_known_cygwin_sid): Declare.
	(get_posix_access): Add prototype.

	* Throughout, use simpler ACE macros from Windows' accctrl.h.

	* getfacl.c (main): Special-case SYSTEM and Admins group.  Add comments.

	* setfacl.c: Align more to Linux tool.
	(delacl): New function to delete acl entries only.
	(modacl): Drop delete functionality.  Add handling of recomputing the
	mask and default mask values.
	(delallacl): Rename from delacl.
	(setfacl): Call delacl in Delete case.  Call delallacl in DeleteAll
	and DeleteDef case.
	(usage): Accommodate new options.  Rearrange and rephrase slightly.
	(longopts): Emit 'x' in --delete case.  Add --no-mask and --mask
	options.
	(opts): Add -x and -n options.
	(main): Handle -d and -x the same.  Handle -n and --mask options.
	Drop handling for -r option.

	* getfacl.c (usage): Align more closely to Linux version.  Add new
	options -c, -e, -E.  Change formatting to accommodate longer options.
	(longopts): Rename --noname to --numeric.  Keep --noname for backward
	compatibility.  Add --omit-header, --all-effective and --no-effective
	options.
	(opts): Add -c, -e and -E option.
	(main): Handle new -c, -e, and -E options.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 22:27:54 +01:00
Corinna Vinschen 049eeecba7 Bump Cygwin DLL version to 2.4.0
* include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2004.
	(CYGWIN_VERSION_API_MINOR): Reset to 0.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 22:11:54 +01:00
Corinna Vinschen 6895a3147b Add missing ChangeLog entry for previous commit 2015-11-18 22:05:21 +01:00
Corinna Vinschen 7da497499f Update Cygwin's fnmatch to latest from FreeBSD.
* collate.h (__collate_load_error): Convert to extern declaration.
        * globals.cc (__collate_load_error): Define and initialize here.
        * libc/fnmatch.c: Update to latest from FreeBSD.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 20:51:12 +01:00
Corinna Vinschen 8cdd7bad21 Don't generate Windows native symlinks targeting Cygwin-only targets
* path.cc (symlink_native): Don't generate native symlink targeting
	Cygwin special file.  Inform the caller.
	(symlink_worker): Don;t bail out in WSYM_nativestrict case if the
	target is a Cygwin special file.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 19:12:37 +01:00
Corinna Vinschen 21608fa57d Regenerate Cygwin locale message info
* lc_msg.h: Regenerate.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 19:09:47 +01:00
Yaakov Selkowitz ed8beb5361 cygwin: export rpmatch(3)
winsup/cygwin/
* common.din (rpmatch): Export.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.

winsup/doc/
* new-features.xml (ov-new2.4): New section. Document rpmatch.
* posix.xml (std-bsd): Add rpmatch.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2015-11-17 12:23:33 -06:00
Corinna Vinschen 914620a7e6 flock: Fix hang in object collision case
* flock.cc (lockf_t::create_lock_obj): Correctly recreate lock object
	attributes anew in each loop.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-12 13:14:08 +01:00
Corinna Vinschen 4998ac4341 Add comment to explain previous patch
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-12 11:52:02 +01:00
Corinna Vinschen d03f429727 Fix crash at process init on 64 bit XP/2003 under WOW64
* init.cc (munge_threadfunc): Don't call NtQueryInformationThread with
	ThreadQuerySetWin32StartAddress info class on XP 64 and Server 2003 64.
	It crashes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-12 11:48:30 +01:00
Corinna Vinschen 1968c57d9c Bump Cygwin DLL minor number
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-09 10:12:48 +01:00
Corinna Vinschen c56dc181f9 Fake volume serial number on filesystems not providing it
* mount.cc (fs_info::update): Fake a serial number on filesystems not
	providing one.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-05 18:34:34 +01:00
Corinna Vinschen 41299df081 Avoid deadlock in flock(2)
* fcntl.cc (fcntl64): Don't lock fd table when performing locking.
	* flock.cc (flock): Ditto.
	(lockf): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-05 18:31:36 +01:00
Corinna Vinschen eeef727026 Fix iterating over pending signals if a signal doesn't have to be cleared
* sigproc.cc (pending_signals::clear): Yet another fix to fix the fix.
	Actually iterate over the list of pending signals even if there's a
	signal which doesn't have to be cleared.  Other than that, revert loop
	to it's former self as a while loop.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-05 10:09:08 +01:00
Corinna Vinschen 57d93bebb2 Accommodate trailing NUL in PrlSF filesystem name.
* globals.cc (ro_u_prlfs): Add trailing NUL.  Explain why.
	* mount.cc (fs_info::update): Add a comment to explain PrlSF.
	* path.h (path_conv::fs_is_prlfs): Add for symmetry.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-04 14:47:25 +01:00
Corinna Vinschen 58922d3125 Add missing release message for 68b4238f4a1276a1f6f18430580b62dfa0420ffd 2015-11-04 10:09:12 +01:00
Corinna Vinschen 0ed1523470 Fix potential endless loop in pending_signals::clear
* sigproc.cc (pending_signals::clear): Fix previous fix resulting in
	yet another endless loop.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-03 18:25:23 +01:00
Corinna Vinschen 7321662bb0 Define MAX_IPOPTLEN
* include/netinet/ip.h (MAX_IPOPTLEN): Define.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-02 15:42:30 +01:00
Corinna Vinschen 90b9303f0b Fix incorrect implementation to clear per-thread pending signals
* sigproc.cc (class pending_signals): Drop sigproc_init friendship.
	(pending_signals::clear): Fix implementation to avoid subsequent
	endless loop in wait_sig.  Improve comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-02 13:54:30 +01:00
Corinna Vinschen df6206aa56 Add support for Parallels Desktop FS (prlfs)
* mount.h (enum fs_info_type): Add prlfs (Parallels Desktop FS).
	(class fs_info): Add has_broken_fnoi flag.  Implement prlfs FS flag.
	* mount.cc (fs_info::update): Handle PrlFS.  Fill new has_broken_fnoi
	flag with life.
	(fs_names): Add prlfs.
	* globals.cc (ro_u_prlfs): Define.
	* path.h (path_conv::has_broken_fnoi): New method.
	* path.cc (symlink_info::check): Call file_get_fnoi utilizing new
	has_broken_fnoi filesystem flag.
	* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Ditto.

	* new-features.xml (ov-new2.3): Document Parallels Desktop FS support.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-02 12:08:25 +01:00
Corinna Vinschen 677eea00a6 Workaround bug in LocaleNameToLCID on Windows 10
* nlsfuncs.cc (__get_lcid_from_locale): Handle LocaleNameToLCID
	returning LOCALE_CUSTOM_UNSPECIFIED instead of failing in case of
	an unsupported locale on Windows 10.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-10-30 20:13:26 +01:00
Corinna Vinschen 4a407e9037 Avoid double unlock of TLS mutex
* exceptions.cc (sigpacket::process): Avoid potentially double unlocking
	the TLS mutex.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-10-30 17:21:30 +01:00
Corinna Vinschen 8f97c045b8 Fix sigwait and pthread_kill return values in case of error
* signal.cc (sigwait): Fix return value to reflect errno in case of
	error according to POSIX.  Never return EINTR.
	* thread.cc (pthread_kill): Return errno if sig_send failed.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-10-30 16:05:43 +01:00
Qian Hong ff3c4a7d2f Check for correct funtion entry address in munge_threadfunc
* init.cc (munge_threadfunc): Check that we're actually replacing
	the correct original function address on the stack.
	* ntdll.h (enum _THREADINFOCLASS): Add ThreadQuerySetWin32StartAddress.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-10-29 09:17:57 +01:00
Jon Turney e30d78d685 Remove spurious execute permissions from some Cygwin source and text files
2015-08-21  Jon Turney  <jon.turney@dronecode.org.uk>

	* cygwin-cxx.h: Remove execute permissions.
	* fenv.cc: Ditto.
	* how-startup-shutdown-works.txt: Ditto.
	* include/arpa/nameser.h: Ditto.
	* include/arpa/nameser_compat.h: Ditto.
	* include/fenv.h: Ditto.
	* include/resolv.h: Ditto.
	* libstdcxx_wrapper.cc: Ditto.

2015-10-27  Jon Turney  <jon.turney@dronecode.org.uk>

	* winsup.api/signal-into-win32-api.c: Remove execute permissions.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2015-10-27 16:10:37 +00:00
Brian Inglis 6090952296 strftime: Add support for %s (seconds since epoch)
* libc/time/strftime.c (__strftime): add support for %s (seconds from
	Unix epoch).  Fix whitespaces.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-10-27 09:41:40 +01:00
Corinna Vinschen cf51db8baa Clear pending signals targeting exiting thread
* cygtls.cc (_cygtls::remove): Call remove_pending_sigs.
	* cygtls.h (_cygtls::remove_pending_sigs): Declare.
	* sigproc.cc (pending_signals::clear): Define new method taking a
	_cygtls pointer argument.  Drop pending signals for that thread.
	(_cygtls::remove_pending_sigs): Call pending_signals::clear for this
	thread.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-10-23 14:30:40 +02:00
Corinna Vinschen 6b457615e6 Export aligned_alloc, at_quick_exit, quick_exit.
* common.din (aligned_alloc): Export.
	(at_quick_exit): Export.
	(quick_exit): Export.

	* posix.xml (std-iso): New section.
	(std-deprec): Rearrange title text.
	* new-features.xml (ov-new2.3): Document aligned_alloc, at_quick_exit,

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-10-22 16:21:17 +02:00
Corinna Vinschen e01381afde Avoid SEGV when handling SIDs with 0 subauthorities
* sec_helper.cc (cygsid::get_sid): Don't reject SIDs with missing
	subauthorities.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-10-22 15:38:42 +02:00
Corinna Vinschen 6599fad55d Add release message for previous Cygwin patch 2015-10-22 15:35:46 +02:00
Corinna Vinschen ef75017378 Fix length returned from sys_cp_wcstombs in case nwc > # of wchars
* strfuncs.cc (sys_cp_wcstombs): Always return number of multibytes
	without trailing NUL as the documentation implies.  Throughout Cygwin,
	fix usage to align to this pattern.
	* fhandler_process.cc (format_process_winexename): Drop trailing NUL
	and LF from output.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-10-22 14:22:07 +02:00
Corinna Vinschen c0345822e5 Fix memory leak in pthread_getattr_np
* thread.cc (pthread_getattr_np): Fix memory leak, remove usage of
	malloc for small local buffer.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-10-21 12:46:32 +02:00
Corinna Vinschen 713161b28b Fix EIO error accessing certain (OS X SMB?) drives
* path.cc (symlink_info::check_reparse_point): Don't generate an EIO
	error if NtFsControlFile returns STATUS_NOT_A_REPARSE_POINT.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-10-21 12:01:11 +02:00
Corinna Vinschen 67364cbfd9 Fix compiler errors/warnings when compiling with -O3
* fhandler_socket.cc (fhandler_socket::wait_for_events): Fix compiler
	warning in -O3 case.
	(fhandler_socket::connect): Ditto.
	* regex/regcomp.c (singleton): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-10-20 12:33:13 +02:00
Corinna Vinschen 36da3f961c Cygwin 2.3.0: Add missing release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-09-08 22:53:54 +02:00
Corinna Vinschen 44e0f5a703 flock.cc: Fix stack allocation from callee used in caller
* flock.cc (lockf_t::create_lock_obj_attr): Add buffer parameter.
	Call _everyone_sd with buffer argument from caller rather than
	everyone_sd with locally allocated stack buffer.
	(lockf_t::create_lock_obj): Call create_lock_obj_attr only once
	outside the loop and with additional buffer argument.
	(lockf_t::open_lock_obj): Call create_lock_obj_attr with additional
	buffer argument.
2015-09-08 16:39:54 +02:00
Corinna Vinschen 8fb2a01188 sysconf.cc: Fix compiler warning.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-29 09:32:00 +02:00
Corinna Vinschen 38fd7ddb79 Allow sysconf to return CPU cache information
* include/sys/unistd.h (_SC_LEVEL*): Add cache-related variables as
        on Linux.

        * fhandler_proc.cc (format_proc_cpuinfo): Fetch cache information
        from new cache functions in sysconf.cc, get_cpu_cache_intel and
        get_cpu_cache_amd.
        * sysconf.cc (__nt_query_system): New local helper.
        (get_nproc_values): Utilize __nt_query_system on pre-Windows 7 systems.
        Use GetLogicalProcessorInformationEx otherwise to handle more than
        64 CPUs.  Only handle _SC_NPROCESSORS_CONF and _SC_NPROCESSORS_ONLN.
        (get_phys_pages): New helper to handle _SC_PHYS_PAGES.
        (cpuid2_cache_descriptor): New array to map Intel CPUID 2 descriptor
        values to cache type, cache size, associativity and linesize.
        (cpuid2_cache_desc_compar): Comparision function for bsearch over
        cpuid2_cache_descriptor.
        (get_cpu_cache_intel_cpuid2): New function to fetch cache info from
        Intel CPUID 2.
        (get_cpu_cache_intel_cpuid4): Ditto from Intel CPUID 4.
        (get_cpu_cache_intel): New function as CPU-specific entry point.
        (assoc): New array to map associativity values from AMD CPUID
        0x80000006.
        (get_cpu_cache_amd): New function to fetch cache info from AMD CPUIDs
        0x80000005 and 0x80000006.
        (get_cpu_cache): New function to fetch cache info.
        (sca): Call get_phys_pages if _SC_PHYS_PAGES is requested.  Call
        get_cpu_cache for new _SC_* cache requests.
        (SC_MAX): Set to _SC_LEVEL4_CACHE_LINESIZE.
        (get_phys_pages(void)): Call get_phys_pages(int).
        * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.

        * new-features.xml (ov-new2.3): Document sysconf cache addition.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-29 09:16:47 +02:00
Corinna Vinschen 35d5d87540 Implement POSIX_MADV_WILLNEED/POSIX_MADV_DONTNEED for newer OSes
* autoload.cc (DiscardVirtualMemory): Import.
        (PrefetchVirtualMemory): Import.
        * mmap.cc (posix_madvise): Actually implement POSIX_MADV_WILLNEED
        utilizing PrefetchVirtualMemory and POSIX_MADV_DONTNEED utilizing
        DiscardVirtualMemory on systems supporting them.
        * wincap.h (wincaps::has_broken_prefetchvm): New element.
        * wincap.cc: Implement above element throughout.
        (wincapc::init): Make sure has_broken_prefetchvm is only true on
        W10 under WOW64.
        * include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2003.
        (CYGWIN_VERSION_API_MINOR): Reset to 0.

        * new-features.xml (ov-new2.3): New section, document posix_madvise
        POSIX_MADV_WILLNEED/POSIX_MADV_DONTNEED change.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-27 13:34:25 +02:00
Corinna Vinschen 9074b9b8ad fhandler_proc.cc: Only request group relation information
* fhandler_proc.cc (format_proc_cpuinfo): Only fetch group relations,
        we don't need anything else.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-26 18:39:53 +02:00
Corinna Vinschen 7f3efa3b65 winsup.h: Claim Windows 10 support
* winsup.h (_WIN32_WINNT): Set to 0x0a00 for Windows 10.
        (WINVER): Ditto.  Remove outdated comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-25 22:23:01 +02:00
Corinna Vinschen 4b104ce070 autoload.cc: Drop using full paths for system DLLs
System DLLs are always first in the DLL search order so
	http://www.microsoft.com/technet/security/advisory/2269637.mspx
	doesn't apply for them.

        * autoload.cc (std_dll_init): Revert using full paths to system DLLs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-25 22:17:43 +02:00
Corinna Vinschen 859c10beee autload.cc: Avoid clobbering return address in noload on i686
This fixes a long-standing problem when GetProcAddress fails
	to load a function.  The noload code calls SetLastError on
	i686 without saving the edx register.  Starting with Windows 7,
	SetLastError apparently uses $edx and the register is set to
	0x00000000 on return.  So the subsequent `jmp *$edx' in noload
	supposed to return to the caller, actually jumps to address NULL,
	which results in a SEGV.

        * autoload.cc (noload): i686 only: Save and restore $edx when calling
        SetLastError to avoid clobbering return address stating with Windows 7.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-25 22:15:22 +02:00
Corinna Vinschen 70b02101ca mmap.cc: Fix some comments
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-25 22:02:35 +02:00
Corinna Vinschen a396499757 Sigproc.cc: Fix copyright.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-24 19:09:16 +02:00
Corinna Vinschen dbc1cae5c5 Fix hang stracing forking processes but not following child
* ntdll.h (PROCESSINFOCLASS): Define ProcessDebugFlags.
        * sigproc.cc (child_info::child_info): Only propagate _CI_STRACED to
        child if strace is actually tracing child processes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-24 18:37:53 +02:00
Corinna Vinschen 986069c7e3 Bump Cygwin DLL minor number.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-24 18:35:49 +02:00
Corinna Vinschen cb2ab5fd01 Cygwin: Return port number from getservent in network byte order
* netdb.cc (parse_services_line): Convert port number to network byte
        order.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-18 13:12:07 +02:00
Corinna Vinschen f9f3d44f27 exceptions.cc: Drop including ucontext.h.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-18 11:09:25 +02:00
Corinna Vinschen 4cb24051f4 Don't call LsaLookupSids if we're not utilizing Windows account DBs
* grp.cc (internal_getgrfull): Drop asking caches.  Explain why.
        (internal_getgroups): In case we're not utilizing the Windows account
        DBs, don't call LsaLookupSids but iterate over the group SIDs in the
        token and call internal_getgrsid for each of them.  Explain why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-17 22:45:02 +02:00
Corinna Vinschen 88dce3abd8 Try harder to avoid LDAP access for RFC2307 mapping
* fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Rearrange
        to fall back to myself uid/gid in case we don't utilize Windows
        account DBs, just as prior to 1.7.34.
        * sec_helper.cc (cygpsid::get_id): Disable Samba user/group mapping per
        RFC2307 if we're not utilizing Windows account DBs.
        * security.cc (convert_samba_sd): Revert previous patch.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-17 20:24:49 +02:00
Corinna Vinschen 37b6936f8b Fix /proc/cpuinfo topology info on newer AMD CPUs
* fhandler_proc.cc (format_proc_cpuinfo): Handle AMDs providing
        extended topology info in CPUID leaf 0x8000001e.  Fix handling of
        AMD CPUs providing extended legacy core info in CPUID leaf 0x80000008.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-17 16:35:41 +02:00
Orgad Shaneh ede983934c mkglobals_h: Handle CRLF earlier.
When globals.cc has CRLF line endings, winsup.h is not removed, and
	compilation fails for duplicate definitions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-17 11:05:43 +02:00
Corinna Vinschen 861a27db66 Support cpb and eff_freq_ro power mgmt flags in /proc/cpuinfo
* fhandler_proc.cc (format_proc_cpuinfo): Print cpb and eff_freq_ro
        power management flags.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-17 10:04:33 +02:00
Corinna Vinschen b5f56ec286 Cygwin: Improve 2.2.1 release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-15 13:32:31 +02:00
Corinna Vinschen 344860a104 Cygwin: Try to fix potential data corruption in pipe write
* fhandler.cc (fhandler_base_overlapped::raw_write): When performing
        nonblocking I/O, copy user space data into own buffer.  Add longish
        comment to explain why.
        * fhandler.h (fhandler_base_overlapped::atomic_write_buf): New member.
        (fhandler_base_overlapped::fhandler_base_overlapped): Initialize
        atomic_write_buf.
        (fhandler_base_overlapped::fhandler_base_overlapped): New destructor,
        free'ing atomic_write_buf.
        (fhandler_base_overlapped::copyto): Set atomic_write_buf to NULL in
        copied fhandler.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-15 12:30:09 +02:00
Corinna Vinschen 36d500e425 Fix copy/paste error in previous patch
* security.cc (convert_samba_sd): Fix copy/paste error in previous
	patch.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-14 21:55:42 +02:00
Corinna Vinschen 5de7f2e6c3 Don't perform RFC2307 account mapping without account DB
* fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Only try
        to map user and group info per RFC2307 if account info is fetched
        from Windows account DB.
        (convert_samba_sd): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-14 21:41:37 +02:00
Corinna Vinschen c19f1b9f8e Evaluate all group perms in ACL to emulate POSIX user perms
* security,cc (get_attribute_from_acl): Merge all group perms into
        user perms if user is member of group.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-14 10:10:34 +02:00
Corinna Vinschen e0d48debed Fix /proc/cpuinfo topology and cache size info
* autoload.cc (GetLogicalProcessorInformationEx): Import.
        (SetThreadGroupAffinity): Import.
        * fhandler_proc.cc (add_size): New macro.
        (get_msb): New inline function.
        (mask_bits): Ditto.
        (format_proc_cpuinfo): Drop handling of old CPUs.  Check if we're
        running on a OS version supporting porcessor groups.  If so, use
        SetThreadGroupAffinity to set thread affinity.  Improve cache info
        to include 3rd level cache on Intel CPUs.  Improve multi core info.
        * wincap.h (wincaps::has_processor_groups): New element.
        * wincap.cc: Implement above element throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-13 17:59:47 +02:00
Corinna Vinschen 1e15b46737 miscfuncs.cc: Fix comment preceeding x86_64 memset and friends.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-10 12:07:22 +02:00
Corinna Vinschen 1641a85e8f Revert to leaving $HOME alone
* uinfo.cc (cygheap_user::ontherange): Revert previous patch.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-10 12:00:12 +02:00
Corinna Vinschen 09d458b5c7 Bump Cygwin DLL minor number.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-03 21:46:55 +02:00
Corinna Vinschen 7666b3634b Cygwin: Fix x86_64 memcpy/memset for n > 2GB
https://cygwin.com/ml/cygwin/2015-07/msg00344.html:

	RtlFillMemory and RtlCopyMemory only work for size values
	up to 2GB.  Fix this problem by using NetBSD code for
	memset and memcpy.  Add entry points for memmove, wmemset,
	wmemmove, wmemcpy.  Thanks to Roman Petrovski
	<RPetrovski@illumina.com> for pointing this out.

        * miscfuncs.cc (memset): x86_64 only: Implement in assembler.
        (memmove,memcpy): x86_64 only: Ditto.
        (wmemmove,wmemcpy): x86_64 only: Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-29 22:09:34 +02:00
Corinna Vinschen d32ea61ae4 cygwin: Fix copyright dates
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-29 13:45:46 +02:00
Corinna Vinschen 6ab56bdd3f cygwin: Fix crashes under AllocationPreference=0x100000 condition
* cygtls.h: Include cygtls_padsize.h and define CYGTLS_PADSIZE there.
        * cygtls_padsize.h: New file.  Define CYGTLS_PADSIZE.
        * environ.cc (parse_options): Fix NULL pointer access.
        * init.cc (threadfunc_fe): Do not force stack align on x86_64.

        * strace.cc (main2): Rename from main.
        (main): Make room for _cygtls area on stack and just call main2.  Add
        comment to explain why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-29 13:32:29 +02:00
Corinna Vinschen 03c8afda17 Improve cygwin 2.2.0 release text
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-23 21:19:43 +02:00
Corinna Vinschen be8183701a Fix potential buffer overflow in makecontext trampoline
glibc's tst-makecontext2 testcase uncovered a bug in
	__cont_link_context.  If the function misses to reserve
	shadow space for the calls to setcontext/cygwin_exit,
	both functions could overwrite memory beyond the stack
	configured in uc_stack.

        * exceptions.cc (__cont_link_context): x86_64: align stack and reserve
        shadow space for subsequent function calls, otherwise suffer potential
        buffer overflow.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-23 20:25:22 +02:00
Corinna Vinschen 1e80973f28 Ignore non-absolute $HOME when started from native process
* uinfo.cc (cygheap_user::ontherange): Ignore $HOME if it's not
	starting with a slash (aka, absolute POSIX Path).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-23 17:42:07 +02:00
Corinna Vinschen 7c96ab0b43 Cygwin: Implement siglongjmp and sigsetjmp functions.
* libc/include/machine/setjmp.h (siglongjmp): Declare as function on
	Cygwin.
	(sigsetjmp): Ditto.
	(_longjmp): Mark as noreturn function on Cygwin.

	* common.din (siglongjmp): Export.
	(sigsetjmp): Export.
	* gendef: Change formatting of some comments.
	(sigsetjmp): Implement.
	(siglongjmp): Implement.
	(__setjmpex): x86_64 only: Drop entry point.
	(setjmp): x86_64 only: Store tls stackptr in Frame now, store MXCSR
	and FPUCW registers in Spare, as MSVCRT does.
	(longjmp): x86_64 only: Restore tls stackptr from Frame now, restore
	MXCSR and FPUCW registers from Spare.
	* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.

	* new-features.xml (ov-new2.2): Document sigsetjmp, siglongjmp.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-21 17:31:02 +02:00
Corinna Vinschen b723ec272e Add previous ldd fix to release file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-20 18:43:16 +02:00
Corinna Vinschen e437a7d826 Lower Cygwin's MINSIGSTKSZ and SIGSTKSZ
* include/cygwin/signal.h (MINSIGSTKSZ): Define as 8K, unconditionally.
        (SIGSTKSZ): Define as 32K, unconditionally.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-19 22:40:29 +02:00
Corinna Vinschen 4889f730c1 Reduce stack pressure throughout Cygwin
* dcrt0.cc (initial_env): Reduce size of local path buffers to
        PATH_MAX.  Allocate debugger_command from process heap.
        (init_windows_system_directory): Very early initialize new global
        variable global_progname.
        * dll_init.cc (dll_list::alloc): Make path buffer static.  Explain why.
        (dll_list::populate_deps): Use tmp_pathbuf for local path buffer.
        * exceptions.cc (debugger_command): Convert to PWCHAR.
        (error_start_init): Allocate debugger_command and fill with wide char
        strings.  Only allocate if NULL.
        (try_to_debug): Just check if debugger_command is a NULL pointer to
        return.  Drop conversion from char to WCHAR and drop local variable
        dbg_cmd.
        * globals.cc (global_progname): New global variable to store Windows
        application path.
        * pinfo.cc (pinfo_basic::pinfo_basic): Just copy progname over from
        global_progname.
        (pinfo::status_exit): Let path_conv create the POSIX path to
        avoid local buffer.
        * pseudo_reloc.cc (__report_error): Utilize global_progname, drop local
        buffer.
        * smallprint.cc (__small_vsprintf): Just utilize global_progname for
        %P format specifier.
        (__small_vswprintf): Ditto.
        * strace.cc (PROTECT): Change to reflect x being a pointer.  Reformat.
        (CHECK): Ditto.  Reformat.
        (strace::activate): Utilize global_progname, drop local buffer.
        Fix formatting.
        (strace::vsprntf): Reduce size of local progname buffer to NAME_MAX.
        Copy and, if necessary, convert only the last path component to
        progname.
        (strace_buf_guard): New muto.
        (buf): New static pointer.
        (strace::vprntf): Use buf under strace_buf_guard lock only.  Allocate
        buffer space for buf on Windows heap.
        * wow64.cc (wow64_respawn_process): Utilize global_progname, drop
        local path buffer.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-19 22:38:30 +02:00
Corinna Vinschen 93a8435f82 Remove x86_64 __sjfault/__ljfault
* gendef: Remove unused 64 bit versions of __sjfault and __ljfault.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-18 14:48:32 +02:00
Corinna Vinschen 877b02be08 Rearrange makecontext and add lots of comments
* exceptions.cc (makecontext): Rearrange order of initialization and
        document at great length.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-18 12:35:23 +02:00
Corinna Vinschen b2df1577c7 Fix ucontext creation in call_signal handler
* exceptions.cc (__unwind_single_frame): Define empty macro on i686.
        (_cygtls::call_signal_handler): Try to make sure signal context makes
        sense in case we're generating context here.  Add comment to explain.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-17 18:29:52 +02:00
Corinna Vinschen 16d2d9f131 Comment fixup
* exceptions.cc (getcontext/x86_64): Drop comment on RtlCaptureContext.
        (swapcontext/x86_64): Fix comment yet again.
        (getcontext/i686): Move comment from x86_64 getcontext, slightly
        rearranged, to preceeding comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-17 16:47:14 +02:00
Corinna Vinschen b3ccf998cc Reuse __unwind_single_frame where appropriate
* exceptions.cc (__unwind_single_frame): Move up in file to be
        accessible from other places.  Move comment to getcontext.
        (stack_info::walk): Call __unwind_single_frame in 64 bit case.  Fix
        preceeding comment.
        (myfault_altstack_handler): Call __unwind_single_frame.
        (getcontext): Give comment from __unwind_single_frame a new home.
        (swapcontext): Fix comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-17 16:29:41 +02:00
Corinna Vinschen 1020bb292a Implement getcontext, setcontext, makecontext, swapcontext
* common.din (getcontext): Export.
        (makecontext): Export.
        (setcontext): Export.
        (swapcontext): Export.
        * exceptions.cc (__unwind_single_frame): New static functions, 64 bit
        only.
        (setcontext): New function.
        (getcontext): New function.
        (swapcontext): New function.
        (__cont_link_context): New function.
        (makecontext): New function.
        * include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2002.
        (CYGWIN_VERSION_API_MINOR): Bump.
        * include/ucontext.h (getcontext): Add prototype.
        (setcontext): Ditto.
        (swapcontext): Ditto.
        (makecontext): Ditto.
        * ntdll.h (NtContinue): Ditto.

        * new-features.xml (ov-new2.2): Add new section.  Document getcontext,
        setcontext, makecontext, swapcontext.
        * posix.xml (std-deprec): Add getcontext, setcontext, makecontext,
        swapcontext.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-17 14:31:12 +02:00
Corinna Vinschen 9a69aac0ed Document the fact that we forgot to bump for sigaltstack and sethostname
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-17 14:02:43 +02:00
Corinna Vinschen 211cd495c4 exceptions.cc: Reenable code only disabled for debug purposes
* exceptions.cc (exception::handle): Reenable code only disabled for
	debug purposes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-13 16:08:29 +02:00
Corinna Vinschen b90a91a618 tzset: Check timezone and country case-insensitive
* tzset.c (main): Check timezone and country case-insensitive.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-08 10:25:49 +02:00
Corinna Vinschen e6b882b957 Add accidentally missing ChangeLog entry for previous patch
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-07 20:49:02 +02:00
Corinna Vinschen 60f10c64aa x86_64: Handle myfault exceptions when running on alternate signal stack
x86_64 only:
        * cygtls.cc (san::leave): Restore _my_tls.andreas.
        * cygtls.h (class san):  Add _clemente as in 32 bit case.  Add ret and
        frame members.
        (san::san): Handle _my_tls.andreas as on 32 bit.  Take parameter and
        write it to new member ret.  Store current stack pointer in frame.
        (san::~san): New destructor to restore _my_tls.andreas.
        (__try): Use __l_except address as parameter to san::san.
        * dcrt0.cc (dll_crt0_0): Add myfault_altstack_handler as vectored
        continuation handler.
        * exception.h (myfault_altstack_handler): Declare.
        * exceptions.cc (myfault_altstack_handler): New function.  Explain what
        it's good for.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-07 20:45:06 +02:00
Corinna Vinschen 29a1263227 Simplify stack allocation code in child after fork
* child_info.h (CURR_CHILD_INFO_MAGIC): Update.
        (child_info_fork::alloc_stack_hard_way): Drop declaration.
        * dcrt0.cc (child_info_fork::alloc_stack_hard_way): Fold into
        child_info_fork::alloc_stack.
        (getstack): Remove.
        (child_info_fork::alloc_stack): Simplify check for application-provided
        stack in "hard way" code.  Don't call getstack for each page, just
        reallocate stack immediately as required.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-07 17:24:49 +02:00
Corinna Vinschen 606013bcf1 Simplify fork code setting up child stack info
* fork.cc (frok::parent): Simplify code propagating stack setup to
        child process.  Tweak comments.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-07 17:05:20 +02:00
Yaakov Selkowitz c9b3716279 winsup/cygwin: rework basename redefinition handling in path.cc
This fixes the compile after commit 79e419de62.

* path.cc: Rework basename redefinition handling.  Explain why.
2015-07-06 15:18:09 -05:00
Corinna Vinschen 14e3fd1b22 Align hard stack allocation to pthread stack setup changes
* dcrt0.cc (CYGWIN_GUARD): Remove.
	(child_info_fork::alloc_stack_hard_way): Align stack commit to changes
	of thread stack setup in CygwinCreateThread.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-05 17:45:29 +02:00
Corinna Vinschen a54bc198b1 Implement correct RLIMIT_STACK handling
* miscfuncs.cc (struct pthread_wrapper_arg): Add member guardsize.
        (pthread_wrapper): Set thread stack guarantee according to guardsize.
        Tweak assembler code so that $rax/$eax is not required by GCC to
        prepare the wrapper_arg value.
        (CygwinCreateThread): Fix deadzone handling.  Drop setting a "POSIX"
        guardpage (aka page w/ PAGE_NOACCESS).  Always use Windows guard
        pages instead.  On post-XP systems (providing SetThreadStackGuarantee)
        always set up stack Windows like with reserved/commited areas and
        movable guard pages.  Only on XP set up stack fully commited if the
        guardpage size is not the default system guardpage size.
        Fill out pthread_wrapper_arg::guardsize.  Improve comments.
        * resource.cc: Implement RSTACK_LIMIT Linux-like.
        (DEFAULT_STACKSIZE): New macro.
        (DEFAULT_STACKGUARD): Ditto.
        (rlimit_stack_guard): New muto.
        (rlimit_stack): New global variable holding current RSTACK_LIMIT values.
        (__set_rlimit_stack): Set rlimit_stack under lock.
        (__get_rlimit_stack): Initialize rlimit_stack from executable header
        and return rlimit_stack values under lock.
        (get_rlimit_stack): Filtering function to return useful default
        stacksize from rlimit_stack.rlim_cur value.
        (getrlimit): Call __get_rlimit_stack in RLIMIT_STACK case.
        (setrlimit): Call __set_rlimit_stack in RLIMIT_STACK case.
        * thread.cc (pthread::create): Fetch default stacksize calling
        get_rlimit_stack.
        (pthread_attr::pthread_attr): Fetch default guardsize calling
        wincap.def_guard_page_size.
        (pthread_attr_getstacksize): Fetch default stacksize calling
        get_rlimit_stack.
        * thread.h (PTHREAD_DEFAULT_STACKSIZE): Remove.
        (PTHREAD_DEFAULT_GUARDSIZE): Remove.
        (get_rlimit_stack): Declare.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-05 15:51:37 +02:00
Corinna Vinschen e426213a88 Disable fetching heap info on 64 bit XP/2003
* fhandler_process.cc (heap_info::heap_info): Disable fetching heap info
        on 64 bit XP/2003.  Explain why.
        * wincap.h (wincaps::has_broken_rtl_query_process_debug_information):
        New element.
        * wincap.cc: Implement above element throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-05 12:53:30 +02:00
Corinna Vinschen f0464fbf9d Add missing wincap changes to previous ChangeLog entry
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-05 12:48:05 +02:00
Corinna Vinschen 2cd7eb7f60 Fix original stack when running signal handler on alternate stack
* autoload.cc (SetThreadStackGuarantee): Import.
        * cygtls.h (struct _cygtls): Replace thread_context with a ucontext_t
        called context.
        * exceptions.cc (exception::handle): Exit from process via signal_exit
        in case sig_send returns from handling a stack overflow SIGSEGV.
        Explain why.
        (dumpstack_overflow_wrapper): Thread wrapper to create a stackdump
        from another thread.
        (signal_exit): Fix argument list to reflect three-arg signal handler.
        In case we have to create a stackdump for a stack overflow condition,
        do so from a separate thread.  Explain why.
        (sigpacket::process): Don't run signal_exit on alternate stack.
        (altstack_wrapper): Wrapper function to do stack correction when
        calling the signal handler on an alternate stack to handle a stack
        overflow.  Make sure to have lots of comments.
        (_cygtls::call_signal_handler): Drop local context variable to reduce
        stack pressure.  Use this->context instead.  Change inline assembler
        to call altstack_wrapper.
        (_cygtls::signal_debugger): Accommodate aforementioned change to
        struct _cygtls.
        * tlsoffset.h: Regenerate.
        * tlsoffset64.h: Regenerate.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-04 22:49:30 +02:00
Corinna Vinschen fc22f77503 Document previous change
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-01 15:50:18 +02:00
Corinna Vinschen e3d345c5c3 Fix fork after recovered stack overflow
* fork.cc (frok::parent): Set stacktop value based on requested stack
	pointer value in child.  Explain why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-01 15:28:16 +02:00
Corinna Vinschen 0f3e631571 Add comment to sigaltstack to explain setting ss_flags here
* signal.cc (sigaltstack): Add comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-30 20:43:50 +02:00
Corinna Vinschen c2c1b84309 Handle ss_flags value longjmp safe.
* exceptions.cc (_cygtls::call_signal_handler): Drop manipulating
	thread's ss_flags here.  It's not safe against longjmp.
	* signal.cc (sigaltstack): Check if we're running on the alternate
	stack and set ss_flags returned in oss to SS_ONSTACK.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-27 12:08:07 +02:00
Corinna Vinschen ba170254e6 Define larger MINSIGSTKSZ and SIGSTKSZ values for Cygwin
* include/cygwin/signal.h: Revert to define MINSIGSTKSZ and SIGSTKSZ
	here with bigger values to allow _cygtls to reside on signal stack,
	should it turn out to be required at one point.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-26 21:41:26 +02:00
Corinna Vinschen 2ecaa3c176 Fix values returned by getrlimit(RLIMIT_STACK)
* resource.cc (getrlimit): Fix values returned by RLIMIT_STACK.
	Explain why this had to be changed.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-26 20:41:54 +02:00
Ken Brown d04fd9d5f7 Complement SIGEV_* enums with macros
* include/cygwin/signal.h (SIGEV_*): Add macros.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-23 10:39:06 +02:00
Corinna Vinschen f4abb28ea8 Don't push on original stack during alternate signal stack setup
* exceptions.cc (_cygtls::call_signal_handler): Drop pushing a register
	on the original stack, it confuses GCC.  Rearrange the assembler code
	so that $rax/$eax is not used by GCC to prepare an argument value.
	Use $rax/$eax without saving.  Drop clearing $rbp/$epb.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-22 13:09:55 +02:00
Corinna Vinschen b6c18f2a64 Safe all clobbered volatile registers when using alternate stack
* exceptions.cc (_cygtls::call_signal_handler): Drop subtracting 16
	bytes from the alternate stack, it's not necessary.  Safe all clobbered
	registers.  Safe one on the orignal stack, the others on the alternate
	stack on both platforms.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-21 13:58:57 +02:00
Corinna Vinschen 44745e3165 Fix comments
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-20 20:56:55 +02:00
Corinna Vinschen a88afecce6 ChangeLog entries for Cygwin's alternate signal stack implementation
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-20 20:36:16 +02:00
Corinna Vinschen b782f869bf Add alternate signal stack to docs
* new-features.xml (ov-new2.1): Add alterante signal stack info.
	* posix.xml (std-susv4): Move sigaltstack here.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-20 20:30:17 +02:00
Corinna Vinschen 0cbf19283b Implement using alternate signal stack in Cygwin
* exceptions.cc (_cygtls::call_signal_handler): Implement alternate
	signal stack handling.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-20 20:21:02 +02:00
Corinna Vinschen 6442e914d9 Use MINSIGSTKSZ and SIGSTKSZ from newlib for Cygwin as well
* libc/include/sys/signal.h: Move altstack macros completely
	outside of rtems block.

	* include/cygwin/signal.h: Remove definitions of MINSIGSTKSZ
	and SIGSTKSZ here.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-20 19:05:51 +02:00
Corinna Vinschen 74d272cc02 Handle exceptions in sigaltstack
* signal.cc (sigaltstack): Add fault handler.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-20 18:48:09 +02:00
Corinna Vinschen 22465796ed Preliminary infrastructure to implement alternate stack
* libc/include/sys/signal.h: Define SS_ONSTACK and SS_DISABLE
	unconditionally.
	(sigaltstack): Enable prototype on Cygwin.

	* common.din (sigaltstack): Export.
	* cygtls.cc (_cygtls::init_thread): Initialize altstack.
	* cygtls.h (__tlsstack_t): Rename from __stack_t to distinguish
	more clearly from stack_t.  Accommodate throughout.
	(_cygtls): Add altstack member.
	* exceptions.cc (exception::handle): Set SIGSEGV handler to SIG_DFL
	if we encounter a stack overflow, and no alternate stack has been
	defined.
	* include/cygwin/signal.h (MINSIGSTKSZ): Define
	(SIGSTKSZ): Define.
	(SA_ONSTACK): Define.
	* signal.cc (sigaltstack): New function.
	* tlsoffset.h: Regenerate.
	* tlsoffset64.h: Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-19 16:12:45 +02:00
Corinna Vinschen 715ac1e872 Formatting fixes in exceptions.cc
* Makefile.in (install-man): Exclude release subdir from search paths.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-19 16:12:10 +02:00
Corinna Vinschen 0d3304af38 Disallow installing "man pages" from release subdir
* Makefile.in (install-man): Exclude release subdir from search paths.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-18 22:04:58 +02:00
Corinna Vinschen 50b00d2b93 Add sethostname
* net.cc (sethostname): New function.
	* common.din (sethostname): Export
	* include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2001.
	(CYGWIN_VERSION_DLL_MINOR): Set to 0.

	* new-features.xml (ov-new): Rename from ov-new1.7.
	(ov-new2.1): Add new section.  Document sethostname.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-17 11:11:02 +02:00
Corinna Vinschen c7af199237 Add release/2.0.5 file 2015-06-17 10:37:10 +02:00
Corinna Vinschen 79d65a1ed2 Try to handle concurrent close on socket more gracefully
* fhandler_socket.cc (LOCK_EVENTS): Don't enter critical section with
	invalid mutex handle since then socket has been closed.
	(UNLOCK_EVENTS): Close critical section.
	(fhandler_socket::evaluate_events): Handle calling connect on shutdown
	socket.
	(fhandler_socket::wait_for_events): Try for pthread_testcancel in case
	of WAIT_FAILED.  Try to come up with a better errno in case we waited
	on an invalid handle.
	(fhandler_socket::release_events): Change wsock_mtx and wsock_evt to
	NULL under lock to avoid accessing invalid handle.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-15 18:29:56 +02:00
Corinna Vinschen 6f9e2f3ed5 Handle more Winsock error codes.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-15 16:17:16 +02:00
Corinna Vinschen 95c5a3f6b7 Don't enforce SA_RESTART in non-main threads
* exceptions.cc (_cygtls::call_signal_handler): Disable enforcing
	SA_RESTART in non-main threads to allow returning with EINTR from
	system calls.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-15 16:15:54 +02:00
Corinna Vinschen b81a830f1a Fix ChangeLog entry 2015-06-11 15:39:34 +02:00
Corinna Vinschen 5979b17401 Bump minor DLL version to 5
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-11 12:59:12 +02:00
Corinna Vinschen 6261fb30a9 Avoid compiler warning in latest patch
* pinfo.cc (_pinfo::cwd): Initialize s to avoid comiler warning.
	(_pinfo::cmdline): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-08 21:55:11 +02:00
Corinna Vinschen 575ec00a43 Evaluate /proc/$PID/{root,cwd,cmdline} for native processes
* pinfo.cc (_pinfo::root): Fake default root for native processes.
	(open_commune_proc_parms): New helper function to access process
	parameter block.
	(_pinfo::cwd): Fetch missing cwd for native processes from processes
	parameter block.
	(_pinfo::cmdline): Ditto for command line.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-08 21:48:13 +02:00
Corinna Vinschen 79511853f7 add bind mount fix to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-08 17:48:34 +02:00
Corinna Vinschen 95868172f3 Avoid delays trying to fetch Cygwin info from non-Cygwin processes
* pinfo.cc (_pinfo::commune_request): Don't try to send commune
	requests to non-Cygwin processes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-08 14:38:30 +02:00
Takashi Yano 511eb2f264 Generate SIGHUP for terminal process group on tty master close
* fhandler_tty.cc (fhandler_pty_slave::write): Move causing of SIGHUP
	into fhandler_pty_master::close().
	(fhandler_pty_slave::read): Ditto.
	(fhandler_pty_master::close): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-08 14:07:42 +02:00
Corinna Vinschen 4c3946c350 Bump minor DLL version to 4
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-08 13:58:39 +02:00
Corinna Vinschen 64848af0bf Add Cygwin 2.0.3 release file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-03 13:38:19 +02:00
Corinna Vinschen da1611493a Bump minor DLL version to 3
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-02 14:10:30 +02:00
Corinna Vinschen 712811e9bb Use NtQueryObject to detect closing the last master handle
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-05-28 16:09:46 +02:00
Takashi Yano 3afe8808b9 * net.cc: Define _NETIOAPI_H_ to accomodate newer w32api.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-05-27 13:30:20 +02:00
Corinna Vinschen 761a123a4f Bump minor DLL version to 2
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-05-03 12:28:39 +02:00
Corinna Vinschen d4058c6686 Bump minor DLL version to 1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-30 17:53:15 +02:00
Corinna Vinschen b07326d29e Use all ACEs from original ACL on Samba share
* security.cc (convert_samba_sd): Fix accidental dropping of all
	non-Unix User, non-Unix Group accounts.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-30 17:26:55 +02:00
Corinna Vinschen 49c051c133 Define __s64 and __u64
* include/asm/types.h: Add __s64 and __u64 types.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-27 14:40:27 +02:00
Corinna Vinschen f21c9bface Document previous unlink patch
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:04:59 +02:00
Corinna Vinschen 5abb0ed13c Handle unlinking in-use files on virtual drives
* path.cc (path_conv::set_nt_native_path): New function.
        * path.h (path_conv::set_nt_native_path): Add prototype.
        * syscall.cc (try_to_bin): Handle moving files to the recycler
        accessed via a local virtual drive (subst).  Fix a problem renaming
        the file to the unique replacement name on Samba.  Align comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:04:59 +02:00
Corinna Vinschen 4e99630cfd Fix closing too many handles in pty fchown/fchmod
* fhandler_tty.cc (fhandler_pty_slave::fch_close_handles): Don't close
	handles not opened via fhandler_pty_slave::fch_open_handles.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:04:59 +02:00
Takashi Yano c846bca992 Fix OPOST for non-Cygwin pty slaves
* fhandler.h (class fhandler_base): Add virtual function
	get_io_handle_cyg() to get handle from which OPOST-processed output is
	read on PTY master.
	(class fhandler_pty_slave): Add variable output_handle_cyg to store a
	handle to which OPOST-processed output is written. Add two functions,
	i.e., set_output_handle_cyg() and get_output_handle_cyg(), regarding
	variable output_handle_cyg. Now, output_handle is used only by native
	windows program. The data before OPOST-processing is written to
	output_handle and OPOST-processing is applied in the master-side. For a
	cygwin process, OPOST-processing is applied in the slave-side, and the
	data after OPOST-processing is written to output_handle_cyg.
	(class fhandler_pty_master): Add two variables, i.e., io_handle_cyg and
	to_master_cyg, to store handles of a pipe through which OPOST-processed
	output passes. Add pty_master_fwd_thread and function
	pty_master_fwd_thread() for a thread which applies OPOST-processing
	and forwards data from io_handle to to_master_cyg. Add function
	get_io_handle_cyg() regarding variable io_handle_cyg. Now, the pipe
	between io_handle and to_master are used only by native windows program
	for applying OPOST-processing in the master-side. For a cygwin process,
	the pipe between io_handle_cyg and to_master_cyg is used for passing
	through the data which is applied OPOST-processing in the slave-side.
	* fhandler_tty.cc (struct pipe_reply): Add member to_master_cyg.
	(fhandler_pty_master::process_slave_output): Read slave output from
	io_handle_cyg rather than io_handle.
	(fhandler_pty_slave::fhandler_pty_salve): Initialize output_handle_cyg.
	(fhandler_pty_slave::open): Set output_handle_cyg by duplicating handle
	to_master_cyg on PTY master.
	(fhandler_pty_slave::close): Close handle output_handle_cyg.
	(fhandler_pty_slave::write): Write data to output_handle_cyg rather
	than output_handle.
	(fhandler_pty_slave::fch_close_handles): Close handle output_handle_cyg.
	(fhandler_pty_master::fhandler_pty_master): Initialize io_handle_cyg,
	to_master_cyg and master_fwd_thread.
	(fhandler_pty_master::cleanup): Clean up to_master_cyg as well.
	(fhandler_pty_master::close): Print to_master_cyg as well in debug
	message. Terminate master forwarding thread. Close handles
	to_master_cyg and io_handle_cyg.
	(fhandler_pty_master::ioctl): Use io_handle_cyg rather than to_master.
	(fhandler_pty_master::pty_master_thread): Add code for duplicating
	handle to_master_cyg.
	(fhandler_pty_master::pty_master_fwd_thread): New function for a thread
	to forward OPOST-processed data from io_handle to to_master_cyg.  This
	thread applies OPOST-processing to the output of native windows program.
	(::pty_master_fwd_thread): Ditto.
	(fhandler_pty_master::setup): Create a new pipe to pass thruegh OPOST-
	processed output. Create new thread to forward data from io_handle to
	to_master_cyg. Set handle to_master_cyg to tty. Print io_handle_cyg as
	well in debug message. Close handles io_handle_cyg and to_master_cyg in
	case of error.
	(fhandler_pty_master::fixup_after_fork): Set handle to_master_cyg to
	tty. Copy handle to_master_cyg from arch->to_master_cyg.
	(fhandler_pty_master::fixup_after_exec): Clean up to_master_cyg.
	* select.cc: Check handle returned by get_io_handle_cyg() rather than
	get_handle().
	* tty.h (class tty): Add variable _to_master_cyg to store a handle to
	which OPOST-processed data is written. Add two functions,
	to_master_cyg() and set_to_master_cyg(), regarding _to_master_cyg.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:04:24 +02:00
Corinna Vinschen 6d099d5bae Undef basename before defining function.
* path.cc (basename): Undefine basename before defining function to
        avoid type collision with prototype in string.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:03:45 +02:00
Corinna Vinschen e0aa6d23fb Remove Cygwin's libgen.h
* include/libgen.h: Remove in favor of newlib version.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:03:45 +02:00
Corinna Vinschen 5dc398f1d9 Fix broken SID in passwd/group entry for unkown account
* uinfo.cc (pwdgrp::fetch_account_from_windows): Always revert SID
        subauth count after checking for known domain.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:01:53 +02:00
Corinna Vinschen 83b3f891c4 Fix broken PSID problem on cygheap in account handling
* pwdgrp.h: Add comment to explain below change.
        (struct pg_pwd): Convert sid member to BYTE array.
        (struct pg_grp): Ditto.
        * grp.cc (pwdgrp::parse_group): Accommodate above change.
        * passwd.cc (pwdgrp::parse_passwd): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:01:53 +02:00
Corinna Vinschen 023be4aedb Don't rely on size argument in shmget call
* shm.cc (shmget): Fetch segment size from server rather than using
	size argument to accommodate existing segments.  Add comment to explain
	why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:59:49 +02:00
Corinna Vinschen 5778304f16 Bump Cygwin version to 2.0.0.
* include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2000.
	(CYGWIN_VERSION_DLL_MINOR): Set to 0.

	* new-features.xml (ov-new2.0): Rename from ov-new1.7.36 and change
	version number to 2.0.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:58:33 +02:00
Jon TURNEY bccc0e83e8 Set mcontext.cr2 to the faulting address
* exceptions.cc (call_signal_handler): Set mcontext.cr2 to the
	faulting address.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-04-23 21:58:33 +02:00
Jon TURNEY 9043956ce8 Only construct ucontext for SA_SIGINFO signal handlers
* exceptions.cc (call_signal_handler): Only bother to construct
	the ucontext for signal handlers with SA_SIGINFO set.  Set
	mcontext.oldmask.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-04-23 21:58:32 +02:00
Jon TURNEY 65c071bc4d Initialize context before RtlContextCapture
* exceptions.cc (call_signal_handler): Zero initialize context and set
	context flags, as RlCaptureContext doesn't.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-04-23 21:58:32 +02:00
Corinna Vinschen 19dc6ee82c Call open_null to open fake handle
* fhandler_dsp.cc (fhandler_dev_dsp::open): Call open_null.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:57:13 +02:00
Corinna Vinschen 853fcd8936 Introduce sidfromuid and sidfromgid
* pwdgrp.h (sidfromuid): New inline function.
	(sidfromgid): Ditto.
	* fhandler_disk_file.cc (fhandler_disk_file::fchown): Use sidfromuid.
	* quotactl.cc (quotactl): Use sidfromuid and sidfromgid.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:57:12 +02:00
Corinna Vinschen 651bb62ae2 Remove __acl16 from official header
* include/cyggwin/acl.h (struct __acl16): Move from here...
	* sec_acl.cc: ...to here.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:57:12 +02:00
Corinna Vinschen 84b8db8e7a Remove unused 32/64 bit tty code
* tty.h (class tty): Remove unused 32/64 bit interoperability
	considerations.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:57:12 +02:00
Corinna Vinschen 19c6889c37 Raise # of ptys to 128.
* tty.h (NTTYS): Raise to 128.
	* devices.in: Change pty, ptym, and cons expressions accordingly.
	* devices.cc: Regenerate.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:57:12 +02:00
Jon TURNEY 4f28e8a0e5 Compile exceptions.cc with -fno-omit-frame-pointer on x86
Selectively using -fomit-frame-pointer when -O is used doesn't make sense
anymore, apparently since gcc 4.6, -O implies -fomit-frame-pointer.

exceptions.cc must be compiled with -fno-omit-frame-pointer on x86, as it uses
RtlCaptureContext, which requires a frame pointer.

	* Makefile.in : Remove setting -fomit-frame-pointer for compiling
	various files, it is already the default.  Set
	-fno-omit-frame-pointer for exceptions.cc on x86.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-04-23 21:57:11 +02:00
Takashi Yano 252a07b0ad Cygwin hangs up if several keys are typed during outputting a lot of texts.
* fhandler_tty.cc (fhandler_pty_slave::read): Change calculation of
	"readlen" not to use "bytes_in_pipe" value directly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:57:11 +02:00