Commit Graph

10701 Commits

Author SHA1 Message Date
Corinna Vinschen 0f4510230a 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-08 11:00:08 +02:00
Corinna Vinschen 0411e86216 Use NULL dey ACE rather than special Cygwin ACE
* 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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-08 10:19:33 +02:00
Corinna Vinschen 6326a8c0f3 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-08 10:19:33 +02:00
Corinna Vinschen cf38039975
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-07 12:16:07 +02:00
Corinna Vinschen de7944034d 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-07 12:14:22 +02:00
Jon TURNEY 72f7cd89f2 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-07 12:08:40 +02:00
Takashi Yano 8e01f34ed1 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-03 13:23:51 +02:00
David A. Wheeler 78cfc586c8 Add FAQ entry on how Cygwin counters install and update MITM attacks
* faq-setup.xml: Document how Cygwin secures installation and
	update against man-in-the-middle (MITM) attacks.  Note that
	setup embeds a public key to check the signature of setup.ini,
	and that setup.ini includes SHA-512 cryptographic hashes.

Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
2015-04-03 13:07:26 +02:00
Jon TURNEY cbb9849fa7 Try to make sure struct _mcontext is 16-byte aligned
On x86_64, RtlCaptureContext() uses fxsave to save FPU/MMX/SSE state.

fxsave requires that the destination address is 16-byte aligned, or it will
fault.

CONTEXT is already annotated __attribute__ ((aligned (16))), do the same with
struct _mcontext.

Rearrange ucontext_t so that it's struct _mcontext element is also correctly
aligned.

	* include/cygwin/signal.h (struct __mcontext): 16-byte align.
	* include/sys/ucontext.h (ucontext_t): Ditto.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-04-02 18:05:32 +01:00
Corinna Vinschen 94bb7da6b4
Rename index variable from i to idx.
* 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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-02 13:48:55 +02:00
Corinna Vinschen ca973c0224
Drop unused parameter from add_access_*_ace
* 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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-02 13:46:04 +02:00
Corinna Vinschen b5fdd3cd8e
Drop local stdint.h and inttypes.h in favor of newlib files
* include/cygwin/types.h: Include sys/_stdint.h rather than stdint.h.
	* include/stdint.h: Drop in favor of newlib version.
	* include/inttypes.h: Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-01 20:37:58 +02:00
Jon TURNEY 28e457cd71 Provide ucontext to signal handlers
Add ucontext.h header, defining ucontext_t and mcontext_t types.

Provide sigaction sighandlers with a ucontext_t parameter, containing stack and
context information.

	* include/sys/ucontext.h : New header.
	* include/ucontext.h : Ditto.
	* exceptions.cc (call_signal_handler): Provide ucontext_t
	parameter to signal handler function.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-04-01 19:09:28 +01:00
Jon TURNEY 431b28c196 Add cygwin_internal() operation to retrieve the EXCEPTION_RECORD from a siginfo_t *
* external.cc (cygwin_internal): Add operation to retrieve a copy
	of the EXCEPTION_RECORD from a siginfo_t *.
	* include/sys/cygwin.h (cygwin_getinfo_types): Ditto.
	* exception.h (cygwin_exception): Add exception_record accessor.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-04-01 18:32:01 +01:00
Jon TURNEY abf6791ecb Rename struct ucontext to struct __mcontext
* include/cygwin/signal.h : Rename struct ucontext to struct
	__mcontext.  Fix layout differences from the Win32 API CONTEXT
	type.  Remove unused member _internal.  Rename member which
	corresponds to ContextFlags.  Add cr2 member.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-04-01 18:26:45 +01:00
Corinna Vinschen 829c8f6c2d
Fix UTF-16 surrogate handling in wctomb and friends.
* libc/stdlib/wctomb_r.c (__utf8_wctomb): Fix check for handling a
	lone high surrogate.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-01 15:31:18 +02:00
Corinna Vinschen 849044a1e9
Avoid potential crash at startup or in getgroups(2).
* grp.cc (internal_getgroups): Handle negative domain index to avoid
	crashes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-01 13:15:18 +02:00
Jon TURNEY 69d477a25c Fix documentation of cygwin_internal()'s return type.
* misc-funcs.xml (cygwin_internal): Correct return type.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-03-31 23:15:42 +01:00
Renato Silva 2cf6edf4ef
Fix buffer size error handling in gethostname.
* net.cc (cygwin_gethostname): Fix buffer size error handling.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-31 21:18:46 +02:00
Corinna Vinschen 46d2802c27
Add release msg
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-31 13:13:06 +02:00
Corinna Vinschen 87dd9bec10
Document GNU basename.
* new-features.xml (ov-new1.7.36): Add new section.  Document GNU
	basename.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-31 13:12:24 +02:00
Corinna Vinschen 1c7ac6e190
Don't allow fully qualified Windows account names.
* uinfo.cc (pwdgrp::fetch_account_from_windows): Don't allow fully
	qualified Windows account names (domain\user or user@domain).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-31 11:54:34 +02:00
Corinna Vinschen 5f4e1e895c
Add _tzset_unlocked and _tzset_unlocked_r
newlib:

	* libc/time/local.h (_tzset_unlocked_r): Add prototype.
	(_tzset_unlocked): Ditto.
	* libc/time/tzset.c (_tzset_unlocked): New function, call
	_tzset_unlocked_r.
	(tzset): Lock and call _tzset_unlocked_r.
	* libc/time/tzset_r (_tzset_unlocked_r): Remove locking and rename
	from _tzset_r.
	(_tzset_r): Lock and call _tzset_unlocked_r.

cygwin:

	* localtime.cc (tzset_unlocked): Export as _tzset_unlocked.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-31 11:14:22 +02:00
Yaakov Selkowitz 1f9716e160 cygwin: add GNU basename(3)
winsup/cygwin/
* common.din (__gnu_basename): Export.
* path.cc (__gnu_basename): New function.

winsup/doc/
* posix.xml (std-gnu): Add basename.
(std-notes): Add note about two forms of basename.
2015-03-30 13:24:54 -05:00
Corinna Vinschen 98209e8e30
Try best to handle user from domain not in trusted domain list.
* cygheap.h (cygheap_domain_info::add_domain): Add prototype.
	* uinfo.cc (cygheap_domain_info::add_domain): New method.
	(pwdgrp::fetch_account_from_windows): Try to add domain explicitely
	if it was not in the original list of trusted domains and go ahead
	rather than bailing out.  Add comment to explain why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-30 18:05:06 +02:00
Corinna Vinschen 40b1aa4008
Prepare to rename/reuse struct ucontext.
* cygtls.h (struct _cygtls): Convert thread_context to type CONTEXT.
	* exceptions.cc (_cygtls::signal_debugger): Use sizeof (CONTEXT) for
	size of CONTEXT copied for GDB's digestion.
	* include/cygwin/signal.h: Add a preliminary comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-30 16:53:52 +02:00
Corinna Vinschen 13681ab7f1
Add CMIN and CTIME definitions
* include/sys/termios.h: Add CMIN and CTIME.
	* fhandler_termios.cc (fhandler_termios::tcinit): Use CMIN and CTIME.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-25 17:21:38 +01:00
Corinna Vinschen 842983ce04 Bump tty.cc copyright date 2015-03-25 17:17:15 +01:00
Takashi Yano c596f5b73c
TIOCPKT mode of PTY is broken if ONLCR bit is cleared.
* tty.h (class tty_min): Remove variable "write_error" to which any
	errors are not currently set at anywhere.
	(class tty): Add variable "column" for handling ONOCR.
	* tty.cc (tty::init): Add initialization code for variable "column".
	* fhandler.h (class fhandler_pty_master): Remove variable "need_nl"
	which is not necessary any more. "need_nl" was needed by OPOST process
	in fhandler_pty_master::process_slave_output().
	(class fhandler_pty_common): Add function process_opost_output() for
	handling post processing for OPOST in write process.
	* fhandler_tty.cc (fhandler_pty_master::process_slave_output): Count
	TIOCPKT control byte into length to be read in TIOCPKT mode. Move
	post processing for OPOST to write process. Remove code related to
	variable "write_error". Return with EIO error if slave is already
	closed.
	(fhandler_pty_master::fhandler_pty_master): Remove initialization
	code for variable "need_nl".
	(fhandler_pty_common::process_opost_output): Add this function for
	handling of OPOST in write process. Add code to avoid blocking in
	non-blocking mode when output is suspended by ^S.
	(fhandler_pty_slave::write): Call fhandler_pty_common::
	process_opost_output() instead of WriteFile(). Remove code related to
	variable "write_error".
	(fhandler_pty_master::doecho): Call fhandler_pty_common::
	 process_opost_output() instead of WriteFile().
	* select.cc (peek_pipe): Remove code related to variable "need_nl".

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-25 16:00:46 +01:00
Corinna Vinschen 57a78e23fd
Ignore __STDC_{FORMAT,LIMIT,CONSTANT}_MACROS
Per glibc BZ #15366:
	* inttypes.h: Drop __STDC_FORMAT_MACROS consideration.
	* stdint.h: Drop __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
	consideration.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-24 10:42:45 +01:00
Corinna Vinschen 548d795d62
Drop cygwin/_types.h.
* include/cygwin/_types.h: Drop unused file.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-23 11:52:05 +01:00
Corinna Vinschen 1c144ed142
Handle S_ISGID bit and multiple ACEs for owner
* 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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-19 18:27:03 +01:00
Corinna Vinschen 52f01a0ff8
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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-18 17:49:12 +01:00
Corinna Vinschen 4a9636b1d6
Implmenet faster getfrompw/getfromgr
* grp.cc (pwdgrp::parse_group): Call cygsid::getfromgr_passwd.
	* passwd.cc (pwdgrp::parse_passwd): Call cygsid::getfrompw_gecos.
	* pwdgrp.h (cygsid::getfrompw): Implement as inline method here,
	accessing pg_pwd's sid member directly.
	(cygsid::getfromgr): Implement as inline method here, accessing
	pg_grp's sid member directly.
	* sec_auth.cc (extract_nt_dom_user): Call cygsid::getfrompw_gecos.
	Explain why.
	* sec_helper.cc (cygsid::getfrompw): Drop implementation.
	(cygsid::getfromgr): Ditto.
	* security.h (cygsid::getfrompw_gecos): Implement former getfrompw
	inline here.
	(cygsid::getfromgr_passwd): Implement former getfromgr inline here.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-18 17:15:27 +01:00
Corinna Vinschen 1d91d469ee
Drop unneeded passwd argument from security functions
* sec_auth.cc (get_server_groups): Drop unused passwd argument.  Adjust
	calls throughout.
	(get_initgroups_sidlist): Ditto.
	(get_setgroups_sidlist): Ditto.
	(create_token): Ditto.
	(lsaauth): Ditto.
	* security.h (create_token): Adjust prototype to above change.
	(lsaauth): Ditto.
	(get_server_groups): Ditto.
	* grp.cc (get_groups): Adjust call to get_server_groups.
	* syscalls.cc (seteuid32): Adjust calls to lsaauth and create_token.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-18 16:54:19 +01:00
Corinna Vinschen 6f93f1d6a5
Drop unused timeoput paramter to internal_getlogin
* grp.cc (internal_getgroups): Drop unused timeout parameter.
	* pwdgrp.h (internal_getgroups): Ditto in prototype.
	* uinfo.cc (internal_getlogin): Ditto in usage.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-17 15:42:59 +01:00
Corinna Vinschen 8f00fa7f36
Avoid name change if script is called via symlink from execvp et al.
* spawn.cc (find_exec): Fix a name change in case of a symlink which
	can be opened as is.

Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
2015-03-17 11:40:12 +01:00
Jon TURNEY b7f2a6c0a7 Fix winsup/doc to install into prefix
By default, docdir and htmldir are defined in terms of prefix, so make sure to
define it, so their values are prefix-relative.

Without this, 'make install' installs the documentation into /share/doc/ unless
configured otherwise.

	* Makefile.in (prefix): Define.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-03-16 14:53:05 +00:00
Jon TURNEY e9e47b8ce6 Teach stackinfo::walk() how to virtually unwind the tls sigstack
This improves how stackinfo::dumpstack() dumps _sigbe and sigdelayed frames

	* exceptions.cc (stack_info): Add sigstackptr member.
	(walk): Unwind sigstackptr inside _sigbe and sigdelayed.
	* gendef (_sigdelayed_end): Add symbol to mark end of sigdelayed.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-03-13 13:05:52 +00:00
Corinna Vinschen 63c9ffeed8
Remove now useless include/cygwin/sys_time.h
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-13 13:22:19 +01:00
Alexey Pavlov aaa7d1f14a
net.cc: Remove extra braces.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-13 10:38:49 +01:00
Alexey Pavlov 63b41daeb6
Fix typo in include/cygwin/version.h
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-12 18:48:59 +01:00
Corinna Vinschen f9d35f473b
Drop defining _BSDTYPES_DEFINED before including winsup.h.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-12 17:11:19 +01:00
Takashi Yano 32fd5b0fe1
Let pty slave detect closure of last master handle
* fhandler_tty.cc (fhandler_pty_master::close): Add code to make slave
	detect closure of master. Fix typo in error message.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-12 15:48:10 +01:00
Corinna Vinschen a34ebbad28
Fix more typos in ntsec.xml
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-12 11:14:57 +01:00
Corinna Vinschen 1aa532fec2
Fix typos in ntsec.xml
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-12 10:53:33 +01:00
Corinna Vinschen 6e90585ad8
Include sys/_timespec.h in cygwin/types.h to adjust to newlib
* include/cygwin/types.h: Include <sys/_timespec.h>

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-11 15:47:19 +01:00
Corinna Vinschen 6bd719beeb
* autoload.cc (CreateEnvironmentBlock): Make loading non-fatal.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-03-11 12:56:53 +01:00
Corinna Vinschen f085e9d321 Fix condition in DLL loading loop 2015-03-11 12:22:45 +01:00
Yaakov Selkowitz 2a6db5083c cygwin: fix __x86_64__ conditional in stdint.h
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2015-03-10 16:32:52 -05:00