Corinna Vinschen
de29476ed5
Cygwin: AF_UNIX: use get_unique_id to create pipe name
...
It's the same as get_plain_ino in this case, but it's cleaner
and easier to understand.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-11 14:54:20 +01:00
Corinna Vinschen
4f1ee1a3e7
Cygwin: AF_UNIX: fix dup
...
Reorder so fhandler_socket::dup is called first. Add missing
duplication of backing_file_handle.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-10 21:12:27 +01:00
Corinna Vinschen
7b1028974b
Cygwin: AF_UNIX: Add fixup_after_exec method
...
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-10 21:09:28 +01:00
Corinna Vinschen
1bb3d65182
Cygwin: AF_UNIX: fix creating abstract socket symlink name
...
Add missing NUL termination when creating symlink representing
abstract socket.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-10 21:07:46 +01:00
Corinna Vinschen
8b6804b8a8
Cygwin: don't skip O_TMPFILE files in readdir
...
Bad idea. A file hidden from directory listings is not seen by
rm either, so it never calls unlink for the file and a recursive
removal of the parent directory fails with "directory not empty".
Fix comments accordingly.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-09 21:13:28 +01:00
Corinna Vinschen
b194d65615
Cygwin: AF_UNIX: Implemant socketpair
...
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-09 14:19:36 +01:00
Corinna Vinschen
f4a1a186f9
Cygwin: fix socketpair prototype
...
Last parameter is a vector of 2 ints, not a pointer to int
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-09 14:17:39 +01:00
Thomas Wolff
e4c65b2e91
describe new locale modifier @cjkwide for user guide
2018-03-08 08:14:39 +01:00
Corinna Vinschen
7d525c171f
Cygwin: AF_UNIX: implement getsockopt SO_RCVBUF/SO_SNDBUF
...
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 21:56:42 +01:00
Corinna Vinschen
483cbf8954
Cygwin: AF_UNIX: define AF_UNIX_CONNECT_TIMEOUT
...
Use macro AF_UNIX_CONNECT_TIMEOUT instead of numerical constant
for connect timeout.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 21:55:34 +01:00
Corinna Vinschen
2f48ddb1ca
Cygwin: Define FSCTL_PIPE_FLUSH
...
This fsctl might come in handy at one point...
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 21:54:46 +01:00
Corinna Vinschen
5bb4cc1e6c
Cygwin: AF_UNIX: Implement read, readv, recvfrom, write, writev, sendto
...
All of these functions just call recvfrom/sendmsg which are still TODO
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 21:53:56 +01:00
Corinna Vinschen
d7f7d292d8
Cygwin: reorder read/write calls in fhandler_socket_unix
...
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 21:52:29 +01:00
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
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
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
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