Commit Graph

16764 Commits

Author SHA1 Message Date
Nick Clifton 3ff65caea5 Always define __high_bsssize, do not just PROVIDE it.
* msp430/msp430xl-sim.ld (__high_bsssize): Define.
2015-12-04 10:14:10 +00: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
Michael Kwasigroch 9471b0b36d Fix SEGV of kill -l 0
* kill.cc (strsigno): Don't call sys_sigabbrev for signal 0.
	(listsig): Don't call strsigno for signal 0.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-26 22:31:01 +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
David Macek 6de53a3516 Add MacType to BLODA
One more patch. MacType was observed by several users to cause `GPGME:
Invalid crypto engine` failures in MSYS2. See
<https://github.com/Alexpux/MSYS2-packages/issues/393>.

I also removed two full stops in the sake of consistency.

	* faq-using.xml: Add MacType to the BLODA.  Fix formatting.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-26 10:26:45 +01:00
David Macek c33794d202 Add a section describing peculiarities of how Cygwin creates NTFS symlinks
First take on how to describe dereferencing of Cygwin-only symlinks path
components when creating NTFS symlinks.

Note that I haven't tried building the documentation, so I don't know if
the added paragraph breaks anything. Hopefully not.

	* pathnames.xml: Add a section describing peculiarities of how Cygwin
	creates NTFS symlinks.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-26 10:23:36 +01:00
David Macek 76b5c03bd7 Add Forefront TMG to the BLODA
A user of MSYS2 had non-deterministic segfaults when running simple
command from bash started from cmd. We've isolated the cause to
`C:\Program Files (x86)\Forefront TMG Client\FwcWsp64.dll`. See
<http://sourceforge.net/p/msys2/tickets/212/> for a little more
information.

It seems enough to include the software in BLODA, but if not, sorry for
the unsolicited patch and let's discuss.

	* faq-using.xml: Add Forefront TMG to the BLODA

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-26 10:19:58 +01:00
Corinna Vinschen 1628bb8995 Only build _strtodg_r on targets supporting a distinct long double type
* libc/stdlib/strtodg.c: Add ifdef to check _HAVE_LONG_DOUBLE and
	_LDBL_EQ_DBL.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-26 10:13:53 +01:00
Steve Ellcey 10677229b9 libc/stdlib/strtorx.c: Fix ifdef to check _LDBL_EQ_DBL. 2015-11-24 13:59:31 -08:00
Marcus Shawcroft 8e62ab4ccc [ARM] Adjust strcmp-armv7.S selection logic.
Reformulate the strcmp-armv7.S selection logic around the architecture
features required by the implementation code rather (some) version of
the architecture that expose those features.
2015-11-23 15:22:26 +00:00
Marcus Shawcroft dc38827570 [ARM] Factor out the thumb2 -Os implementation.
The patch moves the inline ASM thumb2 -Os implementation out into its
own .S file.

Tested by building newlib and comparing libc.a binaries before and
after for all permutations of:

      Architectures:
        armv4 armv4t armv5 armv5t armv5te armv6 armv6j armv6k
        armv6z armv6kz armv6t2 armv6-m armv6s-m armv7 armv7-a
        armv7ve armv7-r armv7-m armv7e-m armv8-a iwmmxt iwmmxt2

      ISAs:
        thumb arm

      Optimization Levels:
        Os O2

      Excluding:
        armv6s-m -mthumb
        armv6-m -mthumb

        armv6zk -mthumb
        armv6z -mthumb
        armv6k -mthumb
        armv6j -mthumb
2015-11-23 15:21:47 +00:00
Nick Clifton c70d8f454a Fix initialisation of .upper.bss for the MSP430.
* msp430/msp430xl-sim.ld (__high_bsssize): Define.
2015-11-23 09:00:23 +00: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 666a3482a5 Handle multibyte decimapl point in strtold.
* libc/stdlib/strtodg.c: Define USE_LOCALE.
	(_strtodg_r): Handle multibyte decimal point.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-21 16:40:21 +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 51bf1b81f3 Make match function globally available to stdlib functions.
* libc/stdlib/strtod.c (match): Move from here...
	* libc/stdlib/gdtoa-hexnan.c (match): ...to here.
	* libc/stdlib/mprec.h (match): Declare and add __match define.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-20 18:03:05 +01:00
Corinna Vinschen b5d8a403ec Drop unused declaration from wcstold.c
* libc/stdlib/wcstold.c (_strtold): Drop unused declaration.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-20 17:57:20 +01:00
Yaakov Selkowitz 1c1a925fc4 Fix typo in rpmatch doc reference
* libc/stdlib/stdlib.tex: Fix typo in rpmatch reference.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2015-11-19 15:28:06 -06:00
Corinna Vinschen fcc2dcbb21 ldtoa.c: Reindent to GNU style
* libc/stdlib/ldtoa.c: Convert to GNU style so as not to get crazy
	reading the code.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-19 17:09:58 +01:00
Corinna Vinschen e2802064b2 Fix rpmatch build problem
* libc/stdlib/rpmatch.c: Include sys/types.h to make GCC happy.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-19 16:31:08 +01:00
Jon Turney bdc6169381 Simplify the markup for sprintf and swprintf documentation
- move the description of the alternative form produced with the # flag from a
nested table to an additional table

2015-11-12  Jon Turney  <jon.turney@dronecode.org.uk>

	* libc/stdio/sprintf.c: Simplify documentation markup.
	* libc/stdio/swprintf.c: Ditto.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2015-11-19 11:39:52 +00:00
Jon Turney 21e6ba20ae Improve markup of sscanf and swscanf documentation
- use bullet points to separate width, size and type sections, rather than using
rows in an enormous table, for consistency with sprintf and swprintf.

- use code markup for size bullet point for consistency

- use a texinfo multitable for description of the size flags, rather than some
preformatted text

- tidy up some whitespace so type flags are all aligned

2015-11-12  Jon Turney  <jon.turney@dronecode.org.uk>

	* libc/stdio/sscanf.c: Improve documentation markup.
	* libc/stdio/swscanf.c: Ditto.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2015-11-19 11:39:49 +00: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 4dc3deea89 setfacl: Allow to combine -b and -k options
* setfacl.c (action_t): Rename DeleteAll to DeleteExt.  Add
	DeleteAll.  Rearrange for bit-wise testing later in the code.
	(delallacl): Handle -b -k combination.
	(setfacl): Handle DeleteExt/DeleteAll.
	(usage): Fix -b/-k output.  Rearrange output to better fill 80
	columns.
	(main): Allow to combine -b and -k.

	* utils.xml (setfacl): Accommodate -b/-k change.
	* new-features.xml (ov-new2.3): Add setfacl -b/-k change.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-18 22:41:11 +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