libc/winsup/cygwin/fhandler_socket.cc

1721 lines
43 KiB
C++
Raw Normal View History

/* fhandler_socket.cc. See fhandler.h for a description of the fhandler classes.
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc.
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
/* #define DEBUG_NEST_ON 1 */
#define __INSIDE_CYGWIN_NET__
#include "winsup.h"
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/uio.h>
#include <asm/byteorder.h>
#include <stdlib.h>
#define USE_SYS_TYPES_FD_SET
#include <winsock2.h>
#include <iphlpapi.h>
#include "cygerrno.h"
#include "security.h"
#include "cygwin/version.h"
#include "perprocess.h"
Add "path.h" include throughout, where needed. Use new path_conv methods and operators to simplify testing for directory and attributes, throughout. * path.h (path_conv::exists): New method. (path_conv::has_attribute): Ditto. (path_conv::isdir): Ditto. (path_conv::DWORD &): New operator. (path_conv::int &): Ditto. * dir.cc (rmdir): Eliminate a goto. * dtable.cc (dtable::build_fhandler): Accept opt and suffix info for path_conv.check. Return fh == NULL on path_conv error. Pass unit to set_name as appropriate. (dtable::reset_unix_path_name): New method. * dtable.h (dtable): Declare new method. Reflect arg changes to build_fhandler. * fhandler.cc (fhandler_disk_dummy_name): Eliminate. (fhandler_base::set_name): Expect paths to be NULL. Build unix_path_name from win32_path_name when it is a device. (fhandler_base::reset_unix_path_name): New method. (fhandler_base::raw_read): Report EISDIR when ERROR_INVALID_FUNCTION or ERROR_INVALID_PARAMETER and reading a directory. (fhandler_disk_file::fstat): Don't call stat_dev since we should now never be calling fhandler_disk_file methods with devices. (fhandler_base::fhandler_base): Clear {unix,win32}_path_name. (fhandler_base::~fhandler_base): Always free {unix,win32}_path_name. (fhandler_disk_file::fhandler_disk_file): Remove set_no_free_names kludge. (fhandler_disk_file::open): Ditto. * fhandler.h (fhandler_base::no_free_names): Eliminate. (fhandler_base::set_no_free_names): Ditto. * fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Don't set unix_path_name here. * path.cc (fchdir): Lock fd table throughout. Use new dtable::reset_unix_path_name method to reset path. * syscalls.cc (stat_worker): Reorganize to always call fstat method. Pass path_conv method to fhandler_*::open. (chroot): Elminate a goto.
2001-10-01 06:10:07 +02:00
#include "path.h"
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
#include "fhandler.h"
#include "dtable.h"
#include "cygheap.h"
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
#include "shared_info.h"
#include "sigproc.h"
#include "cygthread.h"
#include "wininfo.h"
#include <unistd.h>
#include <sys/acl.h>
#include <sys/statvfs.h>
#include "cygtls.h"
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
#include "cygwin/in6.h"
#define ASYNC_MASK (FD_READ|FD_WRITE|FD_OOB|FD_ACCEPT|FD_CONNECT)
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
#define EVENT_MASK (FD_READ|FD_WRITE|FD_OOB|FD_ACCEPT|FD_CONNECT|FD_CLOSE)
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
extern bool fdsock (cygheap_fdmanip& fd, const device *, SOCKET soc);
extern "C" {
int sscanf (const char *, const char *, ...);
} /* End of "C" section */
fhandler_dev_random* entropy_source;
static inline mode_t
adjust_socket_file_mode (mode_t mode)
{
/* Kludge: Don't allow to remove read bit on socket files for
user/group/other, if the accompanying write bit is set. It would
be nice to have exact permissions on a socket file, but it's
necessary that somebody able to access the socket can always read
the contents of the socket file to avoid spurious "permission
denied" messages. */
return mode | ((mode & (S_IWUSR | S_IWGRP | S_IWOTH)) << 1);
}
/* cygwin internal: map sockaddr into internet domain address */
static int
get_inet_addr (const struct sockaddr *in, int inlen,
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
struct sockaddr_storage *out, int *outlen,
int *type = NULL, int *secret = NULL)
{
int secret_buf [4];
int* secret_ptr = (secret ? : secret_buf);
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
if (in->sa_family == AF_INET || in->sa_family == AF_INET6)
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
memcpy (out, in, inlen);
*outlen = inlen;
return 1;
}
else if (in->sa_family == AF_LOCAL)
{
path_conv pc (in->sa_data, PC_SYM_FOLLOW);
if (pc.error)
2003-03-09 21:31:07 +01:00
{
set_errno (pc.error);
return 0;
}
if (!pc.exists ())
2003-03-09 21:31:07 +01:00
{
set_errno (ENOENT);
return 0;
}
if (!pc.issocket ())
2003-03-09 21:31:07 +01:00
{
set_errno (EBADF);
return 0;
}
HANDLE fh = CreateFile (pc, GENERIC_READ, FILE_SHARE_VALID_FLAGS,
&sec_none, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
0);
if (fh == INVALID_HANDLE_VALUE)
2003-03-09 21:31:07 +01:00
{
__seterrno ();
return 0;
}
int ret = 0;
DWORD len = 0;
char buf[128];
memset (buf, 0, sizeof buf);
if (ReadFile (fh, buf, 128, &len, 0))
2003-03-09 21:31:07 +01:00
{
* fhandler.h (fhandler_socket::eid_connect): Make private. (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.
2005-03-23 18:27:18 +01:00
struct sockaddr_in sin;
char ctype;
2002-09-30 17:17:44 +02:00
sin.sin_family = AF_INET;
sscanf (buf + strlen (SOCKET_COOKIE), "%hu %c %08x-%08x-%08x-%08x",
2002-09-30 17:17:44 +02:00
&sin.sin_port,
&ctype,
2002-09-30 17:17:44 +02:00
secret_ptr, secret_ptr + 1, secret_ptr + 2, secret_ptr + 3);
sin.sin_port = htons (sin.sin_port);
sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
memcpy (out, &sin, sizeof sin);
2002-09-30 17:17:44 +02:00
*outlen = sizeof sin;
if (type)
*type = (ctype == 's' ? SOCK_STREAM :
2005-05-02 05:50:11 +02:00
ctype == 'd' ? SOCK_DGRAM
: 0);
2002-09-30 17:17:44 +02:00
ret = 1;
}
else
2005-08-12 04:39:13 +02:00
__seterrno ();
CloseHandle (fh);
return ret;
}
else
{
set_errno (EAFNOSUPPORT);
return 0;
}
}
/**********************************************************************/
/* fhandler_socket */
fhandler_socket::fhandler_socket () :
fhandler_base (),
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
wsock_events (NULL),
wsock_mtx (NULL),
wsock_evt (NULL),
sun_path (NULL),
status ()
{
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
need_fork_fixup (true);
}
fhandler_socket::~fhandler_socket ()
{
if (sun_path)
cfree (sun_path);
}
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
char *
fhandler_socket::get_proc_fd_name (char *buf)
{
__small_sprintf (buf, "socket:[%d]", get_socket ());
return buf;
}
int
fhandler_socket::open (int flags, mode_t mode)
{
set_errno (ENXIO);
return 0;
}
void
fhandler_socket::af_local_set_sockpair_cred ()
{
sec_pid = sec_peer_pid = getpid ();
sec_uid = sec_peer_uid = geteuid32 ();
sec_gid = sec_peer_gid = getegid32 ();
}
void
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
fhandler_socket::af_local_setblocking (bool &async, bool &nonblocking)
{
async = async_io ();
nonblocking = is_nonblocking ();
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
if (async)
{
WSAAsyncSelect (get_socket (), winmsg, 0, 0);
WSAEventSelect (get_socket (), wsock_evt, EVENT_MASK);
}
set_nonblocking (false);
async_io (false);
}
void
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
fhandler_socket::af_local_unsetblocking (bool async, bool nonblocking)
{
if (nonblocking)
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
set_nonblocking (true);
if (async)
{
WSAAsyncSelect (get_socket (), winmsg, WM_ASYNCIO, ASYNC_MASK);
async_io (true);
}
}
bool
fhandler_socket::af_local_recv_secret ()
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
{
int out[4] = { 0, 0, 0, 0 };
int rest = sizeof out;
char *ptr = (char *) out;
while (rest > 0)
{
int ret = recvfrom (ptr, rest, 0, NULL, NULL);
if (ret <= 0)
break;
rest -= ret;
ptr += ret;
}
if (rest == 0)
{
debug_printf ("Received af_local secret: %08x-%08x-%08x-%08x",
out[0], out[1], out[2], out[3]);
if (out[0] != connect_secret[0] || out[1] != connect_secret[1]
2005-05-02 05:50:11 +02:00
|| out[2] != connect_secret[2] || out[3] != connect_secret[3])
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
{
debug_printf ("Receiving af_local secret mismatch");
return false;
}
}
else
debug_printf ("Receiving af_local secret failed");
return rest == 0;
}
bool
fhandler_socket::af_local_send_secret ()
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
{
int rest = sizeof connect_secret;
char *ptr = (char *) connect_secret;
while (rest > 0)
{
int ret = sendto (ptr, rest, 0, NULL, 0);
if (ret <= 0)
break;
rest -= ret;
ptr += ret;
}
debug_printf ("Sending af_local secret %s", rest == 0 ? "succeeded"
: "failed");
return rest == 0;
}
bool
fhandler_socket::af_local_recv_cred ()
{
struct ucred out = { (pid_t) 0, (__uid32_t) -1, (__gid32_t) -1 };
int rest = sizeof out;
char *ptr = (char *) &out;
while (rest > 0)
{
int ret = recvfrom (ptr, rest, 0, NULL, NULL);
if (ret <= 0)
break;
rest -= ret;
ptr += ret;
}
if (rest == 0)
{
debug_printf ("Received eid credentials: pid: %d, uid: %d, gid: %d",
out.pid, out.uid, out.gid);
sec_peer_pid = out.pid;
sec_peer_uid = out.uid;
sec_peer_gid = out.gid;
}
else
debug_printf ("Receiving eid credentials failed");
return rest == 0;
}
bool
fhandler_socket::af_local_send_cred ()
{
struct ucred in = { sec_pid, sec_uid, sec_gid };
int rest = sizeof in;
char *ptr = (char *) &in;
while (rest > 0)
{
int ret = sendto (ptr, rest, 0, NULL, 0);
if (ret <= 0)
break;
rest -= ret;
ptr += ret;
}
if (rest == 0)
debug_printf ("Sending eid credentials succeeded");
else
debug_printf ("Sending eid credentials failed");
return rest == 0;
}
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
int
fhandler_socket::af_local_connect ()
{
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
/* This keeps the test out of select. */
if (get_addr_family () != AF_LOCAL || get_socket_type () != SOCK_STREAM)
return 0;
debug_printf ("af_local_connect called");
bool orig_async_io, orig_is_nonblocking;
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
af_local_setblocking (orig_async_io, orig_is_nonblocking);
if (!af_local_send_secret () || !af_local_recv_secret ()
|| !af_local_send_cred () || !af_local_recv_cred ())
{
debug_printf ("accept from unauthorized server");
::shutdown (get_socket (), SD_BOTH);
WSASetLastError (WSAECONNREFUSED);
return -1;
}
af_local_unsetblocking (orig_async_io, orig_is_nonblocking);
return 0;
}
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
int
fhandler_socket::af_local_accept ()
{
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
debug_printf ("af_local_accept called");
bool orig_async_io, orig_is_nonblocking;
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
af_local_setblocking (orig_async_io, orig_is_nonblocking);
if (!af_local_recv_secret () || !af_local_send_secret ()
|| !af_local_recv_cred () || !af_local_send_cred ())
{
debug_printf ("connect from unauthorized client");
::shutdown (get_socket (), SD_BOTH);
::closesocket (get_socket ());
WSASetLastError (WSAECONNABORTED);
return -1;
}
af_local_unsetblocking (orig_async_io, orig_is_nonblocking);
return 0;
}
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
void
fhandler_socket::af_local_set_cred ()
* cygheap.h (class cygheap_fdenum): New class to enumerate used fhandlers. * dtable.h (class dtable): Add cygheap_fdenum as friend class. * fhandler.h (fhandler_base::get_proc_fd_name): New virtual method to return a name for /proc/<pid>/fd. (fhandler_socket::get_proc_fd_name): Ditto. (fhandler_pipe::get_proc_fd_name): Ditto. (fhandler_virtual::opendir): Make virtual method. (fhandler_process::opendir): New method. * fhandler.cc (fhandler_base::get_proc_fd_name): New method. * fhandler_process.cc: Include ctype.h. (PROCESS_FD): Define. (process_listing): Add "fd". (fhandler_process::exists): Fix comment. Return 1 in case of "fd" directory. Handle files below "fd". (fhandler_process::fstat): Drop "self" handling. Set correct link count for directories. (fhandler_process::opendir): New method to handle "fd" directory. (fhandler_process::readdir): Add "fd" handling. (fhandler_process::open): Drop "self" handling. (fhandler_process::fill_filebuf): Ditto. Add "fd" handling. Fix "maps" output string. * fhandler_registry.cc (fhandler_registry::fstat): Set correct link count for directories. * fhandler_socket.cc (fhandler_socket::get_proc_fd_name): New method. * path.cc (symlink_info::set): Fix thinko. * pinfo.cc (_pinfo::commune_recv): Rename pathbuf to path throughout. Drop local path variable in PICOM_FIFO case. Fix debug output. Close handles as early as possible. Add PICOM_FDS and PICOM_FD handling. (_pinfo::commune_send): Add PICOM_FDS and PICOM_FD handling. (_pinfo::fd): New method. (_pinfo::fds): New method. * pinfo.h (enum picom): Add PICOM_FDS and PICOM_FD. (_pinfo::fd): Declare. (_pinfo::fds): Declare. * pipe.cc (fhandler_pipe::get_proc_fd_name): New method.
2005-01-31 11:28:55 +01:00
{
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
sec_pid = getpid ();
sec_uid = geteuid32 ();
sec_gid = getegid32 ();
sec_peer_pid = (pid_t) 0;
sec_peer_uid = (__uid32_t) -1;
sec_peer_gid = (__gid32_t) -1;
* cygheap.h (class cygheap_fdenum): New class to enumerate used fhandlers. * dtable.h (class dtable): Add cygheap_fdenum as friend class. * fhandler.h (fhandler_base::get_proc_fd_name): New virtual method to return a name for /proc/<pid>/fd. (fhandler_socket::get_proc_fd_name): Ditto. (fhandler_pipe::get_proc_fd_name): Ditto. (fhandler_virtual::opendir): Make virtual method. (fhandler_process::opendir): New method. * fhandler.cc (fhandler_base::get_proc_fd_name): New method. * fhandler_process.cc: Include ctype.h. (PROCESS_FD): Define. (process_listing): Add "fd". (fhandler_process::exists): Fix comment. Return 1 in case of "fd" directory. Handle files below "fd". (fhandler_process::fstat): Drop "self" handling. Set correct link count for directories. (fhandler_process::opendir): New method to handle "fd" directory. (fhandler_process::readdir): Add "fd" handling. (fhandler_process::open): Drop "self" handling. (fhandler_process::fill_filebuf): Ditto. Add "fd" handling. Fix "maps" output string. * fhandler_registry.cc (fhandler_registry::fstat): Set correct link count for directories. * fhandler_socket.cc (fhandler_socket::get_proc_fd_name): New method. * path.cc (symlink_info::set): Fix thinko. * pinfo.cc (_pinfo::commune_recv): Rename pathbuf to path throughout. Drop local path variable in PICOM_FIFO case. Fix debug output. Close handles as early as possible. Add PICOM_FDS and PICOM_FD handling. (_pinfo::commune_send): Add PICOM_FDS and PICOM_FD handling. (_pinfo::fd): New method. (_pinfo::fds): New method. * pinfo.h (enum picom): Add PICOM_FDS and PICOM_FD. (_pinfo::fd): Declare. (_pinfo::fds): Declare. * pipe.cc (fhandler_pipe::get_proc_fd_name): New method.
2005-01-31 11:28:55 +01:00
}
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
void
fhandler_socket::af_local_copy (fhandler_socket *sock)
{
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
sock->connect_secret[0] = connect_secret[0];
sock->connect_secret[1] = connect_secret[1];
sock->connect_secret[2] = connect_secret[2];
sock->connect_secret[3] = connect_secret[3];
sock->sec_pid = sec_pid;
sock->sec_uid = sec_uid;
sock->sec_gid = sec_gid;
sock->sec_peer_pid = sec_peer_pid;
sock->sec_peer_uid = sec_peer_uid;
sock->sec_peer_gid = sec_peer_gid;
}
void
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
fhandler_socket::af_local_set_secret (char *buf)
{
if (!entropy_source)
{
void *buf = malloc (sizeof (fhandler_dev_random));
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
entropy_source = new (buf) fhandler_dev_random ();
entropy_source->dev () = *urandom_dev;
}
if (entropy_source &&
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
!entropy_source->open (O_RDONLY))
{
delete entropy_source;
entropy_source = NULL;
}
if (entropy_source)
{
size_t len = sizeof (connect_secret);
entropy_source->read (connect_secret, len);
if (len != sizeof (connect_secret))
bzero ((char*) connect_secret, sizeof (connect_secret));
}
__small_sprintf (buf, "%08x-%08x-%08x-%08x",
connect_secret [0], connect_secret [1],
connect_secret [2], connect_secret [3]);
}
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
/* Maximum number of concurrently opened sockets from all Cygwin processes
on a machine. Note that shared sockets (through dup/fork/exec) are
counted as one socket. */
#define NUM_SOCKS (65536 / sizeof (wsa_event))
#define LOCK_EVENTS WaitForSingleObject (wsock_mtx, INFINITE)
#define UNLOCK_EVENTS ReleaseMutex (wsock_mtx)
static wsa_event wsa_events[NUM_SOCKS] __attribute__((section (".cygwin_dll_common"), shared)) = { 0 };
static LONG socket_serial_number __attribute__((section (".cygwin_dll_common"), shared)) = 0;
static HANDLE wsa_slot_mtx;
static wsa_event *
search_wsa_event_slot (LONG new_serial_number)
{
char name[CYG_MAX_PATH], searchname[CYG_MAX_PATH];
if (!wsa_slot_mtx)
{
wsa_slot_mtx = CreateMutex (&sec_all, FALSE,
shared_name (name, "sock", 0));
if (!wsa_slot_mtx)
api_fatal ("Couldn't create/open shared socket mutex, %E");
}
switch (WaitForSingleObject (wsa_slot_mtx, INFINITE))
{
case WAIT_OBJECT_0:
case WAIT_ABANDONED:
break;
default:
api_fatal ("WFSO failed for shared socket mutex, %E");
break;
}
unsigned int slot = new_serial_number % NUM_SOCKS;
while (wsa_events[slot].serial_number)
{
HANDLE searchmtx = OpenMutex (STANDARD_RIGHTS_READ, FALSE,
shared_name (searchname, "sock", wsa_events[slot].serial_number));
if (!searchmtx)
break;
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
/* Mutex still exists, attached socket is active, try next slot. */
CloseHandle (searchmtx);
slot = (slot + 1) % NUM_SOCKS;
if (slot == (new_serial_number % NUM_SOCKS))
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
/* Did the whole array once. Too bad. */
debug_printf ("No free socket slot");
ReleaseMutex (wsa_slot_mtx);
return NULL;
}
}
memset (&wsa_events[slot], 0, sizeof (wsa_event));
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
wsa_events[slot].serial_number = new_serial_number;
ReleaseMutex (wsa_slot_mtx);
return wsa_events + slot;
}
bool
fhandler_socket::init_events ()
{
LONG new_serial_number;
char name[CYG_MAX_PATH];
DWORD err = 0;
do
{
new_serial_number = InterlockedIncrement (&socket_serial_number);
if (!new_serial_number) /* 0 is reserved for global mutex */
InterlockedIncrement (&socket_serial_number);
wsock_mtx = CreateMutex (&sec_all, FALSE,
shared_name (name, "sock", new_serial_number));
if (!wsock_mtx)
{
debug_printf ("CreateMutex, %E");
set_errno (ENOBUFS);
return false;
}
err = GetLastError ();
if (err == ERROR_ALREADY_EXISTS)
CloseHandle (wsock_mtx);
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
}
while (err == ERROR_ALREADY_EXISTS);
if ((wsock_evt = CreateEvent (&sec_all, TRUE, FALSE, NULL))
== WSA_INVALID_EVENT)
{
debug_printf ("WSACreateEvent, %E");
set_errno (ENOBUFS);
CloseHandle (wsock_mtx);
return false;
}
if (WSAEventSelect (get_socket (), wsock_evt, EVENT_MASK) == SOCKET_ERROR)
{
debug_printf ("WSAEventSelect, %E");
set_winsock_errno ();
CloseHandle (wsock_evt);
CloseHandle (wsock_mtx);
return false;
}
wsock_events = search_wsa_event_slot (new_serial_number);
/* sock type not yet set here. */
if (pc.dev == FH_UDP || pc.dev == FH_DGRAM)
wsock_events->events = FD_WRITE;
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
return true;
}
int
fhandler_socket::evaluate_events (const long event_mask, long &events,
bool erase)
{
int ret = 0;
long events_now = 0;
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
WSANETWORKEVENTS evts = { 0 };
if (!(WSAEnumNetworkEvents (get_socket (), wsock_evt, &evts)))
{
if (evts.lNetworkEvents)
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
LOCK_EVENTS;
wsock_events->events |= evts.lNetworkEvents;
events_now = (wsock_events->events & event_mask);
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
if (evts.lNetworkEvents & FD_CONNECT)
wsock_events->connect_errorcode = evts.iErrorCode[FD_CONNECT_BIT];
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
UNLOCK_EVENTS;
if ((evts.lNetworkEvents & FD_OOB) && wsock_events->owner)
kill (wsock_events->owner, SIGURG);
}
}
LOCK_EVENTS;
if ((events = events_now) != 0
|| (events = (wsock_events->events & event_mask)) != 0)
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
{
if (events & FD_CONNECT)
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
{
int wsa_err = 0;
if ((wsa_err = wsock_events->connect_errorcode) != 0)
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
{
WSASetLastError (wsa_err);
ret = SOCKET_ERROR;
}
else
wsock_events->events |= FD_WRITE;
wsock_events->events &= ~FD_CONNECT;
wsock_events->connect_errorcode = 0;
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
}
if (erase)
wsock_events->events &= ~(events & ~(FD_WRITE | FD_CLOSE));
}
UNLOCK_EVENTS;
return ret;
}
int
fhandler_socket::wait_for_events (const long event_mask)
{
if (async_io ())
return 0;
int ret;
long events;
while (!(ret = evaluate_events (event_mask, events, true)) && !events)
{
if (is_nonblocking ())
{
WSASetLastError (WSAEWOULDBLOCK);
return SOCKET_ERROR;
}
WSAEVENT ev[2] = { wsock_evt, signal_arrived };
switch (WSAWaitForMultipleEvents (2, ev, FALSE, 50, FALSE))
{
case WSA_WAIT_TIMEOUT:
case WSA_WAIT_EVENT_0:
break;
case WSA_WAIT_EVENT_0 + 1:
if (_my_tls.call_signal_handler ())
{
sig_dispatch_pending ();
break;
}
WSASetLastError (WSAEINTR);
return SOCKET_ERROR;
default:
WSASetLastError (WSAEFAULT);
return SOCKET_ERROR;
}
}
return ret;
}
void
fhandler_socket::release_events ()
{
CloseHandle (wsock_evt);
CloseHandle (wsock_mtx);
}
void
fhandler_socket::fixup_after_fork (HANDLE parent)
{
fork_fixup (parent, wsock_mtx, "wsock_mtx");
fork_fixup (parent, wsock_evt, "wsock_evt");
fhandler_base::fixup_after_fork (parent);
}
int
2005-09-28 21:22:25 +02:00
fhandler_socket::dup (fhandler_base *child)
{
debug_printf ("here");
fhandler_socket *fhs = (fhandler_socket *) child;
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
if (!DuplicateHandle (hMainProc, wsock_mtx, hMainProc, &fhs->wsock_mtx, 0,
TRUE, DUPLICATE_SAME_ACCESS))
{
__seterrno ();
return -1;
}
if (!DuplicateHandle (hMainProc, wsock_evt, hMainProc, &fhs->wsock_evt, 0,
TRUE, DUPLICATE_SAME_ACCESS))
{
__seterrno ();
CloseHandle (fhs->wsock_mtx);
return -1;
}
fhs->wsock_events = wsock_events;
fhs->addr_family = addr_family;
fhs->set_socket_type (get_socket_type ());
if (get_addr_family () == AF_LOCAL)
{
fhs->set_sun_path (get_sun_path ());
if (get_socket_type () == SOCK_STREAM)
2005-05-02 05:50:11 +02:00
{
fhs->sec_pid = sec_pid;
fhs->sec_uid = sec_uid;
fhs->sec_gid = sec_gid;
fhs->sec_peer_pid = sec_peer_pid;
fhs->sec_peer_uid = sec_peer_uid;
fhs->sec_peer_gid = sec_peer_gid;
}
}
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
fhs->connect_state (connect_state ());
int ret = fhandler_base::dup (child);
if (ret)
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
CloseHandle (fhs->wsock_evt);
CloseHandle (fhs->wsock_mtx);
}
return ret;
}
int __stdcall
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
fhandler_socket::fstat (struct __stat64 *buf)
{
int res;
if (get_device () == FH_UNIX)
{
res = fhandler_base::fstat_fs (buf);
if (!res)
2005-05-02 05:50:11 +02:00
{
buf->st_mode = (buf->st_mode & ~S_IFMT) | S_IFSOCK;
}
}
else
{
res = fhandler_base::fstat (buf);
if (!res)
{
buf->st_dev = 0;
buf->st_ino = (__ino64_t) ((DWORD) get_handle ());
buf->st_mode = S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO;
}
}
return res;
}
int __stdcall
fhandler_socket::fstatvfs (struct statvfs *sfs)
{
if (get_device () == FH_UNIX)
{
fhandler_disk_file fh (pc);
fh.get_device () = FH_FS;
return fh.fstatvfs (sfs);
}
set_errno (EBADF);
return -1;
}
int
fhandler_socket::fchmod (mode_t mode)
{
if (get_device () == FH_UNIX)
{
fhandler_disk_file fh (pc);
fh.get_device () = FH_FS;
int ret = fh.fchmod (adjust_socket_file_mode (mode));
SetFileAttributes (pc, GetFileAttributes (pc) | FILE_ATTRIBUTE_SYSTEM);
return ret;
}
set_errno (EBADF);
return -1;
}
int
fhandler_socket::fchown (__uid32_t uid, __gid32_t gid)
{
if (get_device () == FH_UNIX)
{
fhandler_disk_file fh (pc);
return fh.fchown (uid, gid);
}
set_errno (EBADF);
return -1;
}
int
fhandler_socket::facl (int cmd, int nentries, __aclent32_t *aclbufp)
{
if (get_device () == FH_UNIX)
{
fhandler_disk_file fh (pc);
return fh.facl (cmd, nentries, aclbufp);
}
set_errno (EBADF);
return -1;
}
int
fhandler_socket::link (const char *newpath)
{
if (get_device () == FH_UNIX)
{
fhandler_disk_file fh (pc);
return fh.link (newpath);
}
return fhandler_base::link (newpath);
}
static inline bool
address_in_use (struct sockaddr_in *addr)
{
PMIB_TCPTABLE tab;
PMIB_TCPROW entry;
DWORD size = 0, i;
if (GetTcpTable (NULL, &size, FALSE) == ERROR_INSUFFICIENT_BUFFER)
{
tab = (PMIB_TCPTABLE) alloca (size);
if (!GetTcpTable (tab, &size, FALSE))
2006-05-28 17:50:14 +02:00
{
for (i = tab->dwNumEntries, entry = tab->table; i > 0; --i, ++entry)
if (entry->dwLocalAddr == addr->sin_addr.s_addr
2006-05-28 17:50:14 +02:00
&& entry->dwLocalPort == addr->sin_port
&& entry->dwState >= MIB_TCP_STATE_LISTEN
&& entry->dwState <= MIB_TCP_STATE_LAST_ACK)
return true;
}
}
return false;
}
int
fhandler_socket::bind (const struct sockaddr *name, int namelen)
{
int res = -1;
if (name->sa_family == AF_LOCAL)
{
#define un_addr ((struct sockaddr_un *) name)
struct sockaddr_in sin;
int len = sizeof sin;
if (strlen (un_addr->sun_path) >= UNIX_PATH_LEN)
{
set_errno (ENAMETOOLONG);
goto out;
}
sin.sin_family = AF_INET;
sin.sin_port = 0;
sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
if (::bind (get_socket (), (sockaddr *) &sin, len))
{
syscall_printf ("AF_LOCAL: bind failed");
set_winsock_errno ();
goto out;
}
if (::getsockname (get_socket (), (sockaddr *) &sin, &len))
{
syscall_printf ("AF_LOCAL: getsockname failed");
set_winsock_errno ();
goto out;
}
sin.sin_port = ntohs (sin.sin_port);
debug_printf ("AF_LOCAL: socket bound to port %u", sin.sin_port);
path_conv pc (un_addr->sun_path, PC_SYM_FOLLOW);
if (pc.error)
2003-03-09 21:31:07 +01:00
{
set_errno (pc.error);
goto out;
}
if (pc.exists ())
2003-03-09 21:31:07 +01:00
{
set_errno (EADDRINUSE);
goto out;
}
mode_t mode = adjust_socket_file_mode ((S_IRWXU | S_IRWXG | S_IRWXO)
& ~cygheap->umask);
DWORD attr = FILE_ATTRIBUTE_SYSTEM;
if (!(mode & (S_IWUSR | S_IWGRP | S_IWOTH)))
2003-03-09 21:31:07 +01:00
attr |= FILE_ATTRIBUTE_READONLY;
SECURITY_ATTRIBUTES sa = sec_none;
* dir.cc (mkdir): Use local security_descriptor. Call set_security_attribute appropriately. * external.cc (cygwin_internal): Ditto. * fhandler.cc (fhandler_base::open): Ditto. * fhandler_socket.cc (fhandler_socket::bind): Ditto. * path.cc (symlink_worker): Ditto. * sec_acl.cc (setacl): Ditto. Call read_sd appropriately. (getace): Ditto. * sec_helper.cc (security_descriptor::malloc): New method. (security_descriptor::realloc): New method. (security_descriptor::free): New method. * security.cc (read_sd): Get security_descriptor as parameter instead of PSECURITY_DESCRIPTOR and a size. Drop unnecessary parameter check. Allocate the security_descriptor buffer according to size returned by a call to GetFileSecurity. Return buffer size on success. (write_sd): Get security_descriptor as parameter instead of PSECURITY_DESCRIPTOR and a size. (get_nt_attribute): Use local security_descriptor. (get_nt_object_attribute): Ditto in case of type == SE_REGISTRY_KEY. Allocate security_descriptor buffer according to size returned by a call to RegGetKeySecurity. (alloc_sd): Make static. Get security_descriptor as parameter instead of PSECURITY_DESCRIPTOR and a size. Drop unnecessary parameter check. (set_security_attribute): Get security_descriptor as parameter instead of PSECURITY_DESCRIPTOR and a size. (set_nt_attribute): Use local security_descriptor. (check_file_access): Ditto. * security.h: Add class security_descriptor. (read_sd): Change declaration to get security_descriptor as parameter instead of PSECURITY_DESCRIPTOR and a size. (write_sd): Ditto. (set_security_attribute): Ditto. (alloc_sd): Remove declaration. * thread.cc (semaphore::semaphore): Use local security_descriptor. Call set_security_attribute appropriately.
2003-11-26 14:23:27 +01:00
security_descriptor sd;
if (allow_ntsec && pc.has_acls ())
* dir.cc (mkdir): Use local security_descriptor. Call set_security_attribute appropriately. * external.cc (cygwin_internal): Ditto. * fhandler.cc (fhandler_base::open): Ditto. * fhandler_socket.cc (fhandler_socket::bind): Ditto. * path.cc (symlink_worker): Ditto. * sec_acl.cc (setacl): Ditto. Call read_sd appropriately. (getace): Ditto. * sec_helper.cc (security_descriptor::malloc): New method. (security_descriptor::realloc): New method. (security_descriptor::free): New method. * security.cc (read_sd): Get security_descriptor as parameter instead of PSECURITY_DESCRIPTOR and a size. Drop unnecessary parameter check. Allocate the security_descriptor buffer according to size returned by a call to GetFileSecurity. Return buffer size on success. (write_sd): Get security_descriptor as parameter instead of PSECURITY_DESCRIPTOR and a size. (get_nt_attribute): Use local security_descriptor. (get_nt_object_attribute): Ditto in case of type == SE_REGISTRY_KEY. Allocate security_descriptor buffer according to size returned by a call to RegGetKeySecurity. (alloc_sd): Make static. Get security_descriptor as parameter instead of PSECURITY_DESCRIPTOR and a size. Drop unnecessary parameter check. (set_security_attribute): Get security_descriptor as parameter instead of PSECURITY_DESCRIPTOR and a size. (set_nt_attribute): Use local security_descriptor. (check_file_access): Ditto. * security.h: Add class security_descriptor. (read_sd): Change declaration to get security_descriptor as parameter instead of PSECURITY_DESCRIPTOR and a size. (write_sd): Ditto. (set_security_attribute): Ditto. (alloc_sd): Remove declaration. * thread.cc (semaphore::semaphore): Use local security_descriptor. Call set_security_attribute appropriately.
2003-11-26 14:23:27 +01:00
set_security_attribute (mode, &sa, sd);
HANDLE fh = CreateFile (pc, GENERIC_WRITE, 0, &sa, CREATE_NEW, attr, 0);
if (fh == INVALID_HANDLE_VALUE)
2003-03-09 21:31:07 +01:00
{
if (GetLastError () == ERROR_ALREADY_EXISTS)
set_errno (EADDRINUSE);
else
__seterrno ();
}
char buf[sizeof (SOCKET_COOKIE) + 80];
__small_sprintf (buf, "%s%u %c ", SOCKET_COOKIE, sin.sin_port, get_socket_type () == SOCK_STREAM ? 's' : get_socket_type () == SOCK_DGRAM ? 'd' : '-');
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
af_local_set_secret (strchr (buf, '\0'));
DWORD blen = strlen (buf) + 1;
if (!WriteFile (fh, buf, blen, &blen, 0))
2003-03-09 21:31:07 +01:00
{
__seterrno ();
CloseHandle (fh);
DeleteFile (pc);
}
else
2003-03-09 21:31:07 +01:00
{
CloseHandle (fh);
set_sun_path (un_addr->sun_path);
res = 0;
}
#undef un_addr
}
else
{
/* If the application didn't explicitely call setsockopt (SO_REUSEADDR),
2006-05-28 17:50:14 +02:00
enforce exclusive local address use using the SO_EXCLUSIVEADDRUSE
socket option, to emulate POSIX socket behaviour more closely.
2006-05-28 17:50:14 +02:00
KB 870562: Note that this option is only available since NT4 SP4.
Also note that a bug in Win2K SP1-3 and XP up to SP1 only enables
this option for users in the local administrators group. */
if (wincap.has_exclusiveaddruse ())
2006-05-28 17:50:14 +02:00
{
if (!saw_reuseaddr ())
{
int on = 1;
int ret = ::setsockopt (get_socket (), SOL_SOCKET,
~(SO_REUSEADDR),
(const char *) &on, sizeof on);
debug_printf ("%d = setsockopt (SO_EXCLUSIVEADDRUSE), %E", ret);
}
else
{
debug_printf ("SO_REUSEADDR set");
/* There's a bug in SO_REUSEADDR handling in WinSock.
2006-05-28 17:50:14 +02:00
Per standards, we must not be able to reuse a complete
duplicate of a local TCP address (same IP, same port),
even if SO_REUSEADDR has been set. That's unfortunately
possible in WinSock. So we're testing here if the local
address is already in use and don't bind, if so. This
only works for OSes with IP Helper support. */
if (get_socket_type () == SOCK_STREAM
&& wincap.has_ip_helper_lib ()
2006-05-28 17:50:14 +02:00
&& address_in_use ((struct sockaddr_in *) name))
{
debug_printf ("Local address in use, don't bind");
set_errno (EADDRINUSE);
goto out;
}
}
}
if (::bind (get_socket (), name, namelen))
set_winsock_errno ();
else
res = 0;
}
out:
return res;
}
int
fhandler_socket::connect (const struct sockaddr *name, int namelen)
{
int res = -1;
bool in_progress = false;
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
struct sockaddr_storage sst;
DWORD err;
int type;
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
if (!get_inet_addr (name, namelen, &sst, &namelen, &type, connect_secret))
return -1;
if (get_addr_family () == AF_LOCAL && get_socket_type () != type)
{
WSASetLastError (WSAEPROTOTYPE);
set_winsock_errno ();
return -1;
}
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
res = ::connect (get_socket (), (struct sockaddr *) &sst, namelen);
if (!is_nonblocking ()
&& res == SOCKET_ERROR
&& WSAGetLastError () == WSAEWOULDBLOCK)
res = wait_for_events (FD_CONNECT | FD_CLOSE);
if (!res)
err = 0;
else
{
err = WSAGetLastError ();
/* Special handling for connect to return the correct error code
when called on a non-blocking socket. */
if (is_nonblocking ())
{
if (err == WSAEWOULDBLOCK || err == WSAEALREADY)
in_progress = true;
if (err == WSAEWOULDBLOCK)
WSASetLastError (err = WSAEINPROGRESS);
}
if (err == WSAEINVAL)
WSASetLastError (err = WSAEISCONN);
set_winsock_errno ();
}
if (get_addr_family () == AF_LOCAL && (!res || in_progress))
set_sun_path (name->sa_data);
if (get_addr_family () == AF_LOCAL && get_socket_type () == SOCK_STREAM)
{
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
af_local_set_cred (); /* Don't move into af_local_connect since
af_local_connect is called from select,
possibly running under another identity. */
if (!res && af_local_connect ())
{
set_winsock_errno ();
return -1;
}
}
if (err == WSAEINPROGRESS || err == WSAEALREADY)
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
connect_state (connect_pending);
else if (err)
connect_state (connect_failed);
else
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
connect_state (connected);
return res;
}
int
fhandler_socket::listen (int backlog)
{
int res = ::listen (get_socket (), backlog);
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
if (res && WSAGetLastError () == WSAEINVAL)
{
/* It's perfectly valid to call listen on an unbound INET socket.
In this case the socket is automatically bound to an unused
port number, listening on all interfaces. On Winsock, listen
fails with WSAEINVAL when it's called on an unbound socket.
So we have to bind manually here to have POSIX semantics. */
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
if (get_addr_family () == AF_INET)
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
struct sockaddr_in sin;
sin.sin_family = AF_INET;
sin.sin_port = 0;
sin.sin_addr.s_addr = INADDR_ANY;
if (!::bind (get_socket (), (struct sockaddr *) &sin, sizeof sin))
res = ::listen (get_socket (), backlog);
}
else if (get_addr_family () == AF_INET6)
{
struct sockaddr_in6 sin6 =
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
{
sin6_family: AF_INET6,
sin6_port: 0,
sin6_flowinfo: 0,
sin6_addr: IN6ADDR_ANY_INIT,
sin6_scope_id: 0
};
if (!::bind (get_socket (), (struct sockaddr *) &sin6, sizeof sin6))
res = ::listen (get_socket (), backlog);
}
}
if (!res)
{
if (get_addr_family () == AF_LOCAL && get_socket_type () == SOCK_STREAM)
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
af_local_set_cred ();
connect_state (connected);
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
listener (true);
}
else
set_winsock_errno ();
return res;
}
int
fhandler_socket::accept (struct sockaddr *peer, int *len)
{
/* Allows NULL peer and len parameters. */
struct sockaddr_in peer_dummy;
int len_dummy;
if (!peer)
peer = (struct sockaddr *) &peer_dummy;
if (!len)
{
len_dummy = sizeof (struct sockaddr_in);
len = &len_dummy;
}
/* accept on NT fails if len < sizeof (sockaddr_in)
* some programs set len to
* sizeof (name.sun_family) + strlen (name.sun_path) for UNIX domain
*/
if (len && ((unsigned) *len < sizeof (struct sockaddr_in)))
*len = sizeof (struct sockaddr_in);
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
int res = 0;
while (!(res = wait_for_events (FD_ACCEPT | FD_CLOSE))
&& (res = ::accept (get_socket (), peer, len)) == SOCKET_ERROR
&& WSAGetLastError () == WSAEWOULDBLOCK)
;
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
if (res == (int) INVALID_SOCKET)
set_winsock_errno ();
else
{
cygheap_fdnew res_fd;
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
if (res_fd >= 0 && fdsock (res_fd, &dev (), res))
{
fhandler_socket *sock = (fhandler_socket *) res_fd;
sock->set_addr_family (get_addr_family ());
sock->set_socket_type (get_socket_type ());
sock->async_io (async_io ());
sock->set_nonblocking (is_nonblocking ());
if (get_addr_family () == AF_LOCAL)
{
sock->set_sun_path (get_sun_path ());
if (get_socket_type () == SOCK_STREAM)
2005-05-02 05:50:11 +02:00
{
/* Don't forget to copy credentials from accepting
socket to accepted socket and start transaction
on accepted socket! */
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
af_local_copy (sock);
res = sock->af_local_accept ();
if (res == -1)
{
res_fd.release ();
set_winsock_errno ();
goto out;
}
2005-05-02 05:50:11 +02:00
}
}
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
/* No locking necessary at this point. */
sock->wsock_events->events = wsock_events->events | FD_WRITE;
sock->wsock_events->owner = wsock_events->owner;
sock->connect_state (connected);
res = res_fd;
}
else
2003-03-09 21:31:07 +01:00
{
closesocket (res);
res = -1;
}
}
* fhandler.h (fhandler_socket::secret_event): Remove. (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.
2005-03-24 15:04:06 +01:00
out:
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
debug_printf ("res %d", res);
return res;
}
int
fhandler_socket::getsockname (struct sockaddr *name, int *namelen)
{
int res = -1;
if (get_addr_family () == AF_LOCAL)
{
struct sockaddr_un *sun = (struct sockaddr_un *) name;
memset (sun, 0, *namelen);
sun->sun_family = AF_LOCAL;
if (!get_sun_path ())
sun->sun_path[0] = '\0';
else
/* According to SUSv2 "If the actual length of the address is
greater than the length of the supplied sockaddr structure, the
stored address will be truncated." We play it save here so
that the path always has a trailing 0 even if it's truncated. */
strncpy (sun->sun_path, get_sun_path (),
*namelen - sizeof *sun + sizeof sun->sun_path - 1);
*namelen = sizeof *sun - sizeof sun->sun_path
+ strlen (sun->sun_path) + 1;
res = 0;
}
else
{
res = ::getsockname (get_socket (), name, namelen);
if (res)
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
if (WSAGetLastError () == WSAEINVAL)
{
/* Winsock returns WSAEINVAL if the socket is locally
unbound. Per SUSv3 this is not an error condition.
We're faking a valid return value here by creating the
same content in the sockaddr structure as on Linux. */
switch (get_addr_family ())
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
case AF_INET:
res = 0;
*namelen = sizeof (struct sockaddr_in);
break;
case AF_INET6:
res = 0;
*namelen = sizeof (struct sockaddr_in6);
break;
default:
WSASetLastError (WSAEOPNOTSUPP);
break;
}
if (!res)
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
memset (name, 0, *namelen);
name->sa_family = get_addr_family ();
}
}
if (res)
set_winsock_errno ();
}
}
return res;
}
int
fhandler_socket::getpeername (struct sockaddr *name, int *namelen)
{
int res = ::getpeername (get_socket (), name, namelen);
if (res)
set_winsock_errno ();
return res;
}
int
fhandler_socket::readv (const struct iovec *const iov, const int iovcnt,
ssize_t tot)
{
struct msghdr msg =
{
2002-11-28 01:41:02 +01:00
msg_name: NULL,
msg_namelen: 0,
msg_iov: (struct iovec *) iov, // const_cast
msg_iovlen: iovcnt,
* autoload.cc: Never load wsock32.dll. Load all wsock32 function 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.
2005-10-17 23:22:18 +02:00
msg_control: NULL,
msg_controllen: 0,
msg_flags: 0
};
return recvmsg (&msg, 0);
}
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
inline ssize_t
fhandler_socket::recv_internal (WSABUF *wsabuf, DWORD wsacnt, DWORD flags,
struct sockaddr *from, int *fromlen)
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
ssize_t res = 0;
DWORD ret = 0;
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
int evt_mask = FD_READ | ((flags & MSG_OOB) ? FD_OOB : 0);
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
flags &= MSG_WINMASK;
/* Note: Don't call WSARecvFrom(MSG_PEEK) without actually having data
waiting in the buffers, otherwise the event handling gets messed up
for some reason. */
while (!(res = wait_for_events (evt_mask | FD_CLOSE))
|| saw_shutdown_read ())
{
2006-08-10 16:16:24 +02:00
res = WSARecvFrom (get_socket (), wsabuf, wsacnt, &ret,
&flags, from, fromlen, NULL, NULL);
if (!res || WSAGetLastError () != WSAEWOULDBLOCK)
break;
}
if (res == SOCKET_ERROR)
{
/* According to SUSv3, errno isn't set in that case and no error
2003-03-09 21:31:07 +01:00
condition is returned. */
if (WSAGetLastError () == WSAEMSGSIZE)
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
return ret;
/* ESHUTDOWN isn't defined for recv in SUSv3. Simply EOF is returned
2005-12-22 06:57:54 +01:00
in this case. */
if (WSAGetLastError () == WSAESHUTDOWN)
2005-12-22 06:57:54 +01:00
return 0;
set_winsock_errno ();
}
else
res = ret;
return res;
}
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
int
fhandler_socket::recvfrom (void *ptr, size_t len, int flags,
struct sockaddr *from, int *fromlen)
{
WSABUF wsabuf = { len, (char *) ptr };
return recv_internal (&wsabuf, 1, flags, from, fromlen);
}
int
fhandler_socket::recvmsg (struct msghdr *msg, int flags)
{
* autoload.cc: Never load wsock32.dll. Load all wsock32 function 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.
2005-10-17 23:22:18 +02:00
if (CYGWIN_VERSION_CHECK_FOR_USING_ANCIENT_MSGHDR)
((struct OLD_msghdr *) msg)->msg_accrightslen = 0;
else
{
msg->msg_controllen = 0;
msg->msg_flags = 0;
}
if (get_addr_family () == AF_LOCAL)
{
/* On AF_LOCAL sockets the (fixed-size) name of the shared memory
area used for descriptor passing is transmitted first.
If this string is empty, no descriptors are passed and we can
go ahead recv'ing the normal data blocks. Otherwise start
special handling for descriptor passing. */
/*TODO*/
}
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
WSABUF wsabuf[msg->msg_iovlen];
WSABUF *wsaptr = wsabuf + msg->msg_iovlen;
const struct iovec *iovptr = msg->msg_iov + msg->msg_iovlen;
while (--wsaptr >= wsabuf)
* autoload.cc: Never load wsock32.dll. Load all wsock32 function 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.
2005-10-17 23:22:18 +02:00
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
wsaptr->len = (--iovptr)->iov_len;
* autoload.cc: Never load wsock32.dll. Load all wsock32 function 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.
2005-10-17 23:22:18 +02:00
wsaptr->buf = (char *) iovptr->iov_base;
}
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
struct sockaddr *from = (struct sockaddr *) msg->msg_name;
int *fromlen = from ? &msg->msg_namelen : NULL;
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
return recv_internal (wsabuf, msg->msg_iovlen, flags, from, fromlen);
}
int
fhandler_socket::writev (const struct iovec *const iov, const int iovcnt,
ssize_t tot)
{
struct msghdr msg =
{
msg_name: NULL,
msg_namelen: 0,
msg_iov: (struct iovec *) iov, // const_cast
msg_iovlen: iovcnt,
* autoload.cc: Never load wsock32.dll. Load all wsock32 function 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.
2005-10-17 23:22:18 +02:00
msg_control: NULL,
msg_controllen: 0,
msg_flags: 0
};
return sendmsg (&msg, 0);
}
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
inline ssize_t
fhandler_socket::send_internal (struct _WSABUF *wsabuf, DWORD wsacnt, int flags,
const struct sockaddr *to, int tolen)
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
int res = 0;
DWORD ret = 0, err = 0;
* autoload.cc: Never load wsock32.dll. Load all wsock32 function 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.
2005-10-17 23:22:18 +02:00
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
do
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
if ((res = WSASendTo (get_socket (), wsabuf, wsacnt, &ret,
flags & MSG_WINMASK, to, tolen, NULL, NULL))
&& (err = WSAGetLastError ()) == WSAEWOULDBLOCK)
{
LOCK_EVENTS;
wsock_events->events &= ~FD_WRITE;
UNLOCK_EVENTS;
}
}
while (res && err == WSAEWOULDBLOCK
&& !(res = wait_for_events (FD_WRITE | FD_CLOSE)));
if (res == SOCKET_ERROR)
set_winsock_errno ();
else
res = ret;
/* Special handling for EPIPE and SIGPIPE.
EPIPE is generated if the local end has been shut down on a connection
oriented socket. In this case the process will also receive a SIGPIPE
unless MSG_NOSIGNAL is set. */
if (res == SOCKET_ERROR && get_errno () == ESHUTDOWN
&& get_socket_type () == SOCK_STREAM)
{
set_errno (EPIPE);
if (! (flags & MSG_NOSIGNAL))
2002-10-20 06:46:31 +02:00
raise (SIGPIPE);
}
return res;
}
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
ssize_t
fhandler_socket::sendto (const void *ptr, size_t len, int flags,
const struct sockaddr *to, int tolen)
{
struct sockaddr_storage sst;
if (to && !get_inet_addr (to, tolen, &sst, &tolen))
return SOCKET_ERROR;
WSABUF wsabuf = { len, (char *) ptr };
return send_internal (&wsabuf, 1, flags,
(to ? (const struct sockaddr *) &sst : NULL), tolen);
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
}
int
fhandler_socket::sendmsg (const struct msghdr *msg, int flags)
{
2005-09-28 21:22:25 +02:00
if (get_addr_family () == AF_LOCAL)
{
2005-09-28 21:22:25 +02:00
/* For AF_LOCAL/AF_UNIX sockets, if descriptors are given, start
the special handling for descriptor passing. Otherwise just
transmit an empty string to tell the receiver that no
descriptor passing is done. */
2005-09-28 21:22:25 +02:00
/*TODO*/
}
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
WSABUF wsabuf[msg->msg_iovlen];
WSABUF *wsaptr = wsabuf + msg->msg_iovlen;
const struct iovec *iovptr = msg->msg_iov + msg->msg_iovlen;
while (--wsaptr >= wsabuf)
* autoload.cc: Never load wsock32.dll. Load all wsock32 function 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.
2005-10-17 23:22:18 +02:00
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
wsaptr->len = (--iovptr)->iov_len;
* autoload.cc: Never load wsock32.dll. Load all wsock32 function 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.
2005-10-17 23:22:18 +02:00
wsaptr->buf = (char *) iovptr->iov_base;
}
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
return send_internal (wsabuf, msg->msg_iovlen, flags,
(struct sockaddr *) msg->msg_name, msg->msg_namelen);
}
int
fhandler_socket::shutdown (int how)
{
int res = ::shutdown (get_socket (), how);
if (res)
set_winsock_errno ();
else
switch (how)
{
case SHUT_RD:
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
saw_shutdown_read (true);
break;
case SHUT_WR:
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
saw_shutdown_write (true);
break;
case SHUT_RDWR:
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
saw_shutdown_read (true);
saw_shutdown_write (true);
break;
}
return res;
}
int
fhandler_socket::close ()
{
int res = 0;
/* HACK to allow a graceful shutdown even if shutdown() hasn't been
called by the application. Note that this isn't the ultimate
solution but it helps in many cases. */
struct linger linger;
linger.l_onoff = 1;
* cygserver.h (client_request::request_code_t): Add CYGSERVER_REQUEST_MSG and CYGSERVER_REQUEST_SEM. (admininstrator_group_sid): Add extern declaration. * cygserver_ipc.h: Rewrite. * cygserver_msg.h: New file. * cygserver_sem.h: New file. * cygserver_shm.h: More or less rewrite. * cygwin.din: Add msgctl, msgget, msgrcv, msgsnd, semctl, semget and semop. * msg.cc: Rewrite. * safe_memory.h: Remove. * sem.cc: Rewrite. * shm.cc: Rewrite. * include/cygwin/ipc.h: Use appropriate guard. (struct ipc_perm): Add seq. (IPCID_TO_IX): New define from BSD. (IPCID_TO_SEQ): Ditto. (IXSEQ_TO_IPCID): Ditto. (IPC_R): Ditto. (IPC_W): Ditto. (IPC_M): Ditto. * include/cygwin/msg.h: Use appropriate guard. #ifdef _KERNEL all stuff not explicitely defined by SUSv3. Use signed types in structs to match types used in BSD. (msgqnum_t): Define unsigned. (msglen_t): Ditto. (struct msqid_ds): Add msg_first and msg_last. (struct msginfo): Remove msgpool. Add msgssz and msgseg. * include/cygwin/sem.h: Use appropriate guard. #ifdef _KERNEL all stuff not explicitely defined by SUSv3. Use signed types in structs to match types used in BSD. (SEM_UNDO): Define appropriately. (struct semid_ds): Add sem_base. (struct seminfo): Add semmap and semusz. (SEM_A): New define from BSD. (SEM_R): Ditto. (SEM_ALLOC): Ditto. (union semun): Define. * include/cygwin/shm.h: Use appropriate guard. #ifdef _KERNEL all stuff not explicitely defined by SUSv3. Use signed types in structs to match types used in BSD. (SHMLBA): Define using cygwin_internal(CW_GET_SHMLBA) call. (struct shmid_ds): Add shm_internal. (struct shm_info): Rename shm_ids to used_ids as in BSD. Add define for shm_ids. * include/cygwin/sysproto.h: New file. * include/cygwin/version.h: Bump API minor number. * include/sys/ipc.h: New file. * include/sys/msg.h: New file. * include/sys/queue.h: New file from BSD. * include/sys/sem.h: New file. * include/sys/shm.h: New file. * include/sys/sysproto.h: New file.
2003-11-19 19:50:23 +01:00
linger.l_linger = 240; /* secs. default 2MSL value according to MSDN. */
setsockopt (get_socket (), SOL_SOCKET, SO_LINGER,
(const char *)&linger, sizeof linger);
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
release_events ();
while ((res = closesocket (get_socket ())) != 0)
{
if (WSAGetLastError () != WSAEWOULDBLOCK)
{
set_winsock_errno ();
res = -1;
break;
}
if (WaitForSingleObject (signal_arrived, 10) == WAIT_OBJECT_0)
{
set_errno (EINTR);
res = -1;
break;
}
WSASetLastError (0);
}
debug_printf ("%d = fhandler_socket::close()", res);
return res;
}
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
/* Definitions of old ifreq stuff used prior to Cygwin 1.7.0. */
#define OLD_SIOCGIFFLAGS _IOW('s', 101, struct __old_ifreq)
#define OLD_SIOCGIFADDR _IOW('s', 102, struct __old_ifreq)
#define OLD_SIOCGIFBRDADDR _IOW('s', 103, struct __old_ifreq)
#define OLD_SIOCGIFNETMASK _IOW('s', 104, struct __old_ifreq)
#define OLD_SIOCGIFHWADDR _IOW('s', 105, struct __old_ifreq)
#define OLD_SIOCGIFMETRIC _IOW('s', 106, struct __old_ifreq)
#define OLD_SIOCGIFMTU _IOW('s', 107, struct __old_ifreq)
#define OLD_SIOCGIFINDEX _IOW('s', 108, struct __old_ifreq)
#define CONV_OLD_TO_NEW_SIO(old) (((old)&0xff00ffff)|(((long)sizeof(struct ifreq)&IOCPARM_MASK)<<16))
struct __old_ifreq {
#define __OLD_IFNAMSIZ 16
union {
char ifrn_name[__OLD_IFNAMSIZ]; /* if name, e.g. "en0" */
} ifr_ifrn;
union {
struct sockaddr ifru_addr;
struct sockaddr ifru_broadaddr;
struct sockaddr ifru_netmask;
struct sockaddr ifru_hwaddr;
short ifru_flags;
int ifru_metric;
int ifru_mtu;
int ifru_ifindex;
} ifr_ifru;
};
int
fhandler_socket::ioctl (unsigned int cmd, void *p)
{
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
extern int get_ifconf (SOCKET s, struct ifconf *ifc, int what); /* net.cc */
int res;
struct ifconf ifc, *ifcp;
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
struct ifreq *ifrp;
switch (cmd)
{
case SIOCGIFCONF:
ifcp = (struct ifconf *) p;
if (!ifcp)
{
set_errno (EINVAL);
return -1;
}
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
{
ifc.ifc_len = ifcp->ifc_len / sizeof (struct __old_ifreq)
* sizeof (struct ifreq);
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
ifc.ifc_buf = (caddr_t) alloca (ifc.ifc_len);
}
else
{
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
ifc.ifc_len = ifcp->ifc_len;
ifc.ifc_buf = ifcp->ifc_buf;
}
res = get_ifconf (get_socket (), &ifc, cmd);
if (res)
debug_printf ("error in get_ifconf");
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
{
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
struct __old_ifreq *ifr = (struct __old_ifreq *) ifcp->ifc_buf;
for (ifrp = ifc.ifc_req;
(caddr_t) ifrp < ifc.ifc_buf + ifc.ifc_len;
++ifrp, ++ifr)
{
memcpy (&ifr->ifr_ifrn, &ifrp->ifr_ifrn, sizeof ifr->ifr_ifrn);
ifr->ifr_name[__OLD_IFNAMSIZ - 1] = '\0';
memcpy (&ifr->ifr_ifru, &ifrp->ifr_ifru, sizeof ifr->ifr_ifru);
}
ifcp->ifc_len = ifc.ifc_len / sizeof (struct ifreq)
* sizeof (struct __old_ifreq);
}
else
ifcp->ifc_len = ifc.ifc_len;
break;
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
case OLD_SIOCGIFFLAGS:
case OLD_SIOCGIFADDR:
case OLD_SIOCGIFBRDADDR:
case OLD_SIOCGIFNETMASK:
case OLD_SIOCGIFHWADDR:
case OLD_SIOCGIFMETRIC:
case OLD_SIOCGIFMTU:
case OLD_SIOCGIFINDEX:
cmd = CONV_OLD_TO_NEW_SIO (cmd);
/*FALLTHRU*/
case SIOCGIFFLAGS:
case SIOCGIFBRDADDR:
case SIOCGIFNETMASK:
case SIOCGIFADDR:
case SIOCGIFHWADDR:
case SIOCGIFMETRIC:
case SIOCGIFMTU:
case SIOCGIFINDEX:
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
case SIOCGIFFRNDLYNAM:
case SIOCGIFDSTADDR:
{
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
if (!p)
{
debug_printf ("ifr == NULL");
set_errno (EINVAL);
return -1;
}
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
if (cmd > SIOCGIFINDEX && CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
{
debug_printf ("cmd not supported on this platform");
set_errno (EINVAL);
return -1;
}
ifc.ifc_len = 64 * sizeof (struct ifreq);
ifc.ifc_buf = (caddr_t) alloca (ifc.ifc_len);
if (cmd == SIOCGIFFRNDLYNAM)
{
struct ifreq_frndlyname *iff = (struct ifreq_frndlyname *)
alloca (64 * sizeof (struct ifreq_frndlyname));
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
for (int i = 0; i < 64; ++i)
ifc.ifc_req[i].ifr_frndlyname = &iff[i];
}
res = get_ifconf (get_socket (), &ifc, cmd);
if (res)
{
debug_printf ("error in get_ifconf");
break;
}
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
{
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
struct __old_ifreq *ifr = (struct __old_ifreq *) p;
debug_printf (" name: %s", ifr->ifr_name);
for (ifrp = ifc.ifc_req;
(caddr_t) ifrp < ifc.ifc_buf + ifc.ifc_len;
++ifrp)
{
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
debug_printf ("testname: %s", ifrp->ifr_name);
if (! strcmp (ifrp->ifr_name, ifr->ifr_name))
{
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
memcpy (&ifr->ifr_ifru, &ifrp->ifr_ifru,
sizeof ifr->ifr_ifru);
break;
* autoload.cc (WSAIoctl): Define. (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.
2007-01-21 23:54:05 +01:00
}
}
}
else
{
struct ifreq *ifr = (struct ifreq *) p;
debug_printf (" name: %s", ifr->ifr_name);
for (ifrp = ifc.ifc_req;
(caddr_t) ifrp < ifc.ifc_buf + ifc.ifc_len;
++ifrp)
{
debug_printf ("testname: %s", ifrp->ifr_name);
if (! strcmp (ifrp->ifr_name, ifr->ifr_name))
{
if (cmd == SIOCGIFFRNDLYNAM)
/* The application has to care for the space. */
memcpy (ifr->ifr_frndlyname, ifrp->ifr_frndlyname,
sizeof (struct ifreq_frndlyname));
else
memcpy (&ifr->ifr_ifru, &ifrp->ifr_ifru,
sizeof ifr->ifr_ifru);
break;
}
}
}
if ((caddr_t) ifrp >= ifc.ifc_buf + ifc.ifc_len)
{
set_errno (EINVAL);
return -1;
}
break;
}
case FIOASYNC:
res = WSAAsyncSelect (get_socket (), winmsg, WM_ASYNCIO,
*(int *) p ? ASYNC_MASK : 0);
syscall_printf ("Async I/O on socket %s",
*(int *) p ? "started" : "cancelled");
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
async_io (*(int *) p != 0);
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
/* If async_io is switched off, revert the event handling. */
if (*(int *) p == 0)
WSAEventSelect (get_socket (), wsock_evt, EVENT_MASK);
break;
case FIONREAD:
res = ioctlsocket (get_socket (), FIONREAD, (unsigned long *) p);
if (res == SOCKET_ERROR)
set_winsock_errno ();
break;
default:
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
/* Sockets are always non-blocking internally. So we just note the
state here. */
if (cmd == FIONBIO)
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
syscall_printf ("socket is now %sblocking",
*(int *) p ? "non" : "");
set_nonblocking (*(int *) p);
res = 0;
}
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
else
res = ioctlsocket (get_socket (), cmd, (unsigned long *) p);
break;
}
syscall_printf ("%d = ioctl_socket (%x, %x)", res, cmd, p);
return res;
}
int
fhandler_socket::fcntl (int cmd, void *arg)
{
int res = 0;
int request, current;
switch (cmd)
{
case F_SETOWN:
{
pid_t pid = (pid_t) arg;
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
LOCK_EVENTS;
wsock_events->owner = pid;
UNLOCK_EVENTS;
debug_printf ("owner set to %d", pid);
}
break;
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
case F_GETOWN:
res = wsock_events->owner;
break;
case F_SETFL:
{
/* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
Set only the flag that has been passed in. If both are set, just
record O_NONBLOCK. */
int new_flags = (int) arg & O_NONBLOCK_MASK;
if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK))
new_flags = O_NONBLOCK;
current = get_flags () & O_NONBLOCK_MASK;
request = new_flags ? 1 : 0;
if (!!current != !!new_flags && (res = ioctl (FIONBIO, &request)))
break;
set_flags ((get_flags () & ~O_NONBLOCK_MASK) | new_flags);
break;
}
default:
res = fhandler_base::fcntl (cmd, arg);
break;
}
return res;
}
void
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
fhandler_socket::set_close_on_exec (bool val)
{
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * 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.
2006-07-25 21:23:23 +02:00
set_no_inheritance (wsock_mtx, val);
set_no_inheritance (wsock_evt, val);
fhandler_base::set_close_on_exec (val);
debug_printf ("set close_on_exec for %s to %d", get_name (), val);
}
void
fhandler_socket::set_sun_path (const char *path)
{
sun_path = path ? cstrdup (path) : NULL;
}
int
fhandler_socket::getpeereid (pid_t *pid, __uid32_t *euid, __gid32_t *egid)
{
if (get_addr_family () != AF_LOCAL || get_socket_type () != SOCK_STREAM)
{
set_errno (EINVAL);
return -1;
}
if (connect_state () != connected)
{
set_errno (ENOTCONN);
return -1;
}
if (sec_peer_pid == (pid_t) 0)
{
set_errno (ENOTCONN); /* Usually when calling getpeereid on
2005-05-02 05:50:11 +02:00
accepting (instead of accepted) socket. */
return -1;
}
myfault efault;
if (efault.faulted (EFAULT))
return -1;
if (pid)
*pid = sec_peer_pid;
if (euid)
*euid = sec_peer_uid;
if (egid)
*egid = sec_peer_gid;
return 0;
}