Date: Wed, 11 Sep 2013 22:23:12 +0400 From: Gleb Smirnoff <glebius@FreeBSD.org> To: Yuri <yuri@rawbw.com> Cc: freebsd-net@freebsd.org Subject: Re: LOCAL_CREDS are broken ? Message-ID: <20130911182312.GU4574@FreeBSD.org> In-Reply-To: <20130911151042.GO4574@FreeBSD.org> References: <521F9789.5000903@rawbw.com> <20130911151042.GO4574@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Sep 11, 2013 at 07:10:42PM +0400, Gleb Smirnoff wrote:
T> On Thu, Aug 29, 2013 at 11:48:41AM -0700, Yuri wrote:
T> Y> The example below breaks with "Protocol not available"
T> Y> But what is wrong? Isn't this the correct usage?
T> Y> LOCAL_CREDS are only handled in kern/uipc_usrreq.c for AF_LOCAL, so it
T> Y> isn't clear why this doesn't work.
T> Y>
T> Y> --- example.c ---
T> Y> #include <sys/types.h>
T> Y> #include <sys/socket.h>
T> Y> #include <stdio.h>
T> Y> #include <stdlib.h>
T> Y> #include <sys/un.h>
T> Y>
T> Y> main() {
T> Y> int sock;
T> Y> int error;
T> Y> int oval = 1;
T> Y>
T> Y> error = socket(AF_LOCAL, SOCK_SEQPACKET, 0);
T> Y> if (error == -1) {perror("socket"); exit(-1);}
T> Y> sock = error;
T> Y>
T> Y> error = setsockopt(sock, SOL_SOCKET, LOCAL_CREDS, &oval, sizeof(oval));
T> Y> if (error) {perror("setsockopt"); exit(-1);}
T> Y> }
T>
T> Alfred is right, we should add uipc_ctloutput() as method for
T> SOCK_SEQPACKET on local sockets.
T>
T> But your code actually fails because you request SOL_SOCKET
T> level.
T>
T> LOCAL_CREDS is protocol level option, not socket.
T>
T> socket(AF_LOCAL, SOCK_DGRAM, 0);
T> setsockopt(sock, 0, LOCAL_CREDS, &oval, sizeof(oval));
T>
T> P.S. I will look at issue with SOCK_SEQPACKET.
T> According to manual page, it should work.
I've fixed that in head.
--
Totus tuus, Glebius.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130911182312.GU4574>
