4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-09 02:29:07 +08:00

13 Commits

Author SHA1 Message Date
Ken Brown
953308f403 Cygwin: AF_UNIX: update tests 2020-12-28 14:01:30 -05:00
Ken Brown
56fc7c1f2e Cygwin: AF_UNIX: update tests
The previous test, send_tty, didn't really exercise the new
fhandler_pty_slave::dup code, since the descriptor that was sent was
for a pty slave already open in the subprocess.  So it already had an
archetype, and no handles were duplicated.

Replace it by a new test, send_pty_slave, that does exercise the new
code (successfully).
2020-12-15 11:48:04 -05:00
Ken Brown
830ae651d3 Cygwin: AF_UNIX: update tests
Add test for sending a tty.
2020-12-11 17:41:06 -05:00
Ken Brown
5fba23a0fe Cygwin: AF_UNIX: socket_tests: update README.txt 2020-11-28 09:40:16 -05:00
Ken Brown
816c8dfecd Cygwin: AF_UNIX: update tests
There's now a (successful) test of sending socket descriptors.
2020-11-25 15:32:03 -05:00
Ken Brown
0dac3caaf5 Cygwin: AF_UNIX: update tests 2020-11-21 08:01:10 -05:00
Ken Brown
e8b866676f Cygwin: AF_UNIX: add serialization/deserialization for fhandlers
Define static helper functions serialize/deserialize in
fhandler_socket_unix.cc.  These will be used to support sending file
descriptors via SCM_RIGHTS control messages.

The serialize function creates an 'fh_ser' structure that contains a
copy of the fhandler associated with the file descriptor, with all
allocated memory freed.  The structure also contains the Windows pid
of the current process, which deserialize can use for duplicating
handles.

The deserialize function reconstructs an fhandler from an fh_ser
structure, with the handles duplicated into its own process.

For now, serialization and deserialization are fully implemented only
for disk files, and even in that case there are many FIXMEs that need
attention.
2020-11-17 14:42:01 -05:00
Ken Brown
426976b01a Update tests 2020-11-17 09:21:05 -05:00
Ken Brown
6da65394a3 Cygwin: AF_UNIX: update tests 2020-11-01 21:58:34 -05:00
Ken Brown
852fb2afba Cygwin: AF_UNIX: allow more than one control message
Previously, create_cmsg_data and evaluate_cmsg_data required the
ancillary data to contain only a single control message, of type
SCM_CREDENTIALS.  In preparation for supporting SCM_RIGHTS in the
future, allow more than one.

create_cmsg_data now iterates through the specified control messages
and allows both SCM_CREDENTIALS and SCM_RIGHTS.  If no SCM_CREDENTIALS
message is present, it creates one.  This was previously done in
sendmsg.

evaluate_cmsg_data also iterates through the received control messages
and allows both SCM_CREDENTIALS and SCM_RIGHTS.  Control messages of
type SCM_CREDENTIALS are discarded unless the SO_PASSCRED option has
been set.

Update tests.
2020-11-01 15:58:00 -05:00
Ken Brown
c69c850df4 Cygwin: AF_UNIX: sendmsg: always send credentials
If the caller doesn't specify ancillary data, add credentials to the
outgoing packet.

This enables us to satisfy the requirement
(https://man7.org/linux/man-pages/man7/unix.7.html) that a socket with
the SO_PASSCRED option enabled can get the credentials of its peer in
every message it receives.

FIXME: I'm not sure if this is the right way to satisfy that
requirement.  A possible alternative would be to arrange for a socket
to be notified when its peer enables SO_PASSCRED.
2020-10-29 10:14:34 -04:00
Ken Brown
20fd0db075 Cygwin: AF_UNIX: create_cmsg_data: fix credential checking
Require the pid specified by an administrator to be the pid of an
existing process.
2020-10-29 09:17:38 -04:00
Ken Brown
a4f00ed42f Cygwin: AF_UNIX: add winsup/cygwin/socket_tests 2020-10-26 17:43:43 -04:00