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