Re: Getting PID of socket client

From: Johannes Lundberg <johalun0_at_gmail.com>
Date: Sun, 09 Jul 2017 14:07:06 +0000
That code gets the child's pid from the fork command. That's is not
available in my case (Wayland client connects to Wayland server via unix
socket).

I can understand the security issue.. hmm will dig further tomorrow..

Thanks for the info!


On Sun, 9 Jul 2017 at 15:26, Stefan Ehmann <shoesoft_at_gmx.net> wrote:

> On 09.07.2017 11:52, Johannes Lundberg wrote:
> > Hi
> >
> > Yeah I forgot to mention the LOCAL_CREDS.
> > It does not return the PID of the client process but i guess it could be
> > expanded to include that instead of adding another option for that.
>
> I was only skimming the man page. Didn't see that cmsgcred contains the
> PID, but sockcred does not. Of course the PID in my sample output is
> also wrong (the UID is printed instead of the PID):
>
> >     $ ./unixstrserv02
> >     PID of sender = 1001
>
> Don't why the structs are not compatible, maybe because:
> "The process ID cmcred_pid should not be looked up (such as via the
> KERN_PROC_PID sysctl) for making security decisions.  The sending
> process could have exited and its process ID already been reused for a
> new process."
>
> According to the commit log LOCAL_CREDS was obtained from NetBSD but I
> didn't investigate further.
>
Received on Sun Jul 09 2017 - 12:07:19 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:12 UTC