[PATCH 2/2] Add APIs to send file descriptors through the network

Keith Packard keithp at keithp.com
Fri Nov 1 23:08:55 CET 2013


Mark Kettenis <mark.kettenis at xs4all.nl> writes:

> Keith.  This implementation isn't quite right as it doesn't use the
> proper CMSG_ macros to manipulate the ancillary data object
> information.  You get way with this on Linux, because it deviates from
> POSIX and declares the cmsg_len member as size_t, which means no
> additional padding between the cmsghdr and the data array is
> necessary.  But on other systems this code won't work.  Attached is an
> (untested) diff that should fix this.  If you didn't do so yet, please
> read appendix A of RFC 3542, which has a decent description of the
> API.

Yeah, I'm afraid that API didn't make any sense to me, so I just made it
work in the only environment I had available. If you've got something
that works differently and can test it, please send patches along.

> I also believe the handling of MSG_TRUNC and MSG_CTRUNC isn't correct,
> and will result in leaked file descriptors.  If I read the Linux
> kernel code correctly MSG_CTRUNC gets set when there is not enough
> room to store all filedescriptors.

The upper levels of the code are careful to not send more descriptors
than the other end is willing to accept, so yeah, treating these cases
as errors (to the point of just closing the client connection) would be
sufficient.

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20131101/b354a790/attachment.pgp>


More information about the xorg-devel mailing list