Re: Unix-domain sockets - abstract addresses

kuznet@ms2.inr.ac.ru
Thu, 8 Aug 2002 22:36:38 +0400 (MSD)


Hello!

> According to the man page 'unix(7)':
> When a socket is connected and it doesn't already have a local address a
> unique address in the abstract namespace will be generated automatically.

This is wrong. The address is not autogenerated unless SO_PASSCRED
is requested by security&compatibility reasons.
So, if the socket is SOCK_DGRAM it is anounymous and "send-only",
it is impossible to reply to it.

> but I have seen 0x0BA5, 0x7FA8, 0x1FA8 and others).

Yes, this is bug. The fix is enclosed. It should return nil address.

> So, the question is: which is right? The man page, or af_unix.c?

Both of them are wrong.

Alexey

--- af_unix.c.orig Thu Aug 8 22:23:56 2002
+++ af_unix.c Thu Aug 8 22:34:58 2002
@@ -1432,7 +1432,7 @@

static void unix_copy_addr(struct msghdr *msg, struct sock *sk)
{
- msg->msg_namelen = sizeof(short);
+ msg->msg_namelen = 0;
if (sk->protinfo.af_unix.addr) {
msg->msg_namelen=sk->protinfo.af_unix.addr->len;
memcpy(msg->msg_name,
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/