Commit Graph

11700 Commits

Author SHA1 Message Date
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
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
Corinna Vinschen eaf359574d Cygwin: Introduce FH_SOCKET for generic socket file ops
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 19:45:59 +01:00
Corinna Vinschen b79018ee3a Cygwin: encapsulate Winsock based fhandler_socket classes
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>
2018-02-23 15:24:18 +01:00
Corinna Vinschen cc9fe2c716 Cygwin: eliminate unused fhandler method hclose
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 14:56:30 +01:00
Corinna Vinschen 7bcab422e5 Cygwin: fix fhandler_socket_local::fchmod
Rather than just returning 0, return the result of calling
the base class fchmod.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 13:34:08 +01:00
Corinna Vinschen b89b6f4349 Cygwin: socket.h: Add SIOCINQ, equivalent to FIONREAD
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 13:33:23 +01:00
Corinna Vinschen 03f380c2bc Cygwin: drop unused device nodes and clean up socket devices
* 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>
2018-02-23 13:32:51 +01:00
Corinna Vinschen b8a57a2d2a Cygwin: fhandler_socket: Move select functions into derived classes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-22 16:59:55 +01:00
Corinna Vinschen 479080baec Cygwin: fhandler_socket: Rearrange methods
Follow the same pattern in all fhandler_socket classes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-22 16:54:08 +01:00
Corinna Vinschen 9c593d9b39 Cygwin: fhandler_socket: Add derived fcntl methods
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-22 16:37:12 +01:00
Corinna Vinschen 79598f94f7 Cygwin: fhandler_socket: Add derived ioctl methods
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-22 16:31:07 +01:00
Corinna Vinschen 233bde3125 Cygwin: fhandler_socket: Move shutdown and close methods into derived classes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-22 16:28:14 +01:00
Corinna Vinschen 84c5e0fd3d Cygwin: make socketpair an AF_LOCAL-only method
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-22 16:25:28 +01:00
David Macek a3b5795b06 doc/ntsec.xml: Fix typo 2018-02-21 22:41:53 +01:00
Corinna Vinschen a5dfbc6940 Cygwin: inline get_socket_flags()
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-21 22:00:04 +01:00
Corinna Vinschen 8906a4d335 Cygwin: fix whitespaces in socket code
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-21 21:43:44 +01:00
Corinna Vinschen 859d215b7e Cygwin: split out fhandler_socket into inet and local classes
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>
2018-02-21 21:40:01 +01:00
Corinna Vinschen dff3bc9a86 Cygwin: net.cc: drop redundant declarations
Replace cygwin_inet_aton call with cygwin_inet_pton

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-20 18:14:57 +01:00
Corinna Vinschen ea1e5318d5 Cygwin: set/getsockopt: Move implementation into fhandler_socket class
This requires to export find_winsock_errno from net.cc.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-20 18:01:40 +01:00
Corinna Vinschen 044ab77dcc Cygwin: clean error mapping
- Move definition of windows to POSIX error mapping struct into
  cygerrno.h
- Move declaration of winsock errno functions to cygerrno.h
- Input to error mapping functions is DWORD

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-20 17:59:53 +01:00
Corinna Vinschen 0a3f4e6087 Cygwin: Make sure fraction of seconds constants enforce 64 bit computation
Dropping the 'LL' specifier leads to 32 bit truncation during timestamp
computation.  Revert it.  Exempt MSPERSEC which is used for 32 bit values.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-20 15:05:31 +01:00
Corinna Vinschen ea543d3ffa Cygwin: fix declaration of fhandler_socket::socketpair
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-16 17:34:57 +01:00
Corinna Vinschen 26bcedda20 Cygwin: fix utils path handling in case cygdrive path is just '/'
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-16 17:21:48 +01:00
Corinna Vinschen f881942d77 Cygwin: net: Improve standars conformance comments
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-16 16:57:24 +01:00