Commit Graph

18587 Commits

Author SHA1 Message Date
Corinna Vinschen 855e5d7e14 Cygwin: AF_UNIX: fix accept behaviour
* Use correct cygwait/WFSO invocation to not die on cancel and signals
  uncontrolled.
* Manage io handles under io_lock.
* Copy peer address to user space under SEH to avoid a resource leak.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 16:23:44 +01:00
Corinna Vinschen cde2648c22 Cygwin: AF_UNIX: make sure connect wait thread is cleanly interruptible
Using TerminateThread potentially leaks resources.  In our case,
the connect wait thread may be forcefully terminated after
having successfully opened a client side pipe handle.  If this
occurs, we have a stale pipe server instance, so the pipe will
never be closed as long as the process lives.

Avoid this by changing the npfs handle to non-blocking, so we can
wait on a termination event object from inside the thread itself
and cleanly exit from the thread instead of terminating.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 16:19:43 +01:00
Corinna Vinschen 27a63d4ef2 Cygwin: AF_UNIX: some pipe errors may have multiple status codes
Depending on the exact circumstances, some erros are indicated
by different status codes.  Add helper macros to handle them
together.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 16:12:55 +01:00
Corinna Vinschen 4de52a0fe1 Cygwin: AF_UNIX: fix SEGV when sending an empty socket name from connect
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 16:08:15 +01:00
Corinna Vinschen 2f2a75b7bb Cygwin: AF_UNIX: fix creation of npfs handle
The handle to the device is never needed.  As the name impies,
FSCTL_PIPE_WAIT works on the file system, not on the device level.

Drop opening the device and make sure to open only one handle to NPFS.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 16:06:57 +01:00
Corinna Vinschen d69bcdd671 Cygwin: AF_UNIX: Add create_event helper and use throughout
Minimize overhead in creating a nameless event object.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 16:04:26 +01:00
Corinna Vinschen e94fa4ebf3 Cygwin: AF_UNIX: fix comments and move a macro
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 15:43:26 +01:00
Corinna Vinschen 4cd57934be Cygwin: AF_UNIX: Implement listen, accept4, connect, and others
* Implement helper functions
* Improve bind
* Implement setting blocking, ioctl(FIONBIO), fcntl(F_SETFL)
* Implement close_on_exec and fixup_after_fork
* Allow overriding sun_path and peer_sun_path
* Improve comments

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-06 19:10:54 +01:00
Corinna Vinschen e2909e2805 Cygwin: AF_UNIX: fix a couple of thinkos and typos
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-06 18:42:12 +01:00
Corinna Vinschen cabfef78e9 Cygwin: AF_UNIX: create/open pipes relativ to NPFS rootdir handle
Only store and manipulate pipe basename.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-06 18:37:09 +01:00
Corinna Vinschen c502700231 Cygwin: AF_UNIX: initialize rmem/wmem to 256K and use in pipe creation
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-06 18:28:15 +01:00
Corinna Vinschen c0df506b83 Cygwin: ntdll.h: Add some missing pipe-related definitions
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-06 18:24:13 +01:00
Corinna Vinschen f6ce72e623 Cygwin: sys/socket.h: define MSG_CMSG_CLOEXEC
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-06 18:23:48 +01:00
Corinna Vinschen 6d2f1d79a8 Cygwin: export hires counter ntod
Needed it new AF_UNIX socket code

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-06 18:23:23 +01:00
Sebastian Huber f641474cb2 RTEMS: Use int for _CLOCKID_T_
Linux and FreeBSD use int as well.  In addition, this fixes an Ada
incompatiblity problem on 64-bit targets.  See also GCC:

  gcc/ada/libgnarl/s-osinte__rtems.ads

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-03-06 11:40:16 +01:00
Sebastian Huber a9c8434527 Make _CLOCKID_T_ system configurable
Let systems optionally provide the _CLOCKID_T_ type via
<machine/_types.h>.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-03-06 11:40:16 +01:00
Corinna Vinschen ae67198d55 Cygwin: move sun_name_t constructors into fhandler_socket_unix.cc
They are only used there anyway and it allows to use the AF_UNIX
macro without tweaking header files.  While at it, improve
both constructors.  The default constructor now creates the name
of an unnamed socket, the constructor taking parameters carefully
checks its input.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-05 18:08:47 +01:00
Corinna Vinschen a2c02d78be Cygwin: sockets: add bind state, and split out connect state to allow atomic operation
The connect state was stored in a bitfield which is not safe
to do atomic operations on.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-05 17:59:04 +01:00
Corinna Vinschen fe8e2c9b1f Cygwin: drop debug_printf statement from start_transaction
start_transaction is now defined in ntdll.h and we can't rely
on debug_printf being available

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-05 17:50:52 +01:00
Corinna Vinschen 011fc3b508 Cygwin: cygwait.cc: fix formatting of debug statement
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-05 17:49:50 +01:00
Thomas Wolff f92f048528 Locale modifier @cjkwide to adjust ambiguous-width in non-CJK locales
Locale modifier @cjkwide makes Unicode "ambiguous width" characters
wide.  So ambiguous width characters can be enforced to have width 2
even in non-CJK locales. This gives e.g. users of "Powerline symbols"
the opportunity to adjust their width to the desired behaviour (and the
behaviour apparently expected by some tools) without having to set a CJK
locale and without losing consistence of terminal character width with
wcwidth/wcswidth locale width.
2018-03-05 17:15:12 +01:00
Corinna Vinschen df14d97fff Cygwin: AF_UNIX: drop try/except block in bind method
The caller already does it anyway.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 23:40:36 +01:00
Corinna Vinschen be6da79713 Cygwin: AF_UNIX: create pipes with file attribute R/W access
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 23:39:15 +01:00
Corinna Vinschen 00e8707830 Cygwin: accept4: Fix resource leak
The new implementation neglected to release the file descriptor
in case of error.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 23:33:05 +01:00
Corinna Vinschen 984c8beeff Cygwin: remove outdated comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 18:22:45 +01:00
Corinna Vinschen 97b7aaaeb7 Cygwin: fhandler_socket_unix: implement socket, bind, and close
...plus lots of helper functions.  Add comment to explain how everything
works.  This comment will be improved while implementing the yet missing
parts.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 18:17:17 +01:00
Corinna Vinschen 7d260cfac4 Cygwin: add transform_chars_af_unix helper
This function is going to be used for transposing sun_path of
abstract sockets.  This also adds a transposition of the NUL
character to tfx_chars since NUL-bytes in abstract socket names
are perfectly valid.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 18:17:17 +01:00
Corinna Vinschen 488221cf5c Cygwin: small_s[w]printf: add '_' modifier to print lower case hex digits
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 18:17:17 +01:00
Corinna Vinschen 1949db7829 Cygwin: drop CYGWIN_SOCKET_UUID, define CYGWIN_SOCKET_GUID as GUID pointer
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 18:17:13 +01:00
Corinna Vinschen d87ef0dac9 Cygwin: ntdll.h: add definitions required for pipe-based AF_UNIX
Also remove redundant declaration of RtlInitEmptyUnicodeString

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 18:08:05 +01:00
Our Air Quality b7520b14d5 Add global stdio streams support for reent small. 2018-03-01 18:05:31 -05:00
Corinna Vinschen dc3928fc75 Cygwin: convert sun_name_t into class
Add constructors and new/delete operators to make sure sun_name_t
objects are allocated on the cygheap.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-01 18:14:23 +01:00
Corinna Vinschen aa467e6e33 Cygwin: add AF_UNIX reparse points to path handling
* check_reparse_point_target returns a path flag mask, rather than
  just 1.  Return PATH_SYMLINK | PATH_REP for symlinks and directory
  mount points, PATH_SOCKET | PATH_REP for AF_UNIX sockets.

* Define Cygwin AF_UNIX socket reparse tag and GUID in ntdll.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-01 16:54:57 +01:00
Corinna Vinschen 65267a9a34 Cygwin: move transaction helpers into ntdll.h
We'll need them elsewhere in future.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de
2018-03-01 16:51:12 +01:00
Corinna Vinschen 3e16fd6986 Cygwin: ntdll.h: drop macros available in mingw-w64 headers
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-01 16:50:41 +01:00
Corinna Vinschen 28cf818c2e Cygwin: path.cc: clean up includes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-01 16:44:09 +01:00
Corinna Vinschen 7ae89fe708 Cygwin: path_conv: rename is_rep_symlink to is_known_reparse_point
...in preparation of reusing this flag for other types of
reparse points, not only symlinks.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-01 16:41:45 +01:00
Corinna Vinschen a27a7752ec Cygwin: improve storage and handling of AF_UNIX socket path
Define new struct sun_name_t and use throughout internally.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-28 19:06:53 +01:00
Corinna Vinschen 892efccb25 Cygwin: fhandler_socket_unix: store peer credentials in ucred member
* Split out cygwin/_ucred.h file
* drop local credentials

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-28 19:01:29 +01:00
Corinna Vinschen 25ea6af172 Cygwin: cleanup header including within network-releated files
* 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>
2018-02-28 18:56:13 +01:00
Corinna Vinschen d02f3a1238 Cygwin: sockets: Fix fstat on unnamed sockets
Calling fhandler_socket::fstat from fhandler_socket::fstat recursively
is not a good idea...

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-27 15:30:13 +01:00
Corinna Vinschen fbdae2c216 Cygwin: reduce size of fhandler_cygdrive
fhandler_cygdrive has a size of 696 bytes on x86_64, while the next
biggest fhandler type, fhandler_pty_master, is 584 bytes.  The members
responsible for the size are private to opendir/readdir/closedir usage.
fhandler_disk_file stores private readdir data in DIR->__d_internal
instead.  Use equivalent method with fhandler_cygdrive.  This drops
the size to 464 bytes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-26 20:39:48 +01:00
Corinna Vinschen b995936ab5 Cygwin: sockets: Add missing cleanup if socket/socketpair creation fails
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-26 18:02:36 +01:00
Corinna Vinschen 4d75035244 Cygwin: fhandler_socket_unix: Tiny cleanup
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-26 17:58:46 +01:00
Corinna Vinschen d35bd22992 Cygwin: sockets: move type and proto checks into fhandler_socket classes
Encapsulation required

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-26 17:56:47 +01:00
Corinna Vinschen 1e5e44a9a5 Cygwin: fhandler_socket: define socketpair as virtual function
...in preparation of moving the type and protocol test into the
actual classes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-26 17:56:09 +01:00
David Macek 5b6cbef9e0 doc/faq-using.xml: Add BeyondTrust and Cylance to BLODA
Cylance:
- https://github.com/git-for-windows/git/issues/1244
- https://cygwin.com/ml/cygwin/2017-04/msg00238.html

BeyondTrust:
- https://cygwin.com/ml/cygwin/2017-04/msg00092.html
- https://cygwin.com/ml/cygwin/2017-05/msg00422.html
2018-02-23 21:35:39 +01:00
Corinna Vinschen c70761df66 Cygwin: Define SO_PASSCRED and SCM_CREDENTIALS
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 21:00:43 +01:00
Corinna Vinschen 7f7532fafb Cygwin: Create empty fhandler_socket_unix
* Make distinct from AF_LOCAL for testing purposes.  This will have
  to be reverted as soon as fhandler_socket_unix goes life.

* Move saw_reuseaddr flag back to fhandler_socket status

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 21:00:43 +01:00
Corinna Vinschen 5acadbe8af Cygwin: fix upcalls in some fhandler_socket_local methods
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 21:00:43 +01:00