A bug with getsockopt(SOL_LOCAL, LOCAL_PEERCRED) ?
Konstantin Belousov
kostikbel at gmail.com
Thu Apr 15 19:16:09 UTC 2021
On Thu, Apr 15, 2021 at 09:58:36PM +0300, Gleb Popov wrote:
> Hello hackers.
>
> I'm using getsockopt(SOL_LOCAL, LOCAL_PEERCRED) on a unix socket and for
> some reason it fails for me. I came up with a minimal reproduction
> testcase: https://arrowd.name/un.cpp
>
> Steps to reproduce:
> 1. c++ un.cpp
> 2. ./a.out
> 3. nc -U foobar
>
> This results in
>
> getsockopt
> failed with
> Socket is not connected
>
> Am I missing something?
You are calling getsockopt(2) in the listen socket, not on the connected one.
Replace s with s2 in the call.
More information about the freebsd-hackers
mailing list