Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
net: dummy byte in WriteMsgUnix breaks unixgram protocols #6476
What steps will reproduce the problem? https://groups.google.com/d/topic/golang-nuts/PyOeimgyvFw/discussion WriteMsgUnix always sends a dummy normal byte if one tries to send only out-of-band/ancillary data (e.g. a file descriptor), because ReadMsgUnix doesn't receive oob-only writes (it just blocks) on stream sockets. This was done based on prior art: https://git.gitorious.org/libancillary/libancillary.git http://svn.python.org/projects/python/branches/release32-maint/Modules/_multiprocessing/multiprocessing.c and discussions: https://groups.google.com/d/msg/golang-dev/Rkwgwug2OpI/7YYunK4Z9NUJ https://golang.org/cl/2331044#msg12 However, it turns out that you can send oob-only messages on a datagram socket. systemd implements a datagram socket protocol for talking to its journal to exchange file descriptors of temporary files containing messages that are too long to send via the datagram socket directly. systemd doesn't expect the dummy byte and returns an error if it is present. Removing the dummy byte will cause this test with a stream socket to hang: http://play.golang.org/p/ebLI7mwBPF but this test with a datagram socket still works: http://play.golang.org/p/q-eWEP3_96 which is expected, because systemd has a test for this scenario. Which version are you using? (run 'go version') tip Please provide any additional information below. systemd code: http://cgit.freedesktop.org/systemd/systemd/tree/src/journal/journal-send.c#n345 http://cgit.freedesktop.org/systemd/systemd/tree/src/journal/journald-server.c#n1197 http://cgit.freedesktop.org/systemd/systemd/tree/src/journal/test-journal-send.c#n48 systemd test output shows that the test passes: https://gist.github.com/philips/1938c88d544e49f40889/raw/cf64b66c261aee63c0476b28a32e448ecb2d5b60/gistfile1.txt
Or one might argue that the standard library has no business ever adding a dummy byte. One might consider panicking if anyone does WriteMsgUnix(nil, oob), but maybe it works if one does: WriteMsgUnix(data, nil) WriteMsgUnix(nil, oob) WriteMsgUnix(data, nil) on a stream socket. Need to check that.