From owner-freebsd-arch Wed Jul 4 2: 2:40 2001 Delivered-To: freebsd-arch@freebsd.org Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by hub.freebsd.org (Postfix) with SMTP id 31A7337B405 for ; Wed, 4 Jul 2001 02:02:37 -0700 (PDT) (envelope-from dwmalone@maths.tcd.ie) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 4 Jul 2001 10:02:36 +0100 (BST) To: Dima Dorfman Cc: David Malone , arch@freebsd.org Subject: Re: Peer credentials on a Unix domain socket In-reply-to: Your message of "Tue, 03 Jul 2001 14:06:25 PDT." <20010703210625.B09E53E28@bazooka.unixfreak.org> X-Request-Do: Date: Wed, 04 Jul 2001 10:02:35 +0100 From: David Malone Message-ID: <200107041002.aa78002@salmon.maths.tcd.ie> Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > I think we already have this, although it isn't called LOCAL_CREDS. > At least there's code to implement it in uipc_usrreq.c > (unp_internalize() routine, circa line 991). If I'm seeing things, > then LOCAL_CREDS would certainly be a welcome addition, although it > would compliment, not contradict, what's being discussed here. What we have is slightly different. In BSDI's version you set a socket option on the receiving end and then cerds are added as a control message when someone writes data to the sending end. With our version the sender must add a control message of type SCM_CREDS. > > If you want to do things like this without waiting, then maybe it > > would be better coded using unix domain datagram sockets, not stream > > sockets? That way they can't use up file discriptors on the serving > > process. They can still send junk datagrams, but you could tell > > they were junk easily 'cos they'd have no credentials attached. > But it may still be desireable to use a stream socket for other reasons. If you need to communicate after authenticating then you can always send a datagram back with one end of a pipe, a socketpair or whatever type of file discriptor you need. Mind you, I may just be making excuses... > > (If you impliment things this way you can also get the creds of > > the process sending messages, as opposed to the credentials of the > > process which bound the socket.) > With my implementation, the credentials are stored at connect(2) time. > In some bizzare cases, this may even be preferred to the credentials > at write(2) time. Of course, having both would be nice :-). If we wanted to be consistant with the tcp/udp getcred code we should be getting the creds of the person who did the socket(2) call ;-) I guess it's a matter if figuring out what the likely uses are and what the most sensible semantics are based on those. I was working on making a non-suid version of crontab[*] which used SCM_CREDS and SCM_RIGHTS. I was using a datagram socket 'cos it avoided the problem of having to listen and accept. In this case, having the credentials attached to the data you recieve means that there was less doubt about who made the request. I wonder how OpenBSD are using getpeerid and what it's semantics are? Do we know the intended uses of any of other options which people have implimented? (Maybe we should just impliment a way of getting the creds of the caller of socket, connect or write and let application writers choose). David. [*] I got stuck implimenting this version of crontab 'cos currently you can only attach one control message at a time. I've fixed this and found three reasonably serious bugs in the control message passing code (two only show up on FreeBSD-alpha, I think all the BSDs get bitten by the other). Patches soon, hopefully. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message