From owner-freebsd-current@freebsd.org Sun Jul 9 13:26:09 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0A2C8DB21D4 for ; Sun, 9 Jul 2017 13:26:09 +0000 (UTC) (envelope-from shoesoft@gmx.net) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.gmx.net", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 665C38454E for ; Sun, 9 Jul 2017 13:26:07 +0000 (UTC) (envelope-from shoesoft@gmx.net) Received: from walrus.pepperland ([81.217.71.61]) by mail.gmx.com (mrgmx101 [212.227.17.168]) with ESMTPSA (Nemesis) id 0M20Jj-1dnuph3hkJ-00u5En; Sun, 09 Jul 2017 15:25:58 +0200 Subject: Re: Getting PID of socket client To: Johannes Lundberg Cc: freebsd-current References: From: Stefan Ehmann Message-ID: <684e8346-c4a8-a0c5-cb2a-cd5159d2af1c@gmx.net> Date: Sun, 9 Jul 2017 15:25:57 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:DPz+6BbMuqz2Y/10aD5cktzl0A6KnsHaMIacAZy/bMiEl107sYX F/8+GALvrm0WC3/Frr8fwiS2ArznJJIGOMtsVDqY7tgBhp6qvNcWjkx48pOJYhoHkGYdixA GC0XmX1FeXFqzd6LTc5lzVANraioivrShzpmZ+q8C7IPqjjCFoKIEb8ejZHMUS9HHUysYXm TRu3Y3cYy2ZdYqcKOUz0g== X-UI-Out-Filterresults: notjunk:1;V01:K0:l1Pfydvv2dw=:rmlrFsaz78OziTMZqyJq2n TiActv1rFf02COh6p9utlHZPI7nwWhdfrnfLz98+1qacCS+390zj9wXR8yPqwiFCk/tBitmn3 xxl12EIj7mHHECi4dxeAn4hQytWtvFnVRLEw2oAEUkQeFFFjrRglgwuN5iEO+RRg5mNAVtFhK 4L2iyYD6NDrN6DeAynyXTIZG/ywEnvHvfpwZLqLNLTmomEi0tmYMLDdPbQWqgwZP+6vp/88h7 U6iZG4kV0TBSVqGESGIAXbG2Kk4pAiTQeo7b19Jqy/MqlR9uym+8bdz1biAO48MBJvJdnMKsd 8mtn3Re3pDrKeLuxGMkyQI0fkbX03I+LFeJ9PYYxBLWxStnydeZ/EIhmiNSgG/49PFZPletTb WuKZe0axmM7WKo9D9tXCkGFGlnK5CfEP0HIeguUDHXughAgaPsb1P+bgtLEvrfDGuHCjiHQ1+ 5THfRxB8SwPq3nu7Dn6FIcWfDXsXulOTaWrVL6bA3D5MsAbDs2HDOy2bSxBMwkGh9kek5XWAo cStddw+0ixOPsip1HZxqlZVhvu/OqAODOyMuQmrunuz3UHsZ3AmUgtFe6JuuBSzpKwk/ZX0/o 8whEYrRYYOwh+vVLE2Sgi1lovWVHTtra9GbSUKKn429yJDVeflSaki7p4j8RUfjvkX+7add0k iiJUuU2kvjyvvw4zJU0nJTYFn4rFGxr013B/jAJFmU+/FQqjfuB/XULT8Ew5GT3RQdfZxe4yL ZUQVTXyUklPKvWaoycnJLFq66hqCTk72d3osrTFh4YFdh54X6u9gqIst19cZIsNYAXSDmf7W0 McL4k5R X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Jul 2017 13:26:09 -0000 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.