* 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.
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.
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.
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.
(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.
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.
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.
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.
(WSASendMsg): Define.
* fhandler.h (class fhandler_socket): Change definition of recv_internal
and send_internal to take WSAMSG pointer as parameter.
* fhandler_socket.cc (WSAID_WSARECVMSG): Define.
(LPFN_WSARECVMSG): Define.
(WSASendMsg): Declare.
(get_ext_funcptr): New function to fetch address of WSARecvMsg.
(fhandler_socket::recv_internal): Take just a LPWSAMSG parameter.
Change code accordingly. If control information is requested,
fetch address of WSARecvMsg and use that instead of WSARecvFrom.
(fhandler_socket::recvfrom): Change return type to ssize_t as
declared in fhandler.h. Accommodate changes to recv_internal.
(fhandler_socket::recvmsg): Ditto. Make sure that control information
is only requested if system, address family, and socket type support it.
(fhandler_socket::send_internal): Take just a LPWSAMSG parameter
and the flags. Change code accordingly. If control information is
provided, use WSASendMsg instead of WSASendTo.
(fhandler_socket::sendto): Drop useless comment. Accommodate changes
to send_internal.
(fhandler_socket::sendmsg): Ditto. Make sure that control information
is only provided if system, address family, and socket type support it.
* wincap.h (wincaps::has_recvmsg): New element.
(wincaps::has_sendmsg): New element
* wincap.cc: Implement above elements throughout.
* include/cygwin/socket.h (CMSG_ALIGN): Phrase in terms of alignment
of type struct cmsghdr.
* fhandler_fifo.cc (fhandler_fifo::open): Rework to cause errno to be set to
ENXIO when opening a fifo write/nonblocking.
* environ.cc (ucreqenv): Rename to ucenv. Move code from old ucenv here and
conditionalize it on create_upcaseenv.
(ucenv): Delete.
(environ_init): Fix compiler warning by moving create_upcaseenv test to ucenv.
Don't bother checking for child_proc_info when calling ucenv since it is
assumed to be NULL at the point where the function is called.
* path.cc (symlink_worker): Turn off MS-DOS path warnings when dealing with
devices since the device handler passes in a translated MS-DOS path.
* sec_auth.cc (lsaprivkeyauth): Avoid variable initialization which causes a
compiler error.
* fhandler_netdrive.cc: Update copyright.
* dtable.cc (handle_to_fn): Ditto.
* fhandler_console.cc (fhandler_console::read): Ditto.
(fhandler_console::scroll_screen): Ditto.
(dev_console::set_color): Ditto.
* fhandler_dsp.cc (fhandler_dev_dsp::write): Ditto.
(fhandler_dev_dsp::read): Ditto.
* fhandler_tape.cc (mtinfo_drive::get_status): Ditto.
* hookapi.cc (find_first_notloaded_dll): Ditto.
* mmap.cc (msync): Ditto.
* pipe.cc (pipesync::pipesync): Ditto.
* sec_acl.cc (getace): Ditto.
* sec_auth.cc (create_token): Ditto.
(lsaauth): Ditto.
* select.cc (peek_pipe): Ditto.
* spawn.cc (av::fixup): Ditto.
* syscalls.cc (popen): Ditto.
* tty.cc (tty::init_session): Ditto.
* uinfo.cc (pwdgrp::load): Ditto.
* fhandler.cc (fhandler_base::setup_overlapped): Ditto.
(fhandler_base::wait_overlapped): Rename second use of res variable to wres or
errors are not returned correctly.
* dcrt0.cc: Remove obsolete variable.
* dll_init.cc (release_upto): Fix typo involving incorrect use of '|'.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a compiler
warning regarding coercing type-punned variables.
(fhandler_base::fstat_by_name): Ditto. fhandler_fifo.cc
(fhandler_fifo::open_nonserver): Fix = vs. == typo.
(fhandler_fifo::wait): Add all conditions to switch statement to avoid a
compiler warning.
* fhandler_process.cc: Avoid unneeded initialization of variables to zero.
(fhandler_socket::listen): Add braces around initializer.
* flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a compiler
warning. Fix problem with EWOULDBLOCK error return.
* path.cc (GUID_shortcut): Use braces around struct initializer.
(cygwin_conv_path): Reorganize to avoid a compiler warning.
* random.cc (dummy): Mark variable as volatile to avoid a "used uninitialized"
warning.
* libc/getopt.c: Mark some variables as dllexport although gcc doesn't seem to
do the right thing with them.
* libc/minires-os-if.c (get_registry_dns_items): Coerce some function arguments
to avoid a compiler warning.
additional path_conv argument.
* fhandler.cc (fhandler_base::open): Ditto.
* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Never set DOS
R/O attribute when using ACLs.
(fhandler_disk_file::mkdir): Ditto. Set
security descriptor on remote dirs after creating the dir, same as in
fhandler_base::open.
* fhandler_socket.cc (fhandler_socket::bind): Ditto for remote AF_LOCAL
socket files.
* path.cc (symlink_worker): Ditto. for remote symlinks.
* security.cc (alloc_sd): Take additional path_conv argument.
Accommodate throughout. Drop setting FILE_WRITE_EA/FILE_READ_EA
flags unconditionally (was only necessary for "ntea"). Don't set
FILE_READ_ATTRIBUTES and FILE_WRITE_ATTRIBUTES unconditionally on
Samba. Add comment to explain. Drop useless setting of
STANDARD_RIGHTS_WRITE, it's in FILE_GENERIC_WRITE anyway.
Remove FILE_READ_ATTRIBUTES bit from FILE_GENERIC_EXECUTE so as not
to enforce read permissions on Samba.
(set_security_attribute): Take additional path_conv argument.
* security.h (set_security_attribute): Change prototype accordingly.
then 64K bytes at once. For blocking sockets, loop until entire data
has been sent or an error occurs.
(fhandler_socket::sendto): Drop code which sends on 64K bytes.
(fhandler_socket::sendmsg): Ditto.
* fhandler_socket.cc (address_in_use): Take const struct sockaddr
pointer as argument. Implement additional AF_INET6 table check.
(fhandler_socket::bind): Drop AF_INET test before calling
address_in_use.
* net.cc (ipv4_getnameinfo): Return EAI_FAMILY instead of 1 if
called with unsupported af_family.
local socket test in SO_REUSEADDR case on systems supporting
enhanced socket security. Explain why. Only call address_in_use
for AF_INET sockets.
* net.cc (cygwin_setsockopt): Don't call setsockopt to set SO_REUSEADDR
on systems supporting enhanced socket security. Add comment.
* wincap.h (wincaps::has_enhanced_socket_security): New element.
* wincap.cc: Implement above element throughout.
wsa_event.h instead.
* fhandler_socket.cc (NUM_SOCKS): Move to wsa_event.h.
(wsa_events): Move from DLL shared area to cygwin_shared shared
memory. Accommodate throughout.
(socket_serial_number): Ditto.
* fhandler_tape.cc (mt): Ditto.
(mtinfo_init): Remove.
(mt): Define as cygwin_shared->mt.
* flock.cc (FLOCK_PARENT_DIR_ACCESS): Remove.
(FLOCK_INODE_DIR_ACCESS): Move up in file.
(FLOCK_MUTANT_ACCESS): Ditto.
(FLOCK_EVENT_ACCESS): Ditto.
(get_lock_parent_dir): Remove.
(inode_t::inode_t): Call get_shared_parent_dir to get parent dir handle.
Add a "flock-" prefix to file's lock directory name for clarity.
* mtinfo.h (mtinfo_init): Drop declaration.
* net.cc (last_used_bindresvport): Move from DLL shared area to
cygwin_shared shared memory.
(cygwin_bindresvport_sa): Accommodate above change.
* sec_helper.cc (_everyone_sd): Move here from flock.cc.
* security.h (SD_MIN_SIZE): Ditto.
(everyone_sd): Ditto.
* shared.cc (cygwin_shared_area): Remove.
(cygwin_shared_h): New handle.
(get_shared_parent_dir): New static function.
(shared_name): Drop session_local argument. Call get_shared_parent_dir
here. Add cygwin-shared subdir to object name.
(offsets): Reinstantiate SH_CYGWIN_SHARED member.
(open_shared): Revert change from 2007-03-29 for systems supporting
SeCreateGlobalPrivilege.
(shared_info::initialize): Call mtinfo's initialize here.
(memory_init): Drop call to mtinfo_init.
* shared_info.h (SHARED_INFO_CB): Accommodate change to shared_info.
(CURR_SHARED_MAGIC): Ditto.
(class shared_info): Add members for global socket and tape info
sharing.
(enum shared_locations): Reinstantiate SH_CYGWIN_SHARED.
(get_shared_parent_dir): Declare.
(shared_name): Drop session_local argument from declaration.
* wsa_event.h: New file. Move definitions of NUM_SOCKS and
struct wsa_event here.
throughout for subkey name buffer size.
* fhandler_socket.cc (search_wsa_event_slot): Use MAX_PATH instead of
CYG_MAX_PATH for mutext name buffer size.
(fhandler_socket::init_events): Ditto.
* fhandler_virtual.cc (fhandler_virtual::opendir): Check path length
against PATH_MAX instead of against CYG_MAX_PATH.
* registry.cc (get_registry_hive_path): Use PATH_MAX instead of
CYG_MAX_PATH for registry value path buffer size.
* shared.cc (open_shared): Use MAX_PATH instead of CYG_MAX_PATH
for shared memory name buffer size.
* thread.cc (semaphore::semaphore): Use MAX_PATH instead of CYG_MAX_PATH
for semaphore name buffer size.
* uinfo.cc (cygheap_user::env_userprofile): Use PATH_MAX instead of
CYG_MAX_PATH for temporary path name buffer size.
* winf.h (LINE_BUF_CHUNK): Define as MAX_PATH * 2.
* include/sys/dirent.h: Include sys/limits.h. Define name buffer sizes
using NAME_MAX.
handling. Use explicit flag values instead of MSG_WINMASK.
(fhandler_socket::send_internal): Use explicit flag values instead of
MSG_WINMASK.
* include/cygwin/socket.h (MSG_WINMASK): Remove definition.
(MSG_WAITALL): Define.
too. Don't write to file and especially don't close handle if file
couldn't be created. Set delete disposition if writing failed,
instead of calling unlink_nt.
mode bit by setting the SYSTEM attribute.
* fhandler_socket.cc (fhandler_socket::fchmod): Add S_IFSOCK mode bit
when calling fhandler_disk_file::fchmod. Don't set attributes here.
* delqueue.cc: Delete.
* fhandler.h (fhandler_base::close_fs): Drop declaration.
(fhandler_disk_file::close): Drop declaration.
* fhandler_disk_file.cc (fhandler_base::fstat_fs): Call close instead of
close_fs.
(fhandler_base::fstat_helper): Use open FH_UNIX handle in call to
get_file_attribute.
(fhandler_base::open_fs): Call close instead of get_file_attribute.
(fhandler_disk_file::close): Remove.
(fhandler_base::close_fs): Remove.
* fhandler_socket.cc (fhandler_socket::close): Just call
fhandler_base::close for FH_UNIX sockets.
* shared.cc (user_shared_initialize): Drop call to
user_shared->delqueue.init.
* shared_info.h (CURR_USER_MAGIC): Change according to below change.
(MAX_DELQUEUES_PENDING): Remove.
(class delqueue_list): Remove.
(class user_info): Remove delqueue.
* syscalls.cc (close_all_files): Drop call to
user_shared->delqueue.process_queue.
(unlink): Drop delqueue handling.
* cygwin.din: Export freeifaddrs, getifaddrs.
* fhandler_socket.cc (fhandler_socket::ioctl): Drop SOCKET parameter
from get_ifconf.
* net.cc: Include ifaddrs.h.
(in_are_prefix_equal): Match addresses in network byte order.
(ip_addr_prefix): Convert address into host byte order before
testing with IN_LOOPBACK.
(struct ifall): Define.
(get_xp_ifs): Replace get_xp_ifconf. Return struct ifall array.
(get_2k_ifs): Ditto, replace get_2k_ifconf.
(get_nt_ifs): Ditto, replace get_nt_ifconf.
(getifaddrs): New function.
(freeifaddrs): New function.
(get_ifconf): Call matching get_XX_ifs function and create
ifc content from here. Drop lo fake since it's now in get_nt_ifs.
* posix.sgml: Add freeifaddrs and getifaddrs to list of implemented
BSD functions.
* wincap.h (wincapc::has_broken_if_oper_status): New element.
* wincap.cc: Implement above element throughout.
* include/ifaddrs.h: New file.
* include/cygwin/version.h: Bump API minor number.
case of query_open flag set to query_read_control. Add case for
new query_read_attributes flag.
(fhandler_base::fstatvfs): New method.
* fhandler.h (enum query_state): Add query_read_attributes flag.
(class fhandler_base): Declare new virtual fstatvfs method.
(class fhandler_socket): Ditto.
(class fhandler_pipe): Ditto.
(class fhandler_fifo): Ditto.
(class fhandler_disk_file): Ditto.
(class fhandler_virtual): Ditto.
* fhandler_disk_file.cc (fhandler_base::fstat_fs): Open with
query_read_attributes instead of query_read_control.
(fhandler_disk_file::fstatvfs): New method.
(fhandler_disk_file::facl): Open with query_read_attributes instead of
query_read_control.
* fhandler_fifo.cc (fhandler_fifo::fstatvfs): New method.
* fhandler_socket.cc (fhandler_socket::fstatvfs): New method.
(fhandler_socket::fchmod): Return with EBADF in the default case.
(fhandler_socket::fchown): Ditto.
(fhandler_socket::facl): Ditto.
* fhandler_virtual.cc (fhandler_virtual::fstatvfs): Ditto.
* ntdll.h (struct _FILE_FS_ATTRIBUTE_INFORMATION): Define.
(struct _FILE_FS_FULL_SIZE_INFORMATION): Define.
* pipe.cc (fhandler_pipe::fstatvfs): New method.
* syscalls.cc (fstatvfs): Just call the fhandler's fstatvfs.
(statvfs): Ditto.
(fstatfs): Call fstatvfs.
(statfs): Drop EFAULT handling.
(SendARP): Define.
* cygwin.din: Export if_freenameindex, if_indextoname, if_nameindex and
if_nametoindex.
* fhandler_procnet.cc: Drop including wchar.h. Drop definitions of
GAA_FLAG_INCLUDE_ALL_INTERFACES, IP_ADAPTER_UNICAST_ADDRESS_VISTA.
(fhandler_procnet::exists): Check for has_gaa_prefixes. Call
get_adapters_addresses here.
(fhandler_procnet::readdir): Ditto.
(prefix): Move to net.cc.
(fhandler_procnet::fill_filebuf): Call get_adapters_addresses here.
Simplify allocation. Use AdapterName rather than FriendlyName as
interface name. Use IfIndex if available, Ipv6IfIndex otherwise.
(in6_are_prefix_equal): Move to net.cc.
* fhandler_socket.cc: Define old SIOCGxxx values.
(CONV_OLD_TO_NEW_SIO): Convert old SIOCGxxx value to new one.
(struct __old_ifreq): Define old struct ifreq.
(fhandler_socket::ioctl): Handle old SIOCGxxx values. Handle new
SIOCGIFFRNDLYNAM command. Simplify copying ifreq data to user space.
Call get_ifconf with additional SOCKET parameter.
* net.cc (IP_ADAPTER_UNICAST_ADDRESS_LH): Define.
(IP_ADAPTER_ADDRESSES_LH): Define.
(SIO_GET_INTERFACE_LIST): Define.
(sockaddr_in6_old): Define.
(sockaddr_gen): Define.
(INTERFACE_INFO): Define.
(IN_LOOPBACK): Define.
(in_are_prefix_equal): New static function.
(ip_addr_prefix): New function, replaces prefix function, add AF_INET
handling.
(GAA_FLAG_INCLUDE_ALL_INTERFACES): Define.
(get_adapters_addresses): New function.
(WS_IFF_xxx): Define Winsock interface flag values.
(convert_ifr_flags): New function to convert Winsock interface flag
values to Cygwin interface flag values.
(get_xp_ifconf): New get_ifconf implementation for XP SP1 and above.
(get_2k_ifconf): Fix interface index. Fix formatting.
(get_nt_ifconf): Fix formatting.
(get_95_ifconf): Ditto.
(get_ifconf): Take additional SOCKET parameter. Call get_xp_ifconf
on XP SP1 and above.
(if_nametoindex): New function.
(if_indextoname): New function.
(if_nameindex): New function.
(if_freenameindex): New function.
(in6_are_prefix_equal): Moved here from fhandler_procnet.cc.
* wincap.cc (wincap_xp): Define has_gaa_prefixes as true by default.
(wincapc::init): Assume has_osversioninfoex by default. Call
GetVersionEx with OSVERSIONINFOEX first. Call with OSVERSIONINFO only
if that fails. Simplify NT4 case and try to avoid strcmp. Check XP
Service Pack using version.wServicePackMajor to avoid strcmp.
* include/asm/socket.h (SIOCGIFFRNDLYNAM): Define.
* include/cygwin/if.h: Fix formatting.
(IFF_POINTTOPOINT): Define.
(IFF_NOARP): Define.
(IFF_LOWER_UP): Define.
(IFF_DORMANT): Define.
(struct if_nameindex): Define.
(IFRF_FRIENDLYNAMESIZ): Define.
(struct ifreq_frndlyname): Define.
(IFNAMSIZ): Redefine as 44.
(IF_NAMESIZE): Define.
(struct ifreq): Redefine ifru_flags as int. Define ifru_data. Pad size
to sizeof sockaddr_in6 for further extensions.
(ifr_data): Define.
(ifr_frndlyname): Define.
(if_nametoindex): Declare.
(if_indextoname): Declare.
(if_nameindex): Declare.
(if_freenameindex): Declare.
* include/cygwin/version.h: Bump API minor number.
(CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ): Define check for old vs. new
ifreq structure.
* net.cc (get_2k_ifconf): Ditto.
(get_nt_ifconf): Fake SIOCGIFINDEX.
(get_95_ifconf): Ditto.
(get_ifconf): Handle SIOCGIFINDEX. Fake it for loopback on systems
not supporting IP Helper Lib.
* include/asm/socket.h (SIOCGIFINDEX): Define.
* include/cygwin/if.h (struct ifreq): Add member for interface index.
(ifr_ifindex): Define.
for SIOCGIFFLAGS here. Call get_ifconf instead.
* net.cc (get_2k_ifconf): Clean up code to generate interface name.
Handle SIOCGIFFLAGS here.
(get_nt_ifconf): Fake SIOCGIFFLAGS here.
(get_95_ifconf): Ditto.
(get_ifconf): Don't fake loopback on systems with IP Helper Lib.
Set MTU for loopback to a more "modern" value.
with poll(2) after shutdown(SHUT_RD) has been called on the local side.
* poll.cc (poll): Use POSIX type nfds_t for second parameter. Drop
special socket handling for POLLIN. Add comment to explain why.
* include/sys/poll.h: Declare nfds_t. Use as type for second parameter
in poll(2) declaration.
potential race condition.
(fhandler_socket::recv_internal): Fix MSG_PEEK bug on blocking sockets
and simplify recv loop.
(fhandler_socket::send_internal): Only lock when changing wsock_events.
(class fhandler_socket): Make wsock_evt private again.
(fhandler_socket::wsock_event): New read accessor for wsock_evt.
(fhandler_socket::serial_number): New read accessor to get the
socket's serial number.
(fhandler_socket::ready_for_read): Just return true.
* fhandler_socket.cc (struct wsa_event): Move definition to fhandler.h.
* select.cc (struct socketinf): Add serial number vector.
(start_thread_socket): Identify duplicate sockets by their serial
number, not (wrongly) by their wsock_evt.
conditions in evaluate_events.
(search_wsa_event_slot): Move wrongly placed memset in
fhandler_socket::init_events here.
(fhandler_socket::init_events): Initially set FD_WRITE event for
connectionless sockets.
* poll.cc (poll): Don't add sockets always to except_fds since select
is now supposed to do it right.
* select.cc (set_bits): Set connection state correctly for failed
af_local_connect on local sockets. Remove socket special handling
for except_selected descriptors.
(peek_socket): Try to set the read/write/exception bits actually
correctly.
(fhandler_socket::fixup_before_fork_exec): Remove.
(fhandler_socket::fixup_after_exec): Remove.
(fhandler_socket::need_fixup_before): Remove.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Drop
initializing prot_info_ptr. Remove unused code.
(fhandler_socket::~fhandler_socket): Drop free'ing prot_info_ptr.
(struct wsa_event): Rename connect_errorcode to errorcode.
(fhandler_socket::evaluate_events): Handle FD_CLOSE error condition
as FD_CONNECT error condition, except, never reset an FD_CLOSE error
condition. Always set FD_WRITE after successfully recorded FD_CONNECT.
(fhandler_socket::fixup_before_fork_exec): Remove.
(fhandler_socket::fixup_after_fork): Revert to using handle duplication.
(fhandler_socket::fixup_after_exec): Remove.
(fhandler_socket::dup): Revert to using handle duplication.
(fhandler_socket::send_internal): Only call wait_for_events in case
of WSAEWOULDBLOCK condition.
(fhandler_socket::set_close_on_exec): Call
fhandler_base::set_close_on_exec.
* net.cc (fdsock): Just set socket to inheritable on non-NT. Don't
call inc_need_fixup_before.
* select.cc (peek_socket): Don't set except_ready on every FD_CLOSE,
just on error.
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
accept and connect back to using select:
* fhandler.h (class fhandler_socket): Remove accept_mtx.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Drop
initializing accept_mtx.
(fhandler_socket::accept): Drop event handling.
(fhandler_socket.cc (fhandler_socket::connect): Ditto.
(fhandler_socket::dup): Drop accept_mtx handling.
(fhandler_socket::listen): Ditto.
(fhandler_socket::prepare): Ditto.
(fhandler_socket::release): Ditto.
(fhandler_socket::close): Ditto.
* net.cc (cygwin_accept): Revert to calling cygwin_select to
implement interuptible accept.
(cygwin_connect): Ditto for connect.
accept_mtx.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize
accept_mtx to NULL.
(fhandler_socket::dup): Duplicate accept_mtx, if available.
(fhandler_socket::listen): Create accept_mtx before trying to listen.
(fhandler_socket::prepare): Wait for accept_mtx if available to
serialize accepts on the same socket.
(fhandler_socket::release): Release accept_mtx.
(fhandler_socket::close): Close accept_mtx on successful closesocket.
* fhandler_socket.cc (address_in_use): New function to check if
sockaddr_in address is already in use.
(fhandler_socket::bind): Check if address is alreay in use in case of
SO_REUSEADDR, to circumvent WinSock non-standard behaviour.
* fhandler_socket.cc (fhandler_socket::bind): Set socket to
SO_EXCLUSIVEADDRUSE if application didn't explicitely set SO_REUSEADDR
socket option, on systems supporting SO_EXCLUSIVEADDRUSE.
* net.cc (cygwin_setsockopt): Set fhandler's saw_reuseaddr status flag
if SO_REUSEADDR socket option has been successsfully set.
* wincap.h (wincaps::has_exclusiveaddruse): New element.
* wincap.cc: Implement above element throughout.
(fhandler_socket::release): Add debug output for WSAEventSelect failure.
(fhandler_socket::ioctl): Always cancel WSAEventSelect before switching
to blocking mode. Only set nonblocking flag if ioctlsocket call
succeeded. Only print new socket state if ioctlsocket call succeeded.
(init_cygheap::console_count): Renamed from open_fhs. Make private.
* cygheap.cc (init_cygheap::manage_console_count): Define new function.
* dtable.cc (dtable::fixup_after_exec): Always call fixup_after_exec on
elements of fd even when they are about to be closed.
* fhandler.h (report_tty_counts): Remove open_fhs from debugging output.
* fhandler_console.cc (fhandler_console::open): Use manage_console_count rather
than manipulating count directly.
(fhandler_console::close): Ditto.
(fhandler_console::fixup_after_fork): Ditto.
(fhandler_console::fixup_after_exec): Ditto. Don't close handles if
close_on_exec.
* fhandler_tty.cc (fhandler_tty_slave::open): Use manage_console_count() rather
than manipulating count directly. Reflect change in arguments to
report_tty_counts().
(fhandler_tty_slave::close): Ditto for both.
(fhandler_tty_slave::dup): Ditto for both.
(fhandler_tty_slave::ioctl): Use myctty() rather than raw ctty #.
(fhandler_tty_slave::fixup_after_fork): Reflect change in arguments to
report_tty_counts().
(fhandler_tty_master::init_console): Use manage_console_count() rather than
manipulating count directly.
* fhandler_clipboard.cc (fhandler_dev_clipboard::fixup_after_exec): Don't
perform any operations if close_on_exec.
* fhandler_dsp.cc (fhandler_dev_dsp::fixup_after_exec): Ditto.
* fhandler_raw.cc (fhandler_dev_raw::fixup_after_exec): Ditto.
* fhandler_serial.cc (fhandler_serial::fixup_after_exec): Ditto.
* pinfo.h (_pinfo::_ctty): Declare new function.
(myctty): Declare new macro.
(__ctty): Declare new macro.
* pinfo.cc (_pinfo::_ctty): Define new function.
(_pinfo::set_ctty): Use manage_console_count() rather than manipulating count
directly.
* signal.cc (kill_pgrp): Use myctty() and __ctty() macros rather than raw ctty
#.
* syscalls.cc (setsid): Ditto. Use manage_console_count() rather than
manipulating count directly.
from ws2_32. Rearrange symbol order accordingly. None of the ws2_32
functions is optional right now.
(wsadata): Move from net.cc here. Define NO_COPY.
(wsock_init): Drop unused symbols ws2_32_handle and wsock32_handle.
(load_wsock32): Remove.
(WSACleanup): Remove.
* fhandler_socket.cc: Drop Winsock 1 accommodations throughout.
(fhandler_socket::readv): Accomodate new POSIX style struct msghdr.
(fhandler_socket::writev): Ditto.
(fhandler_socket::recvmsg): Ditto. Handle "old" applications using
former struct msghdr correctly.
* net.cc: Drop Winsock 1 accommodations throughout.
(wsadata): Move definition to autoload.cc.
(set_socket_inheritance): Remove.
(convert_ws1_ip_optname): New static function to convert Winsock1
IPPROTO_IP option values into Winsock2 IPPROTO_IP option values.
(cygwin_setsockopt): Remove wrong and incomplete cleartext printing
of optname. For "old" applications, convert optname from Winsock1
to Winsock2 values before using them. Add comment to describe the
IP_TOS weirdness on W2K and above.
(cygwin_getsockopt): Remove wrong and incomplete cleartext printing
of optname. For "old" applications, convert optname from Winsock1
to Winsock2 values before using them.
* select.cc (start_thread_socket): Forget about winsock2_active.
* winsup.h (wsock32_handle): Remove declaration.
(ws2_32_handle): Ditto.
(netapi32_handle): Ditto.
(wsadata): Ditto.
(winsock2_active): Remove definition.
* include/cygwin/socket.h: Change formatting slightly.
(socklen_t): Move definition up in file.
(struct msghdr): Convert to POSIX style.
(struct cmsghdr): New type.
(CMSG_ALIGN): New macro.
(CMSG_LEN): Ditto.
(CMSG_SPACE): Ditto.
(CMSG_FIRSTHDR): Ditto.
(CMSG_NXTHDR): Ditto.
(CMSG_DATA): Ditto.
(SCM_RIGHTS): Ditto.
(struct OLD_msghdr): Define old msghdr structure for Cygwin internal
purposes.
(MSG_TRUNC): New macro.
(MSG_CTRUNC): Ditto.
(IP_OPTIONS): Redefine IPPROTO_IP option values to Winsock2 values.
Keep Winsock1 values for Cygwin internal purposes.
* include/cygwin/version.h: Bump API minor version.
(CYGWIN_VERSION_CHECK_FOR_USING_ANCIENT_MSGHDR): Define to check for
applications using old struct msghdr.
(CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES): Define to check for
applications using old Winsock1 IPPROTO_IP values.
eof_detected status flag. Delete is_eom and is_eof methods.
Move drive_size, bytes_per_sector, eom_detected status flag, as well
as the methods read_file, write_file, raw_read and raw_write to ...
(class fhandler_dev_floppy): ... here. Remove is_eom and is_eof
methods. Add dup method.
* fhandler_floppy.cc (IS_EOM): New macro.
(fhandler_dev_floppy::is_eom): Remove.
(fhandler_dev_floppy::is_eof): Remove.
(fhandler_dev_floppy::fhandler_dev_floppy): Initialize status flags.
(fhandler_dev_floppy::get_drive_info): Only call EX functions on
systems supporting them and stop suffering strange delays.
(fhandler_dev_floppy::read_file): Move here, drop setting
current_position.
(fhandler_dev_floppy::write_file): Move here, drop setting
current_position.
(fhandler_dev_floppy::open): Rearrange comment.
(fhandler_dev_floppy::dup): New method.
(fhandler_dev_floppy::get_current_position): New inline method. Use
instead of former current_position were appropriate.
(fhandler_dev_floppy::raw_read): Move here. Drop EOF handling.
(fhandler_dev_floppy::raw_write): Move here. Drop EOF handling.
(fhandler_dev_floppy::lseek): Remove useless conditions. Convert
sector_aligned_offset to LARGE_INTEGER to improve SetFilePointer call.
(fhandler_dev_floppy::ioctl): Move blocksize check in RDSETBLK case
to here.
* fhandler_raw.cc (fhandler_dev_raw::is_eom): Remove.
(fhandler_dev_raw::is_eof): Remove.
(fhandler_dev_raw::write_file): Remove.
(fhandler_dev_raw::read_file): Remove.
(fhandler_dev_raw::raw_read): Remove.
(fhandler_dev_raw::raw_write): Remove.
(fhandler_dev_raw::dup): Drop copying removed members.
(fhandler_dev_raw::ioctl): Drop blocksize testing.
* wincap.h: Implement has_disk_ex_ioctls throughout.
* wincap.cc: Ditto.
(wincap_vista): Preliminary wincaps for Windows Vista/Longhorn.
(wincapc::init): Add Vista/Longhorn handling.
everywhere. Leave some thread.cc stuff alone for now.
* cygtls.h: Kludge some definitions to avoid including a problematic windows
header.
(_cygtls::_myfault): New entry.
(_cygtls::_myfault_errno): Ditto.
(_cygtls::fault_guarded): New function.
(_cygtls::setup_fault): Ditto.
(_cygtls::return_from_fault): Ditto.
(_cygtls::clear_fault): Ditto.
(myfault): New class.
* exceptions.cc (handle_exceptions): Handle case of guarded fault in system
routine.
* gendef: Add another entry point for setjmp that the compiler doesn't know
about and won't complain about.
* gentls_offsets: Just include windows.h rather than kludging a HANDLE def.
* miscfuncs.cc (check_null_str): Delete.
(check_null_empty_str): Ditto.
(check_null_empty_str_errno): Ditto.
(check_null_str_errno): Ditto.
(__check_null_invalid_struct): Ditto.
(__check_null_invalid_struct_errno): Ditto.
(__check_invalid_read_ptr): Ditto.
(__check_invalid_read_ptr_errno): Ditto.
(dummytest): New function.
(check_iovec_for_read): Delete.
(chec_iovec): Rename from check_iovec_for_write. Take a read/write parameter.
* tlsoffsets.h: Regenerate.
* winsup.h: Remove check_* declarations.
(check_iovec_for_read): Delete declaration. Turn into a define instead.
(check_iovec_for_write): Ditto.
(check_iovec): New declaration.
* thread.h: Use ifdef guard name consistent with other header files.
* fhandler_socket.cc (fhandler_socket::connect): Set connect_state to
connect_failed when connect failed.
* poll.cc (poll): Change errno to EINVAL if allocating memory fails,
according to SUSv3. Add socket descriptors always to except_fds. Test
for failed connect and set revents flags appropriately.
* select.cc (set_bits): Set connect_state to connect_failed when
select indicates failed nonblocking connect.
(fhandler_dev_null::select_except): Set except_ready to false so that
/dev/null is not always in except state.
(peek_socket): Fix bogus conditional.
(fhandler_socket::select_write): Treat all connect_states except
unconnected equivalent to return consistent results.
(fhandler_windows::select_except): Set except_ready to false so that
/dev/windows is not always in except state.
unix socket type. Read socket type from unix socket file.
(fhandler_socket::bind): Write socket type to unix socket file.
(fhandler_socket::connect): Return with errno EPROTOTYPE if
socket type of socket doesn't match socket type of unix socket
trying to connect to.
(fhandler_socket::af_local_set_secret): New function combining former
set_connect_secret and get_connect_secret into one function.
(fhandler_socket::af_local_setblocking): Rename from eid_setblocking.
(fhandler_socket::af_local_unsetblocking): Rename from
eid_unsetblocking.
(fhandler_socket::af_local_set_cred): New method.
(fhandler_socket::af_local_copy): New method.
(fhandler_socket::af_local_recv_secret): New method.
(fhandler_socket::af_local_send_secret): New method.
(fhandler_socket::af_local_recv_cred): Rename from eid_recv.
(fhandler_socket::af_local_send_cred): Rename from eid_send.
(fhandler_socket::af_local_accept): New method.
(fhandler_socket::af_local_set_sockpair_cred): Rename from
set_socketpair_eids.
(fhandler_socket::eid_accept): Remove.
(fhandler_socket::eid_connect): Remove.
(fhandler_socket::set_connect_secret): Remove.
(fhandler_socket::get_connect_secret): Remove.
(fhandler_socket::create_secret_event): Remove.
(fhandler_socket::check_peer_secret_event): Remove.
(fhandler_socket::signal_secret_event): Remove.
(fhandler_socket::close_secret_event): Remove.
(fhandler_socket::sec_event_accept): Remove.
(fhandler_socket::sec_event_connect): Remove.
* fhandler_socket.cc (secret_event_name): Remove.
(fhandler_socket::af_local_set_sockpair_cred): Rename from
set_socketpair_eids.
(fhandler_socket::af_local_setblocking): Rename from eid_setblocking.
(fhandler_socket::af_local_unsetblocking): Rename from
eid_unsetblocking.
(fhandler_socket::af_local_recv_secret): New function to receive
AF_LOCAL connect secret over socket itself.
(fhandler_socket::af_local_send_secret): New function to send AF_LOCAL
connect secret over socket itself.
(fhandler_socket::af_local_recv_cred): Rename from eid_recv.
(fhandler_socket::af_local_send_cred): Rename from eid_send.
(fhandler_socket::eid_connect): Remove.
(fhandler_socket::af_local_connect): Take over connect side handling
of AF_LOCAL secret and credential handshake.
(fhandler_socket::eid_accept): Remove.
(fhandler_socket::af_local_accept): New method, take over accept side
handling of AF_LOCAL secret and credential handshake.
(fhandler_socket::af_local_set_cred): New method, set eid credentials
to start values.
(fhandler_socket::af_local_copy): New method, copy secret and
credentials to another socket.
(fhandler_socket::af_local_set_secret): New function combining former
set_connect_secret and get_connect_secret into one function.
(fhandler_socket::create_secret_event): Remove.
(fhandler_socket::signal_secret_event): Remove.
(fhandler_socket::close_secret_event): Remove.
(fhandler_socket::check_peer_secret_event): Remove.
(fhandler_socket::sec_event_connect): Remove.
(fhandler_socket::sec_event_accept): Remove.
(fhandler_socket::fixup_after_fork): Drop secret_event handling.
(fhandler_socket::bind): Call af_local_set_secret.
(fhandler_socket::connect): Call af_local_set_cred and af_local_connect.
(fhandler_socket::listen): Call af_local_set_cred.
(fhandler_socket::accept): Call af_local_copy and af_local_accept on
accepted socket.
(fhandler_socket::close): Don't call close_secret_event.
(fhandler_socket::set_close_on_exec): Don't set secret_event
inheritance.
* net.cc (cygwin_getsockopt): Add debug output.
(socketpair): Call af_local_set_sockpair_cred instead of
set_socketpair_eids.
* select.cc (set_bits): Drop AF_LOCAL special handling in case
of except bit set.
(fhandler_socket::set_connect_secret): Ditto.
(fhandler_socket::get_connect_secret): Ditto.
(fhandler_socket::create_secret_event): Ditto. Remove secret argument.
(fhandler_socket::check_peer_secret_event): Ditto.
(fhandler_socket::signal_secret_event): Make private.
(fhandler_socket::close_secret_event): Ditto.
(fhandler_socket::sec_event_accept): New private method.
(fhandler_socket::sec_event_connect): Ditto.
(fhandler_socket::af_local_connect): New public method.
* fhandler_socket.cc: Use 'struct sockaddr' and 'struct sockaddr_in'
rather than just 'sockaddr' and 'sockaddr_in' throughout.
(fhandler_socket::eid_connect): Drop AF_LOCAL/SOCK_STREAM test.
(fhandler_socket::create_secret_event): Remove secret argument.
Always use connect_secret instead.
(fhandler_socket::check_peer_secret_event): Ditto.
(fhandler_socket::sec_event_connect): New method, combining entire
secret event handshake on connect side.
(fhandler_socket::af_local_connect): New method, combining secret
event handshake and eid credential transaction on connect side, to
be called from select.
(fhandler_socket::sec_event_accept): New method, combining entire
secret event handshake on accept side.
(fhandler_socket::connect): Drop secret, use connect_secret instead.
Move entire secret event handshake to sec_event_connect.
(fhandler_socket::accept): Move entire secret event handshake to
sec_event_accept.
* select.cc (set_bits): Just call af_local_connect here.
(fhandler_socket::sec_pipe): Remove.
(fhandler_socket::eid_pipe_name): Remove.
(fhandler_socket::eid_setblocking): New private method.
(fhandler_socket::eid_unsetblocking): Ditto
(fhandler_socket::eid_recv): Ditto
(fhandler_socket::eid_send): Ditto
(fhandler_socket::eid_accept): Ditto
(fhandler_socket::eid_connect): New public method.
* fhandler_socket.cc (ASYNC_MASK): Move to beginning of file.
(fhandler_socket::eid_pipe_name): Remove.
(fhandler_socket::set_socketpair_eids): Move down to fhandler_socket
methods.
(fhandler_socket::fhandler_socket): Drop initializing sec_pipe.
(fhandler_socket::~fhandler_socket): Drop closing sec_pipe.
(fhandler_socket::eid_setblocking): New method.
(fhandler_socket::eid_unsetblocking): New method.
(fhandler_socket::eid_recv): New method.
(fhandler_socket::eid_send): New method.
(fhandler_socket::eid_connect): New method.
(fhandler_socket::eid_accept): New method.
(fhandler_socket::dup): Drop sec_pipe handling.
(fhandler_socket::connect): Fix WinSock error handling. Prepare
eid credential transaction. Call eid_connect on successful connect.
(fhandler_socket::listen): Drop creating sec_pipe.
(fhandler_socket::accept): Slightly simplify code. Call eid_accept
on accepted socket.
(fhandler_socket::getpeereid): Reshuffle code for readability. Fix
test for invalid pid.
* select.cc (set_bits): Call eid_connect on successfully connected
socket.
in case of a successful or pending connect.
(fhandler_socket::accept): Don't run secret event and eid credential
transactions if OS accept returned WSAEWOULDBLOCK.
string.
(fhandler_socket::connect): Set sun_path before running eid credential
transaction. Run transaction only if OS connect was successful.
(fhandler_socket::accept): Run transaction only if OS accept was
successful.