Re: SO_PASSCRED broken in 2.4 ? - mystery tackled

From: Jakob Østergaard (jakob@ostenfeld.dtu.dk)
Date: Sat Jul 01 2000 - 17:50:00 EST


On Sat, 01 Jul 2000, I wrote:

...
> I have a program that uses the SO_PASSCRED socket option on a connected UNIX
> socket.
>
> This program works fine under 2.2, but under 2.4 I receive an EOPNOTSUPP when
> doing the recvmsg() call on the new socket after a client connects.
...

A wild guess based on some net/unix/af_unix.c reading turned out to provide
a workaround for my problem.

The client program did:
-----------------------------------
  /* Connect and get a host suggestion */
  antsd = socket(AF_UNIX, SOCK_STREAM, 0);
  if(antsd == -1)
    fail("Cannot create AF_UNIX socket");

  addr.sun_family = AF_UNIX;
  strcpy(addr.sun_path, ANTSD_SOCKET);
  
  rc = connect(antsd, (struct sockaddr*)&addr, sizeof(struct sockaddr_un));
  if(rc)
    fail("Cannot connect to antsd socket - antsd not running?");
----------------------------------

Which causes the server to recieve an EOPNOTSUPP upon recvmsg() with
the buffer for the ancillary SO_PASSCRED data.

However, the following ``fix'' can be applied:
------------------------------
...
  antsd = socket(AF_UNIX, SOCK_STREAM, 0);
...
  addr.sun_family = AF_UNSPEC; /* used to be AF_UNIX */
...
------------------------------

Now, dear networking gurus, why, oh why, can't I use AF_UNIX for AF_UNIX
sockets ?

Anyway, now this is in the archives, so if it isn't a programming error on my
part, a workaround is known. If I'm really doing something wrong (me? wrong? ;),
I should appreciate to be let in on it.

Best regards,

-- 
................................................................
: jakob@ostenfeld.dtu.dk  : And I see the elder races,         :
:.........................: putrid forms of man                :
:   Jakob Østergaard      : See him rise and claim the earth,  :
:        OZ9ABN           : his downfall is at hand.           :
:.........................:............{Konkhra}...............:

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Jul 07 2000 - 21:00:09 EST