A bug with getsockopt(SOL_LOCAL, LOCAL_PEERCRED) ?
Mark Millard
marklmi at yahoo.com
Thu Apr 15 19:58:19 UTC 2021
On 2021-Apr-15, at 12:21, Gleb Popov <arrowd at freebsd.org> wrote:
> On Thu, Apr 15, 2021 at 10:16 PM Konstantin Belousov <kostikbel at gmail.com>
> wrote:
>
>> You are calling getsockopt(2) in the listen socket, not on the connected
>> one.
>> Replace s with s2 in the call.
>>
>
> The `man unix ` says:
>
> The credentials presented to the server (the
> listen(2) caller) are those of the client
> when it called connect(2); the credentials
> presented to the client (the connect(2)
> caller) are those of the server when it
> called listen(2).
>
> This is what I actually want - to find out credentials of the connected
> user.
The way I read the above quote and your code and
related documentation: s2 after the accept4 assignment
is specific to the client's specific connect and
will give access to the connected user's credentials
--but s is not specific to the specific connect in
question (after that assignment or later) and would
not give the information that you indicate that you
want: you need a connection-specific identifier.
In other words, it looks to me like what you quoted
agrees with what Konstantin reported.
===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)
More information about the freebsd-hackers
mailing list