Commit Graph

284 Commits

Author SHA1 Message Date
Corinna Vinschen 75543537a1 * Throughout, replace usage of w32api's min with MIN from sys/param.h. 2012-03-08 09:36:11 +00:00
Christopher Faylor 8f937028d9 * exceptions.cc (exception::handle): Drop abbreviation for "exception" since I
never remember what it stands for.
(sig_handle_tty_stop): Remove obsolete call to sig_handle_tty_stop.
(_cygtls::call_signal_handler): Rework to grab signal information from
_main_tls if none is set for _my_tls.  Try harder to keep thread locked.
(reset_signal_arrived): Delete.
* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Use new cygWFMO call
to wait for an event + standard cygwin stuff.  Modify debug output to
acccomodate new function.
* fhandler_console.cc (fhandler_console::read): Replace WaitForMultipleObjects
with cygWFMO.
* fhandler_socket.cc (get_inet_addr): Add comment.
* gendef (_sigdelayed): Remove call to reset_signal_arrived.
* sigproc.cc (_cygtls::signal_exit): Don't close my_readsig here unless we're
in the signal thread.
(create_signal_arrived): Create signal_arrived as auto-reset so that only one
thread is woken when a signal arrives.
* sigproc.h (cygWFMO): New function.
(reset_signal_arrived): Delete declaration.
2011-12-04 17:58:24 +00:00
Christopher Faylor b9aa81491f Throughout, remove extra space after function name from debugging output.
Throughout, change syscalls to report on return values using new %R format
option.
* smallprint.cc (__small_vsprintf): Add parsing for %R to report on return
values and possible errno from syscalls.
* errno.cc (errmap): Add PRIVILEGE_NOT_HELD.
* fhandler_tty.cc (fhandler_pty_master::setup): When creating a thread use
shorter name to reduce debuggging output.
* select.cc (start_thread_pipe): Ditto.
(start_thread_serial): Ditto.
(start_thread_socket): Ditto.
(start_thread_mailslot): Ditto.
* sigproc.cc (talktome): Ditto.
2011-12-03 21:43:27 +00:00
Christopher Faylor 23771fa1f7 * cygerrno.h (__set_errno): Modify debugging output to make searching strace
logs easier.  Throughout, change /dev/tty* to /dev/pty*.  Throughout, add flags
argument to fhandler_*::dup methods.
* devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN.  Add /dev/ptymN
devices for pty masters.
* devices.cc: Regenerate.
* devices.h (MAX_CONSOLES): Set to max number supported by devices.in.
(fh_devices::FH_PTMX): Rename from FH_PTYM.
(device::operator int): Return by reference.
* dtable.cc (fh_alloc): Take pc as an argument rather than just the device.
This makes debugging easier since more information is available.  Actually
implement handling for already-allocated pty master devices.  Make different
decisions when generating fhandler for not-opened devices.  Add kludge to deal
with opening /dev/tty.
(cnew_no_ctor): New macro.
(build_fh_pc): Make debugging output more verbose.  Use new clone() fhandler
interface to duplicate archetypes.  Reset last term opened.
(dtable::dup_worker): Use Use new clone() fhandler interface to duplicate
archetypes.  Pass flags to child dup handler.
(dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr.
* fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce
functionality and sense of copy direction.
(fhandler_base::open_with_arch): Use published interface to query io_handle().
Use new copyto() fhandler method to copy from/to found archetype.
* fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_*
(void *) methods.
(fhandler_base::reset): Rename from operator =().
(fhandler_termios::is_dev_tty): Delete.
(fhandler_termios): change "protected" region to "private".
(fhandler_termios::is_dev_tty): Delete.
(fhandler_termios): Rearrange protected/public.
(fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened".
(fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened.
(ioctl): Rename from ioctl_termios.  Take a void * argument.  Reflect argument
change in pinfo::set_ctty.
(fhandler_console::dup): Declare new function.  Set ctty here if appropriate.
(fhandler_pty_master::from_master): Privatize.
(fhandler_pty_master::to_master): Ditto.
(fhandler_pty_master::dwProcessId): Ditto.
(fhandler_pty_master::fhandler_pty_master): Add an `int' argument.
(fhandler_pty_master::open_setup): Declare new function.
(fhandler_pty_master::~fhandler_pty_master): Declare new method.
(fhandler_nodevice): Remove commented out function declaration.
* fhandler_console.cc: Use get_ttyp() instead of tc() throughout.
(fhandler_console::dup): Define new function to set controlling ctty on dup, as
appropriate.
(fhandler_console::ioctl): Reflect ioctl_termios name change.
(fhandler_console::setup): Rename from get_tty_stuff.
(fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty.
(fhandler_console::fhandler_console): Set _tc here.
* fhandler_termios.cc (handler_termios::ioctl): Rename.  Take a void * arg like
other ioctl functions.
* fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to
potentially reset the controlling terminal.
(fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios.
(fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument.  Call setup()
here so that we will know the unit number of this fhandler as soon as possible.
Set the unit as appropriate.
(handler_pty_master::open): Move most stuff to constructor and open_setup.
(handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty.
(handler_pty_master::open_setup): Define new function.
(fhandler_pty_master::cleanup): Clear handles as a flag that the destructor
does not have to do "close" operations.
(fhandler_pty_master::close): Ditto.
(fhandler_pty_master::~fhandler_pty_master): Define new method.
(fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios.
(fhandler_pty_master::setup): Allocate tty here.  Rely on handles being
returned from allocated test rather than opening them here.  Avoid setting
_need_nl here since it is already zeroed in the constructor.  Set up device
information with DEV_TTYM_MAJOR.
* path.h (path_conv &operator =): Take a const argument.
(path_conv::dup): Ditto.
(pathconv_arg::PC_OPEN): New enum.
(pathconv_arg::PC_CTTY): Ditto.
(path_types::PATH_CTTY): Ditto.
(path_types::PATH_OPEN): Ditto.
(path_conv::isopen): New method.
(path_conv::isctty_capable): Ditto.
* path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate.
* pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle.
* syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on
non-std* handles.
* tty.cc (tty_list::allocate): Pass out handles for allocated tty.  use
`not_allocated' to find unallocated ttys.  Avoid keeping the lock since the
allocation of the tty should be sufficient to prevent multiple access.
(tty::not_allocated): Clarify comment.  Rename.  Return handles when an unused
tty is found.  Simply test for existing tty.
(tty::exists): Rewrite to use `not_allocated'.
* tty.h (NTTYS): Reset down to actual number supported by devices.in.
(tty::not_allocated): Declare new function.
(tty_list::allocate): Pass out read/write tty handles.  Zero them when not
found.
* fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX.
* pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in.
* pinfo.cc (pinfo::set_ctty): Ditto.  Just use tc() built into the passed-in
fhandler_termios pointer.  Return true if ctty is assigned.
* syscalls.cc (open): Call build_fh_pc with PC_OPEN flag.  Set PC_CTTY if
appropriate.
(stat_worker): Remove is_dev_tty () stuff.
2011-10-15 22:37:30 +00:00
Corinna Vinschen 247caa48ea * fhandler_socket.cc (fhandler_socket::send_internal): Fix setting
nosignal flag.  Convert ECONNABORTED on connection-oriented socket
	to EPIPE, too.
2011-08-23 13:07:24 +00:00
Corinna Vinschen d32e0bfc08 * syscalls.cc (faccessat): Fix parens in flag expression when calling
build_fh_name.

	* fhandler_disk_file.cc (fhandler_disk_file::mkdir): Fix typo in
	comment.
	* fhandler_socket.cc (fhandler_socket::bind): Ditto.
	* path.cc (symlink_worker): Ditto.
2011-08-01 17:01:38 +00:00
Corinna Vinschen c114604529 * fhandler.h (class fhandler_dev_mem): Remove dup method declaration.
* fhandler_clipboard.cc (fhandler_dev_clipboard::dup): Accommodate the
	fact that the entire fhandler gets copied over to the child in
	operator =.
	* fhandler_floppy.cc (fhandler_dev_floppy::dup): Ditto.
	* fhandler_raw.cc (fhandler_dev_raw::dup): Ditto.
	* fhandler_serial.cc (fhandler_serial::dup): Ditto.
	* fhandler_socket.cc (fhandler_socket::dup): Ditto.
	* fhandler_virtual.cc (fhandler_virtual::dup): Ditto.
	* fhandler_mem.cc (fhandler_dev_mem::dup): Ditto.  Remove entirely.
2011-07-31 12:37:52 +00:00
Corinna Vinschen c487f2fef5 Throughout change "WinSock" to "Winsock" in comments.
* fhandler_socket.cc (fhandler_socket::sendmsg): Add missing call to
	get_inet_addr to convert AF_LOCAL to AF_INET sockets.
	* net.cc (cygwin_socket): Workaround UDP Winsock problem.  Add comment
	to explain why.
	* select.cc: Include winsock2.h rather than winsock.h.
2011-07-29 12:47:54 +00:00
Corinna Vinschen fcacca02dd * fhandler.cc (fhandler_base::open): Don't open file with WRITE_DAC
access on remote filesystem.  Explain why.
	* fhandler_disk_file.cc (fhandler_disk_file::mkdir): Ditto for
	directories.
	* fhandler_socket.cc (fhandler_socket::bind): Ditto for sockets.
	* path.cc (symlink_worker): Ditto for symlinks.
2011-07-05 09:59:34 +00:00
Christopher Faylor b86f999af1 whitespace elimination 2011-06-06 05:02:13 +00:00
Corinna Vinschen 933d2af50d * fhandler_socket.cc (get_inet_addr): Rearrange for better readability.
Make waiting loop interruptible and cancelable.  Check for SYSTEM DOS
	flag before reading the file.  Change return value to return 0 on
	success, SOCKET_ERROR on failure.
	(fhandler_socket::bind): Only set R/O DOS flag on filesystems not
	supporting ACLs.
	(fhandler_socket::connect): Accommodate changed return values from
	get_inet_addr.  Use SOCKET_ERROR instead of -1.
	(fhandler_socket::sendto): Accommodate changed return values from
	get_inet_addr.
	* syslog.cc (connect_syslogd): Ditto.
2011-05-11 08:20:17 +00:00
Corinna Vinschen a4e5706eb2 * fhandler.h (fhandler_socket::read): Declare.
(fhandler_socket::write): Declare.
	* fhandler_procsys.cc (fhandler_procsys::read): Add FIXME comment.
	(fhandler_procsys::write): Ditto.
	* fhandler_socket.cc (fhandler_socket::read): New method.
	(fhandler_socket::write): New method.
	* syscalls.cc: Rearrange order of read/write functions.
	(read): Call fhandler read method directly instead of just readv.
	(readv): Remove EINTR loop.  This is done in all affected fhandler's
	now.
	(write): Call fhandler write method directly instead of just writev.
	Fix debug output.
2011-05-06 10:56:37 +00:00
Corinna Vinschen 1804be048a * fcntl.cc (fcntl64): Call pthread_testcancel.
* fhandler_socket.cc (fhandler_socket::connect): Ditto.
	(fhandler_socket::accept4): Ditto.
	(fhandler_socket::recvfrom): Ditto.
	(fhandler_socket::recvmsg): Ditto.
	(fhandler_socket::sendto): Ditto.
	(fhandler_socket::sendmsg): Ditto.
	* flock.cc (lf_setlock): Allow to cancel thread running blocking
	file lock.  Try to make code more readable.
	(lockf): Call pthread_testcancel.
	* mmap.cc (msync): Ditto.
	* posix_ipc.cc (ipc_cond_timedwait): Call pthread::static_cancel_self
	rather than pthread_testcancel.
	* select.cc (cygwin_select): Call pthread_testcancel.
	* syscalls.cc (pread): Ditto.
	(pwrite): Ditto.
	(readv): Ditto.
	(writev): Ditto.
	(open): Ditto.
	(close): Ditto.
	(fsync): Ditto.
	* termios.cc (tcdrain): Ditto.
	* thread.cc: Align list of cancellation points with above changes.
	Mark not-implemented functions, too.
	(cancelable_wait): Don't set unused object indices to WAIT_FAILED
	since that could result in wrong behaviour.  Set them to the invalid
	value WAIT_TIMEOUT + 1 instead.
2011-04-30 16:34:48 +00:00
Corinna Vinschen 0077cd1016 * fhandler_socket.cc (fhandler_socket::evaluate_events): Handle the
FD_CLOSE event specially when called from accept.  Explain why.
	(fhandler_socket::shutdown): Fake success on not-connected socket and
	trigger socket event if the read side of a socket is affected.  Explain
	why.
	* poll.cc (poll): Check for saw_shutdown_read on sockets to generate
	POLLHUP as well.
2011-04-18 11:44:17 +00:00
Corinna Vinschen bb8216a114 * autoload.cc (GetExtendedTcpTable): Remove.
(GetTcpTable): Remove.
	(CharNextExA): Remove.
	(FindWindowA): Remove.
	(ShowWindowAsync): Remove.
	* dcrt0.cc (disable_dep): Remove unused function.
	(dll_crt0_0): Drop comment babbling about TS & DEP.
	* fhandler_socket.cc (address_in_use): Remove unused function.
	* wincap.cc: Throughout, drop ts_has_dep_problem from wincaps.
	(wincapc::init): Drop code setting ts_has_dep_problem flag.
	* wincap.h (struct wincaps): Drop ts_has_dep_problem flags and method.
2011-04-02 11:30:27 +00:00
Corinna Vinschen 39735c85f2 * fhandler_socket.cc (get_inet_addr): Make externally available.
* autoload.cc (GetUdpTable): Define.
	* syslog.cc (connect_syslogd): Use get_inet_addr rather than _stat64
	to check for local socket file.  Create socket with type returned by
	get_inet_addr.  If connect on UDP socket works, test if there's
	really a listening peer, otherwise fall back to Windows event log.
	(try_connect_syslogd): Use syslogd_inited flag to check if syslogd
	is available.
2011-03-29 11:07:23 +00:00
Corinna Vinschen 69d7815eae * fhandler.cc (fhandler_base::open): When creating a file on a
filesystem supporting ACLs, create the file with WRITE_DAC access.
	Explain why.
	* fhandler_disk_file.cc (fhandler_disk_file::mkdir): Ditto for
	directories.
	* fhandler_socket.cc (fhandler_socket::bind): Ditto for sockets.
	* path.cc (symlink_worker): Ditto for symlinks.
	* security.cc (get_file_sd): Always call GetSecurityInfo for directories
	on XP and Server 2003.  Improve comment to explain why.
	(set_file_attribute): Explicitely cast mode_t value to bool in call to
	get_file_sd.
	* wincap.h (wincaps::use_get_sec_info_on_dirs): New element.
	* wincap.cc: Implement above element throughout.
2011-03-08 14:26:15 +00:00
Corinna Vinschen 291698e54a * fhandler_socket (fhandler_socket::readv): Call recv_internal directly,
rather than recvmsg.
	(fhandler_socket::writev): Call send_internal directly, rather than
	sendmsg.
	* net.cc (cygwin_recv): Call fhandler_socket::recvfrom directly, rather
	than cygwin_recvfrom.
	(cygwin_send): Call fhandler_socket::sendto directly, rather than
	cygwin_sendto.
2011-02-21 17:01:05 +00:00
Corinna Vinschen 3591470260 * Throughout fix copyright dates. 2011-02-15 15:56:03 +00:00
Corinna Vinschen adef8606bd * fhandler_socket.cc (address_in_use): Improve comment readability. 2011-01-31 08:53:57 +00:00
Corinna Vinschen a01454811a * fhandler_socket.cc (address_in_use): Disable. Add comment.
(fhandler_socket::bind): Change comment to explain setting the
	SO_EXCLUSIVEADDRUSE socket option.  Remove code which checks for
	address in use.
	* net.cc (cygwin_setsockopt): Never set SO_REUSEADDR option.  Improve
	comment to compensate for the deleted comment in fhandler_socket::bind.
	* wincap.cc: Throughout, drop has_enhanced_socket_security from wincaps.
	* wincap.h (struct wincaps): Drop has_enhanced_socket_security flags
	and method.
2011-01-30 21:52:12 +00:00
Corinna Vinschen 93a4d9d97c * fhandler_socket.cc (fhandler_socket::wait_for_events): Call
pthread_testcancel in case of timeout to enable pthread_cancel
	on waiting thread.
2011-01-28 11:17:29 +00:00
Corinna Vinschen 6fe59500e5 * fhandler_socket.cc (fhandler_socket::bind): Drop has_exclusiveaddruse
condition.  Fix comment about availability.  Move remaining comment to
	the right spot.  Drop has_ip_helper_lib condition.
	* net.cc (cygwin_setsockopt): Drop has_disabled_user_tos_setting
	condition.  Fix comment.
	(get_2k_ifs): Fix comment.
	(get_nt_ifs): Remove.
	(getifaddrs): Drop call to get_nt_ifs.
	(get_ifconf): Ditto.
	* wincap.cc: Throughout, drop has_ip_helper_lib,
	has_disabled_user_tos_setting, and has_exclusiveaddruse settings from
	wincaps.
	(wincap_unknown): Remove.
	(wincap_nt4): Remove.
	(wincap_minimal): New macro, set to wincap_nt4sp4 for now.
	(wincapc::init): Drop test for pre-SP4 NT4.  Just imply at least NT SP4.
	Replace references to wincap_unknown with references to wincap_minimal.
	* wincap.h (struct wincaps): Drop has_ip_helper_lib,
	has_disabled_user_tos_setting, and has_exclusiveaddruse flags and
	methods.
2010-09-25 20:06:21 +00:00
Corinna Vinschen 0ef4bb7c50 * fhandler_socket.cc (get_inet_addr): Only test the file for being a
socket after opening it.  Retry if opening failed with sharing
	violation.  Explain why we do this.
	(fhandler_socket::bind): Create file with no sharing allowed.
2010-04-13 19:56:30 +00:00
Corinna Vinschen d8b4cbe896 * fhandler_socket.cc (fhandler_socket::wait_for_events): Remove call to
sig_dispatch_pending.
2010-03-30 16:20:15 +00:00
Corinna Vinschen 65b4b495c6 * fhandler_socket.cc (fhandler_socket::evaluate_events): Make erase
const in parameter list.
	(fhandler_socket::wait_for_events): Take a DWORD flags value instead of
	just a bool.  Call evaluate_events with erase flag according to
	MSG_PEEK value in flags.  Replace check for dontwait with check for
	MSG_DONTWAIT in flags.
	(fhandler_socket::connect): Call wait_for_events with 0 flags value.
	(fhandler_socket::accept4): Ditto.
	(fhandler_socket::recv_internal): Save flags in wait_flags.  Drop
	dontwait variable.  Call wait_for_events with wait_flags.
	(fhandler_socket::send_internal): Save MSG_DONTWAIT flag in wait_flags
	and call wait_for_events with wait_flags as argument.  Drop dontwait
	variable.
	* fhandler.h (class fhandler_socket): Change second parameter in
	declaration of wait_for_events to const DWORD.
2010-03-22 10:47:53 +00:00
Corinna Vinschen 1a8d1e1040 * fhandler_socket.cc (fhandler_socket::accept4): Reset async flag
on accepted socket.
2010-01-16 10:22:58 +00:00
Corinna Vinschen 9d5bf1b13c * fhandler_socket.cc (fhandler_socket::accept4): Set nonblocking
flag exactly according to flags, as on Linux.
	* net.cc (cygwin_accept): Maintain BSD semantics here.
2010-01-15 21:34:27 +00:00
Corinna Vinschen 0d6531551b * cygwin.din (accept4): Export.
* fhandler.h (fhandler_socket::accept4): Rename from accept.  Take
	additional flag parameter.
	* fhandler_socket.cc (fhandler_socket::accept4): Ditto.  Handle
	SOCK_NONBLOCK and SOCK_CLOEXEC flags.
	* net.cc (cygwin_socket): Handle SOCK_NONBLOCK and SOCK_CLOEXEC flags
	in type.  Check for invalid flag values.
	(socketpair): Ditto.
	(cygwin_accept): Accommodate renaming of fhandler_socket::accept
	function to accept4.
	(accept4): New function.
	* posix.sgml: Mention accept4 as GNU extensions.
	* include/cygwin/socket.h (SOCK_NONBLOCK): Define.
	(SOCK_CLOEXEC): Define.
	(_SOCK_FLAG_MASK): Define when building Cygwin.
	* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
	* include/sys/socket.h (accept4): Declare.
2010-01-15 15:40:05 +00:00
Corinna Vinschen 935d37f116 * fhandler.h (fhandler_socket::wait_for_events): Drop parameter default
value.
	* fhandler_socket.cc (fhandler_socket::connect): Add false as second
	parameter to wait_for_events call.
	(fhandler_socket::accept): Ditto.
	(fhandler_socket::send_internal): Fix typo in call to wait_for_events.
2009-12-28 17:24:03 +00:00
Corinna Vinschen f16706de97 Throughout, replace hMainProc with GetCurrentProcess/NtCurrentProcess
according to context.  Throughout, replace hMainThread with
	GetCurrentThread/NtCurrentThread according to context.
	* dcrt0.cc (dll_crt0_0): Drop duplication of GetCurrentProcess to
	hMainProc.  Drop duplication of GetCurrentThread to hMainThread.
	* dtable.cc (dtable::stdio_init): Remove useless comment.
	* globals.cc (hMainProc): Remove.
	(hMainThread): Remove.
	* ntdll.h (NtCurrentProcess): Define.
	(NtCurrentThread: Define.
2009-12-18 20:32:04 +00:00
Corinna Vinschen 2bc3381e5c * fhandler_socket.cc (send_internal): Don't split datagram messages
into pieces.

	* syslog.cc (vsyslog): Set default facility to LOG_USER if it hasn't
	been set yet.
2009-12-02 15:23:03 +00:00
Corinna Vinschen 27bbefdefd * fhandler_socket.cc (fhandler_socket::fixup_before_fork_exec): Add
socket handle value to debug output.
	(fhandler_socket::fixup_after_fork): Ditto.  Make new socket handle
	OVERLAPPED, just as if it has been created with socket().
	* net.cc (fdsock): Close duplicated socket and explain why.  Disable
	the entire WSADuplicateSocket test for now and explain why.
2009-11-23 14:50:14 +00:00
Corinna Vinschen 013e402bfc * fhandler_socket.cc (fhandler_socket::set_close_on_exec): Only call
fhandler_base::set_close_on_exec for inheritable sockets.
2009-11-23 12:21:39 +00:00
Corinna Vinschen b14f53a8ec Reintegrate socket duplication via WSADuplicateSocket/WSASocket.
* autoload.cc (WSADuplicateSocketW): Define.
	(WSASocketW): Define.
	* dtable.cc (dtable::release): Call dec_need_fixup_before if necessary.
	(dtable::fixup_before_fork): New function.
	(dtable::fixup_before_exec): New function.
	* dtable.h (class dtable): Add member cnt_need_fixup_before.  Add
	declarations for above new functions.
	(dtable::dec_need_fixup_before): New inline method.
	(dtable::inc_need_fixup_before): New inline method.
	(dtable::need_fixup_before): New inline method.
	* fhandler.h (fhandler_base::fixup_before_fork_exec): New virtual
	method.
	(fhandler_base::need_fixup_before): New virtual method.
	(class fhandler_socket): Add member prot_info_ptr.
	(fhandler_socket::init_fixup_before): Declare.
	(fhandler_socket::need_fixup_before): New inline method.
	(fhandler_socket::fixup_before_fork_exec): Declare.
	(fhandler_socket::fixup_after_exec): Declare.
	* fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize
	prot_info_ptr to NULL.
	(fhandler_socket::~fhandler_socket): Free prot_info_ptr conditionally.
	(fhandler_socket::init_fixup_before): New method.
	(fhandler_socket::fixup_before_fork_exec): Ditto.
	(fhandler_socket::fixup_after_fork): Use WSASocketW to duplicate
	socket if necessary.
	(fhandler_socket::fixup_after_exec): New method.
	(fhandler_socket::dup): Use fixup_before_fork_exec/fixup_after_fork
	to duplicate socket if necessary.
	* fork.cc (frok::parent): Start child suspended if some fhandler
	needs fixup before fork.  If so, call dtable::fixup_before_fork after
	CreateProcess and resume child.
	* net.cc (fdsock): Try to find out if socket needs fixup before and
	initialize socket accordingly.  Add HUGE comment to explain what happens
	and why.
	* spawn.cc (spawn_guts): Start child suspended if some fhandler needs
	fixup before exec.  If so, call dtable::fixup_before_exec after
	CreateProcess.
2009-11-17 10:43:01 +00:00
Corinna Vinschen b42441d32b * sec_helper.cc (security_descriptor::free): If sd_size is 0, call
LocalFree instead of ::free.

	* sec_acl.cc: Throughout replace old ACE flag definitions with current
	definitions as used in MSDN man pages.
	* security.cc: Ditto.

	* fhandler.cc (fhandler_base::open): Make sure file has really been
	just created before fixing file permissions.  Add S_JUSTCREATED
	attribute to set_file_attribute call.
	* fhandler_disk_file.cc (fhandler_disk_file::mkdir): Always create dir
	with default security descriptor and fix descriptor afterwards.
	Add S_JUSTCREATED flag to set_file_attribute call.
	* fhandler_socket.cc (fhandler_socket::bind): Ditto for AF_LOCAL
	socket files.
	* path.cc (symlink_worker): Ditto for symlinks.
	* security.cc (get_file_sd): Call GetSecurityInfo rather than
	NtQuerySecurityObject.  Explain why.  Change error handling accordingly.
	(alloc_sd): Skip non-inherited, non-standard entries in ACL if
	S_JUSTCREATED attribute is set.  Explain why.  Minor format fixes.
	* security.h (S_JUSTCREATED): New define.
	(security_descriptor::operator=): New operator.
2009-10-30 19:58:53 +00:00
Corinna Vinschen d358c9e9b0 * fhandler_disk_file.cc (fhandler_disk_file::link): Only append .lnk
if the original device had one, too.  Add comment.

	* fhandler_socket.cc (fhandler_socket::fstat): Always return a size of
	0 on sockets.
2009-10-12 11:57:29 +00:00
Corinna Vinschen 4abcdf2717 * fhandler_socket.cc (fhandler_socket::recv_internal): Always call
WSARecv on SOCK_STREAM sockets.
2009-09-29 08:46:29 +00:00
Corinna Vinschen 5e8d7527af * autoload.cc (WSARecv): Define.
* fhandler_socket.cc (fhandler_socket::recv_internal): Call WSARecv
	instead of WSARecvFrom if no name parameter is given.  Explain why.
2009-09-22 14:27:57 +00:00
Corinna Vinschen c1999c4b0c * (fhandler_socket::getsockname): Fix length returned for unbound
AF_LOCAL sockets.
	(fhandler_socket::getpeername): Ditto.
	* net.cc (socketpair): Don't set sun_path and peer_sun_path to
	make sure getsockname and getpeername return the correct values
	for AF_LOCAL sockets.
2009-08-14 06:58:44 +00:00
Corinna Vinschen 95a1cc7024 * fhandler_socket.cc (fhandler_socket::accept): Use sizeof rather
then constant size.  Truncate returned data, but return full address
	length as per POSIX.
	(fhandler_socket::getsockname): Truncate returned data, but return full
	address length as per POSIX.
	(fhandler_socket::getpeername): Ditto.
2009-08-13 15:44:29 +00:00
Corinna Vinschen d3d4aa96aa * fhandler.h (class fhandler_socket): Add peer_sun_path member.
(fhandler_socket::set_peer_sun_path): New method.
	(fhandler_socket::get_peer_sun_path): New method.
	* fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize
	peer_sun_path to NULL.
	(fhandler_socket::~fhandler_socket): Free peer_sun_path if necessary.
	(fhandler_socket::dup): Duplicate peer_sun_path.
	(fhandler_socket::accept): Ditto.  Return fake unbound peer content
	and len in case of AF_LOCAL sockets.
	(fhandler_socket::getsockname): Always use local sockaddr_storage to
	store socket address and copy over to incoming address.  Handle every
	namelen correctly per POSIX.
	(fhandler_socket::getpeername): Ditto.  Add code path to return
	correct value for AF_LOCAL sockets.
	(fhandler_socket::set_peer_sun_path): New method.
	* net.cc (socketpair): Set peer_sun_path to empty string, just like
	sun_path.
2009-08-13 10:26:42 +00:00
Corinna Vinschen a73a3f438b * fhandler_socket.cc (fhandler_socket::accept): Always use local
sockaddr_storage to store peer address and copy over to incoming
	peer address if available.  Truncate data as necessary according
	to POSIX.
2009-08-12 14:48:16 +00:00
Christopher Faylor 631681619e * fhandler_socket.cc (fhandler_socket::send_internal): Just use wmem size if
the length exceeds it.
* net.cc (fdsock): Use 65535 as window size, just like the comment says or we
run into problems with DuplicateHandle.
* path.cc (patch_conv::check): Use set_path to set invalid filename.
* path.h (path_conv::path_conv): Ditto.
2009-08-04 22:35:35 +00:00
Corinna Vinschen 58fc288ada * fhandler_socket.cc (fhandler_socket::recv_internal): Convert wsabuf
and wsacnt to references.  Fix handling of WSAEMSGSIZE.
2009-07-06 20:30:34 +00:00
Corinna Vinschen 975a630109 * fhandler.h (class fhandler_socket): Add class members and methods
to store and retrieve the SO_RCVBUF and SO_SNDBUF sizes.
	* fhandler_socket.cc (fhandler_socket::dup): Duplicate new members.
	(fhandler_socket::send_internal): Check for SO_SNDBUF size and
	restrict send to 1 byte less per KB 823764.  Leave loop immediately
	if WSASendMsg has been used.
	* net.cc (fdsock): Change comment again.  Set buffer sizes to 65536.
	Store values in fhandler_socket.
	(cygwin_setsockopt): Store SO_RCVBUF and SO_SNDBUF sizes in
	fhandler_socket.
	(cygwin_sendto): Drop call to sig_dispatch_pending.
	(cygwin_recvfrom): Ditto.
	(cygwin_recvmsg): Ditto.
	(cygwin_sendmsg): Ditto.
2009-07-01 09:16:17 +00:00
Corinna Vinschen 4a83803381 * net.cc (fdsock): Set default socket buffer sizes to 65520. Change
comment accordingly.
	* fhandler_socket.cc (fhandler_socket::send_internal): Set maximum
	send size to 65520 as well.
2009-06-30 10:36:40 +00:00
Corinna Vinschen 3477392bd7 * fhandler_socket.cc (fhandler_socket::recv_internal): Mark WSARecvMsg
as NO_COPY.
2009-06-17 08:23:17 +00:00
Corinna Vinschen 792c564b27 * fhandler_socket.cc (fhandler_socket::recv_internal): Set namelen
pointer to NULL if name pointer is NULL.  Explain why.
2009-06-13 16:13:01 +00:00
Corinna Vinschen 71d13bca55 * fhandler.h (fhandler_socket::wait_for_events): Take additional
parameter "dontwait".
	* fhandler_socket.cc (fhandler_socket::wait_for_events): Act as if the
	socket is non-blocking if dontwait is true.
	(fhandler_socket::recv_internal): Use incoming MSG_DONTWAIT flag to
	set the wait_for_events dontwait parameter.
	(fhandler_socket::send_internal): Ditto.  Optimize code slightly.
	* include/cygwin/socket.h (MSG_DONTWAIT): Define.
	* include/cygwin/version.h: Bump API minor number.
2009-03-09 14:40:45 +00:00