Per-socket info in fhandler isn't correctly shared between multiple
instances of th same descriptor. Implement a basic shared info which
is shared between all instances of a socket.
This also requires to move the fhandler_socket status bits into
fhandler_socket_wsock since the data is moved to the shared region
for AF_UNIX sockets.
Also, drop backing file requirement for socketpair server socket.
This will be handled differently in recvmsg/sendmsg.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Rearrange includes and drop unneccessary ones.
* Don't pull in cygwin/socket.h into sys/un.h just to get
sa_family_t. Include sys/types.h and use __sa_family_t instead.
* start including Windows headers using the w32api/ path prefix
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Insert another class fhandler_socket_wsock between fhandler_socket
and fhandler_socket_inet/fhandler_socket_local.
Also, add a new method fhandler::is_wsock_socket to allow asking
for sockets in general (is_socket) vs. Winsock-based sockets
(is_wsock_socket).
This allows to develop a new handler_socket_unix class as derived
class from fhandler_socket without any trace of wsock code left
in fhandler_socket.
While this is basically a temporary measure at this time, it may
prove useful for later interoperability with the upcoming Windows 10
AF_UNIX implementation at one point.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Rename DEV_TCP_MAJOR to DEV_SOCK_MAJOR
* Drop FH_TCP, FH_UDP, FH_ICMP in favor of single FH_INET
* Drop FH_UNIX, FH_STREAM, FH_DGRAM in favor of single FH_LOCAL
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
First cut, still incomplete
* fhandler_socket is now base class for other socket classes
* fhandler_socket_inet handles AF_INET and AF_INET6 sockets
* fhandler_socket_local handles AF_LOCAL/AF_UNIX sockets
* finally get rid of fdsock by using set_socket_handle in accept4
* align file-related calls (fstat, fstatvfs, fchown, fchmod, facl)
to Linux.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Add fhandler_socket::socket method
Add fhandler_socket::set_socket_handle method, basically duplicating
what fdsock is doing. This is the first step in getting rid of fdsock.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix an incorrect condition to recognize AF_LOCAL sockets in
file-related functions (fchmod, fchown, fstat, fsttavfs, facl, link).
* Return successfully when called on unnamed or abstract AF_LOCAL sockets,
except link, just as on Linux.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
We're still using ~SO_REUSEADDR because SO_EXCLUSIVEADDRUSE wasn't
defined in Mingw. But it is in Mingw-w64, so fix it.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix the maximum number of sockets allowed in the session to 2048,
instead of making it relative to sizeof(wsa_event).
The original choice of 2048 was in order to fit the wsa_events array
in the .cygwin_dll_common shared section, but there is still enough
room to grow there to have 2048 sockets on 64-bit as well.
* Return an error and set errno=ENOBUF if a socket can't be created
due to this limit being reached.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
When SA_RESTART is not set on a socket, a blocking send() that is
interrupted mid-transition by a signal should return success (and
report just how many bytes were actually transmitted).
The err variable used here was not always guaranteed to be set
correctly in the loop, so better to just remove it and call
WSAGetLastError() explicitly.
Include ntsecapi.h where required and just redefine RtlGenRandom
correctly in the ntsecapi.h wrapper.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
In preparation of exporting getentropy/getrandom to userspace, rearrange
code a bit:
- Define RtlGenRandom in ntdll.h.
- Drop calls to getentropy in favor of RtlGenRandom (fhandler_socket,
fhandler_dev_random).
- Add try/except blocks in fhandler_dev_random to return EFAULT rather
than crashing if buffer pointer is invalid.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Commit b1b46d45 introduced a regression. After redefining FIONREAD
as part of restructuring newlib/Cygwin headers, the call to ioctlsocket
in the FIONREAD branch of fhandler_socket::ioctl should have been
changed to use the Winsock definition of FIONREAD, which I neglected.
This only affects 64 bit Cygwin.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Bump GPLv2+ to GPLv3+ for some files, clarify BSD 2-clause.
Everything else stays under GPLv3+.
New Linking Exception exempts resulting executables from LGPLv3 section 4.
Add CONTRIBUTORS file to keep track of licensing.
Remove 'Copyright Red Hat Inc' comments.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
u_char, u_short, u_int, u_long are BSD-only types. Remove them from
Cygwin headers which are supposed to be used in a non-BSD scenario.
Drop special Cygwin handling of those types in sys/types.h.
newlib:
* libc/include/sys/types.h (u_char,u_short,u_int,u_long): Drop
Cygwin exception.
cygwin:
* fhandler_socket.cc (fhandler_socket::ioctl): Accommodate change
in include/asm/socket.h. Continue using u_long since that's the
MS type here.
* include/asm/socket.h: Since the type given in _IOR/_IOW macros
is only used for its sizeof, replace u_long with equivalent long.
* netdb.h (getnetbyaddr): Fix prototype.
* netinet/ip.h: Replace old BSD-only types with generically defined
old BSD types (u_char -> u_int8_t, etc).
* netinet/tcp.h: Ditto.
* netinet/udp.h: Ditto.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Add sec_posixacl.o.
(SUBLIBS): Add libacl.a
(libacl.a): New rule to create libacl.a.
* common.din: Export POSIX ACL functions as well as most libacl.a
extensions.
* fhandler.h (fhander_base::acl_get): New prototype.
(fhander_base::acl_set): Ditto.
(fhandler_disk_file::acl_get): Ditto.
(fhandler_disk_file::acl_set): Ditto.
* include/acl/libacl.h: New file.
* include/cygwin/version.h: Bump API minor version.
* include/sys/acl.h: Drop including cygwin/acl.h. Accommodate
throughout Cygwin. Add POSIX ACL definitions.
* sec_acl.cc: Include sec_posixacl.h. Replace ILLEGAL_UID and
ILLEGAL_GID with ACL_UNDEFINED_ID where sensible.
(__aclcheck): New internal acl check function to be used for
Solaris and POSIX ACLs.
(aclcheck32): Call __aclcheck.
(__aclcalcmask): New function to compute ACL_MASK value.
(__aclsort): New internal acl sort function to be used for Solaris
and POSIX ACLs.
(aclsort32): Call __aclsort.
(permtostr): Work directly on provided buffer.
(__acltotext): New internal acltotext function to be used for
Solaris and POSIX ACLs.
(acltotext32): Call __acltotext.
(__aclfromtext): New internal aclfromtext function to be used for
Solaris and POSIX ACLs.
(aclfromtext32): Call __aclfromtext.
* sec_posixacl.cc: New file implemeting POSIX ACL functions.
* sec_posixacl.h: New internal header.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (fhandler_base::get_plain_ino): New inline method.
Add comment to explain what it's supposed to be used for.
* fhandler_socket.cc (fhandler_socket::get_proc_fd_name): Create
filename using inode number.
(fhandler_socket::fstat): Generate inode number from filename if
ino is not set (that's the case in a stat(2) call).
* pipe.cc: Throughout, use get_plain_ino when appropriate.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_base): Convert unique_id to int64_t.
(fhandler_base::set_ino): New protected inline method.
(fhandler_base::get_unique_id): Convert to int64_t.
(fhandler_base::set_unique_id): New inline method taking int64_t.
(fhandler_pipe::fstat): Declare.
(fhandler_pipe::init): Take extra parameter.
(fhandler_pipe::create): Ditto.
* fhandler_socket.cc (fhandler_socket::init_events): Set inode number
to serial number.
(fhandler_socket::fstat): Set device to DEV_TCP_MAJOR. Create st_ino
from get_ino.
* include/cygwin/signal.h (struct _sigcommune): Replace
_si_pipe_fhandler with _si_pipe_unique_id.
* pinfo.h (_pinfo::pipe_fhandler): Take unique id instead of HANDLE.
* pinfo.cc (commune_process): Accommodate change to _si_pipe_unique_id.
(_pinfo::commune_request): Ditto.
(_pinfo::pipe_fhandler): Ditto.
* pipe.cc (fhandler_pipe::init): Take unique id as argument and set
inode number and unique_id from there.
(fhandler_pipe::open): Rework to find any matching pipe from unique
id in filename.
(fhandler_pipe::get_proc_fd_name): Create filename using inode number.
(fhandler_pipe::create): Generate and return unique id from process pid
and pipe_unique_id. In outer method, call init with additional unique
id as parameter.
(fhandler_pipe::fstat): New method.
(pipe_worker): Accommodate using 64 bit inode number in filename.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* cygtls.h (_cygtls::wait_signal_arrived): Renamed from
set_signal_arrived.
(_cygtls::set_signal_arrived): New function signalling signal_arrived.
(_cygtls::reset_signal_arrived): Don't reset will_wait_for_signal.
(_cygtls::unwait_signal_arrived): New function only resetting
will_wait_for_signal.
(class wait_signal_arrived): Rename from set_signal_arrived.
Accommodate name change throughout Cygwin.
(wait_signal_arrived::~wait_signal_arrived): Call
_cygtls::unwait_signal_arrived. Add comment.
* cygserver_ipc.h (ipc_set_proc_info): Fetch signal_arrived handle
via call to _cygtls::get_signal_arrived.
* exceptions.cc (_cygtls::interrupt_setup): Signal signal_arrived via
call to _cygtls::set_signal_arrived.
(_cygtls::handle_SIGCONT): Ditto.
* fhandler_socket.cc (fhandler_socket::wait_for_events): Generate
WSAEVENT array prior to entering wait loop. Add cancel event object
if available. Remove calls to pthread_testcancel and just call
pthread::static_cancel_self if the cancel event object is signalled.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
- New, unified implementation of POSIX permission and ACL handling. The
new ACLs now store the POSIX ACL MASK/CLASS_OBJ permission mask, and
they allow to inherit the S_ISGID bit. ACL inheritance now really
works as desired, in a limited, but theoretically equivalent fashion
even for non-Cygwin processes.
To accommodate Windows default ACLs, the new code ignores SYSTEM and
Administrators group permissions when computing the MASK/CLASS_OBJ
permission mask on old ACLs, and it doesn't deny access to SYSTEM and
Administrators group based on the value of MASK/CLASS_OBJ when
creating the new ACLs.
The new code now handles the S_ISGID bit on directories as on Linux:
Setting S_ISGID on a directory causes new files and subdirs created
within to inherit its group, rather than the primary group of the user
who created the file. This only works for files and directories
created by Cygwin processes.
2015-05-29 Corinna Vinschen <corinna@vinschen.de>
Reapply POSIX ACL changes.
* utils.xml (setfacl): Show new option output.
(getfacl): Show new option output.
* sec_acl.cc (get_posix_access): Check for Cygwin "standard" ACL.
Apply umask, if so. Align comments.
* security.cc (set_created_file_access): Fix permission masking by
incoming requested file mode.
* sec_acl.cc (set_posix_access): Apply mask only in terms of execute bit
for SYSTEM and Admins group.
* sec_acl.cc (set_posix_access): Don't create DENY ACEs for USER and
GROUP entries if they are the same as USER_OBJ or GROUP_OBJ.
* fhandler.h (fhandler_pty_slave::facl): Add prototype.
* fhandler_tty.cc (fhandler_pty_slave::facl): New method.
(fhandler_pty_slave::fchown): Fix uid/gid handling.
* sec_acl.cc (set_posix_access): Drop superfluous class_idx variable.
Simplify and move around code in a few places. To improve ACL
readability, add r/w permissions to Admins ACE appended to pty ACL.
Add comment to explain Windows ACE Mask filtering being in the way of
creating a real CLASS_OBJ.
(get_posix_access): Fake CLASS_OBJ for ptys. Explain why.
* security.cc (get_object_attribute): Add S_IFCHR flag to attributes
when calling get_posix_access.
* sec_acl.cc (set_posix_access): Move merging group perms into owner
perms in case of owner == group after mask has been computed. Take
mask into account when doing so to avoid unnecessary ACCESS_DENIED_ACE.
* sec_acl.cc (get_posix_access): Only set saw_group_obj flag if we saw
the ACCESS_ALLOWED_ACE.
* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Deliberatly
set GROUP_OBJ and CLASS_OBJ perms to new group perms. Add comment
to explain why.
* security.cc (set_created_file_access): Ditto.
* sec_acl.cc (set_posix_access): Replace previous patch. Return
EINVAL if uid and/or guid is invalid and not backed by an actual
Windows account.
* sec_acl.cc (set_posix_access): Workaround owner/group SIDs being NULL.
* sec_acl.cc (set_posix_access): Handle files with owner == group.
Rephrase switch statement checking against unfiltered a_type value.
(get_posix_access): Handle files with owner == group.
* sec_acl.cc (get_posix_access): Don't use GROUP_OBJ access to fix up
CLASS_OBJ mask on old-style ACLs. Fix a comment.
* sec_acl.cc (set_posix_access): Always make sure Admins have
WRITE_DAC and WRITE_OWNER permissions.
* security.h (create_object_sd_from_attribute): Drop handle parameter
from prototype.
* security.cc (create_object_sd_from_attribute): Drop handle parameter.
Just create the standard POSIXy security descriptor.
(set_object_attribute): Accommodate dropped paramter in call to
create_object_sd_from_attribute.
* fhandler_tty.cc: Ditto, throughout.
* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Fix typo in
mask computation.
* fhandler.cc (fhandler_base::open_with_arch): Call open with mode
not umasked.
(fhandler_base::open): Explicitely umask mode on NFS here. Call new
set_created_file_access rather than set_file_attribute.
* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Reimplement
setting permissions on filesystems supporting ACLs using the new
set_posix_access call.
(fhandler_disk_file::fchown): Ditto.
(fhandler_disk_file::mkdir): Call new set_created_file_access rather
than set_file_attribute.
* fhandler_socket.cc (fhandler_socket::bind): Don't umask here. Add
WRITE_OWNER access to allow writing group in case of SGID bit set.
Call new set_created_file_access rather than set_file_attribute.
* path.cc (symlink_worker): Call new set_created_file_access rather
than set_file_attribute.
* sec_acl.cc (searchace): Un-staticize.
(set_posix_access): New, complementary functionality to
get_posix_access.
(setacl): Implement in terms of get_posix_access/set_posix_access.
(get_posix_access): Add handling for just created files requiring
their first Cygwin ACL. Fix new_style recognition. Handle SGID
bit. For old-style ACLs, ignore SYSTEM and Administrators when
computing the {DEF_}CLASS_OBJ perms.
* security.cc (get_file_sd): Revamp comment. Change and (hopefully)
speed up inheritance processing for just created files.
(alloc_sd): Remove.
(set_security_attribute): Call set_posix_access instead of alloc_sd.
(get_object_attribute): Fix return value.
(create_object_sd_from_attribute): Call set_posix_access instead of
alloc_sd.
(set_file_attribute): Remove.
(set_created_file_access): New function implemented in terms of
get_posix_access/set_posix_access.
* security.h (set_file_attribute): Remove prototype.
(set_created_file_access): Add prototype.
(searchace): Ditto.
(set_posix_access): Ditto.
* syscalls.cc (open): Call open_with_arch with mode not umasked.
* sec_acl.cc: Change preceeding comment explaining new-style ACLs.
Describe how to generate deny ACEs in more detail. Accommodate the
fact that a NULL deny ACE is used for {DEF_}CLASS_OBJ, rather than
a special Cygwin ACE. Improve further comments.
(CYG_ACE_NEW_STYLE): Define.
(get_posix_access): Change from Cygwin ACE to NULL deny ACE. Fix
CLASS_OBJ handling to generate CLASS_OBJ and DEF_CLASS_OBJ from a single
NULL deny ACE if the inheritance flags say so.
* sec_helper.cc (well_known_cygwin_sid): Remove.
* security.h (well_known_cygwin_sid): Drop declaration.
* sec_acl.cc (CYG_ACE_ISBITS_TO_WIN): Fix typo.
(get_posix_access): Rename index variable from i to idx. Define only
once at top level.
* security.cc (add_access_allowed_ace): Drop unused parameter "offset".
Accommodate throughout.
(add_access_denied_ace): Ditto.
* sec_acl.cc: Accommodate above change throughout.
* security.h (add_access_allowed_ace): Adjust prototype to above change.
(add_access_denied_ace): Ditto.
* sec_acl.cc (get_posix_access): Handle multiple ACEs for the
owner and primary group of the file. Handle the default primary
group ACE as DEF_GROUP_OBJ entry if the directory has the S_ISGID bit
set. Add comments. Minor code rearrangements.
Preliminary read side implementation of new permission handling.
* acl.h (MAX_ACL_ENTRIES): Raise to 2730. Add comment to explain.
* sec_acl.cc: Add leading comment to explain new ACL style.
Add definitions and macros to use for bits in new Cygwin ACL.
(DENY_RWX): New mask value for all temporary deny bits.
(getace): Add bool parameter to decide when leaving all bits intact,
rather than filtering them per the already set bits.
(get_posix_access): New function, taking over functionality to read
POSIX ACL from SECURITY_DESCRIPTOR.
(getacl): Just call get_posix_access.
* sec_helper.cc (well_known_cygwin_sid): Define.
* security.cc (get_attribute_from_acl): Remove.
(get_info_from_sd): Remove.
(get_reg_sd): Call get_posix_access instead of get_info_from_sd.
(get_file_attribute): Ditto.
(get_object_attribute): Ditto.
* security.h (well_known_cygwin_sid): Declare.
(get_posix_access): Add prototype.
* Throughout, use simpler ACE macros from Windows' accctrl.h.
* getfacl.c (main): Special-case SYSTEM and Admins group. Add comments.
* setfacl.c: Align more to Linux tool.
(delacl): New function to delete acl entries only.
(modacl): Drop delete functionality. Add handling of recomputing the
mask and default mask values.
(delallacl): Rename from delacl.
(setfacl): Call delacl in Delete case. Call delallacl in DeleteAll
and DeleteDef case.
(usage): Accommodate new options. Rearrange and rephrase slightly.
(longopts): Emit 'x' in --delete case. Add --no-mask and --mask
options.
(opts): Add -x and -n options.
(main): Handle -d and -x the same. Handle -n and --mask options.
Drop handling for -r option.
* getfacl.c (usage): Align more closely to Linux version. Add new
options -c, -e, -E. Change formatting to accommodate longer options.
(longopts): Rename --noname to --numeric. Keep --noname for backward
compatibility. Add --omit-header, --all-effective and --no-effective
options.
(opts): Add -c, -e and -E option.
(main): Handle new -c, -e, and -E options.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (LOCK_EVENTS): Don't enter critical section with
invalid mutex handle since then socket has been closed.
(UNLOCK_EVENTS): Close critical section.
(fhandler_socket::evaluate_events): Handle calling connect on shutdown
socket.
(fhandler_socket::wait_for_events): Try for pthread_testcancel in case
of WAIT_FAILED. Try to come up with a better errno in case we waited
on an invalid handle.
(fhandler_socket::release_events): Change wsock_mtx and wsock_evt to
NULL under lock to avoid accessing invalid handle.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
setting connect_state to connect_credxchg.
(fhandler_socket::af_local_accept): Ditto.
(fhandler_socket::recv_internal): Drop ill-advised connect_state check.
Add comment so as not to repeat the exercise.
* fhandler.h (enum conn_state): Drop now unneeded connect_credxchg
state.
connect_pending only on unconnected socket. Set connect_state to
connected on WSAEISCONN error. Set connect_state to connect_failed
on any other error except WSAEWOULDBLOCK if connect is still pending.
Add lots of comment to explain why all of the above.
initial handshake on AF_LOCAL sockets.
* fhandler.h (class fhandler_socket): Add no_getpeereid status flag.
(fhandler_socket::af_local_set_no_getpeereid): New prototype.
* fhandler_socket.cc (fhandler_socket::af_local_connect): Skip handshake
if no_getpeereid is set. Add debug output.
(fhandler_socket::af_local_accept): Likewise.
(fhandler_socket::af_local_set_no_getpeereid): New function.
(fhandler_socket::af_local_copy): Copy no_getpeereid.
(fhandler_socket::getpeereid): Fail if no_getpeereid is set.
* net.cc (cygwin_setsockopt): Add SO_PEERCRED for AF_LOCAL/SOCK_STREAM
sockets. Add comment to explain why we need it.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
comment.
(fhandler_socket::evaluate_events): Only set connect_state and call
af_local_connect if connect_state is connect_pending. Explain why.
Drop redundant test for socket family and type.
(fhandler_socket::connect): Extend comment.
connect_state and af_local_connect connect call here, once, independent
of FD_CONNECT being requested. Add comment to explain why.
(fhandler_socket::connect): Drop connect_state handling and calling
af_local_connect. Move remaining AF_LOCAL stuff prior to calling
::connect and explain why. Simplify error case.
* poll.cc (poll): Handle connect state independently of POLLOUT being
requested for the descriptor to allow setting POLLIN if connect failed.
Add comment.
* select.cc (set_bits): Drop connect_state and AF_LOCAL handling here.
handler.
* cygtls.cc (_cygtls::remove): Accommodate the fact that pathbufs
has been moved from _local_storage to _cygtls.
* cygtls.h (class tls_pathbuf): Add comment to hint to gendef usage
of counters. Change type of counters to uint32_t for clarity.
Remove _cygtls as friend class.
(struct _local_storage): Move pathbufs from here...
(struct _cygtls): ...to here, allowing to access it from _sigbe.
(class san): Only define on 32 bit. Remove errno, _c_cnt and _w_cnt
members.
(san::setup): Drop parameter. Don't initialize removed members.
(san::leave): Don't set removed members.
(class myfault): Only define on 32 bit.
(myfault::faulted): Only keep implementation not taking any parameter.
Drop argument in call to sebastian.setup.
(__try/__leave/__except/__endtry): Implement to support real SEH. For
now stick to SJLJ on 32 bit.
* dcrt0.cc (dll_crt0_0): Drop 64 bit call to
exception::install_myfault_handler.
* exception.h (exception_handler): Define with EXCEPTION_DISPOSITION
as return type.
(PDISPATCHER_CONTEXT): Define as void * on 32 bit. Define as pointer
to _DISPATCHER_CONTEXT on 64 bit.
(class exception): Define separately for 32 and 64 bit.
(exception::myfault): Add handler for myfault SEH handling on 64 bit.
(exception::exception): Fix mangled method name to account for change
in type of last parameter.
(exception::install_myfault_handler): Remove.
* exceptions.cc (exception::myfault_handle): Remove.
(exception::myfault): New SEH handler for 64 bit.
* gendef (_sigbe): Set tls_pathbuf counters to 0 explicitely when
returning to the caller.
* ntdll.h: Move a comment to a better place.
(struct _SCOPE_TABLE): Define on 64 bit.
* thread.cc (verifyable_object_isvalid): Remove gcc 4.7 workaround.
* tls_pbuf.cc (tls_pbuf): Fix to accommodate new place of pathbufs.
(tls_pathbuf::destroy): Change type of loop variables to uint32_t.
* tls_pbuf.h (class tmp_pathbuf): Change type of buffer counters to
uint32_t. Accommodate new place of pathbufs.
* tlsoffsets.h: Regenerate.
* tlsoffsets64.h: Regenerate.
(class fhandler_socket): Grant another bit to connect_state flag.
* fhandler_socket.cc (fhandler_socket::af_local_connect): Rearrange
variable definition. Set connect_state to connect_credxchg.
(fhandler_socket::af_local_accept): Ditto.
(fhandler_socket::recv_internal): Accept connect_credxchg on connection
oriented AF_LOCAL sockets as well to allow the credential exchange.
Extend comment to explain.
handles are kernel objects since Windows 8.
* fhandler.h (enum conn_state): Add "listener" state.
(class fhandler_socket): Drop listener status flag.
(fhandler_socket::lseek): Return -1 and errno ESPIPE.
(fhandler_serial::lseek): Ditto.
* fhandler_socket.cc (fhandler_socket::listen): Set connect_state to
listener. Add comment.
(fhandler_socket::accept4): Explicitely check if the socket is listening
and fail with EINVAL, if not. Explain why we have to do that.
(fhandler_socket::recv_internal): Explicitely check if the socket is
connected if it's a stream socket. Explain why we have to do that.
(fhandler_socket::getpeereid): Drop now redundant test.