From owner-freebsd-current@freebsd.org Sun Jul 9 14:07:19 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 72271DB2A8D for ; Sun, 9 Jul 2017 14:07:19 +0000 (UTC) (envelope-from johalun0@gmail.com) Received: from mail-wr0-x235.google.com (mail-wr0-x235.google.com [IPv6:2a00:1450:400c:c0c::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EDB9494E for ; Sun, 9 Jul 2017 14:07:18 +0000 (UTC) (envelope-from johalun0@gmail.com) Received: by mail-wr0-x235.google.com with SMTP id k67so105252384wrc.2 for ; Sun, 09 Jul 2017 07:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=s6cb7l07gAj3Ri1rDYO+W8dxyz+dBYfVhlq7TeQjX/M=; b=laU8/QGJy/1q8JR5iB1DZcodB5TPU6mRQWPwN7dlatSY7UkKw/po93D6LtcnuG+1vH cziOzzZJ4q9YlyvDiEzu4gQBpdYRn1r9BjR9gTYnYzESUSGZGLfr6gZ/5BWJ40FdjNlO o7pm4QfTllqe+6q3HP6GATtAq5vzODlKUS2AP4AHqf7j2IL5ni9k+USGgioZox5WqgBB uvMLIrqq7VpnC0yua6RwkN3DmEI5xx/nRUA2MHCUjaDwfhn6ugj9KY/DM+yWsqx2m5IQ qwYH23tpqxD47VDWeojjKuVnvTKrumXakJkOLpjY2dqzmESFU4MbkA8kDHMEGYpU3RnN lQGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=s6cb7l07gAj3Ri1rDYO+W8dxyz+dBYfVhlq7TeQjX/M=; b=tMCMDcmHZ5GijLWT7ca1pLYC8f8v/CLWyt+UqhqvYYr2yEeCRAYB6r/vv1BdrBkOnN JDrVsfWVbV32+ID4fXZeP4iWufWttWSgWe6+rCQIt3QhG1IFo217ZEdBt4Cq4wR1D0IP jtKCw9EgGXOCB7MjYlqhH39DzaAmJJggYCaw634eRCXD8gwivyIOdjwlGlzmNnX2ghBK mrReE8wcl6MSnxtd+KA2VuB6F2FOh6MFqOIcnZKw9f4VmSJWbUFnM7nbUc8qHapL86Qf dxU7XMb5mYAFajrFj1k8Y0G7+8qlSiEFnm++4/1S+lnGVQhEwxurRGRVYbHJLWZm4Wt+ JnGw== X-Gm-Message-State: AIVw112Ar4xnofY+dmmP+jNlR3i0vBCGn6QSfCpp3I11SuU3ZOtU1yct /5/RrWuenb1ILfPX400V7GPGGqPBOg== X-Received: by 10.28.17.11 with SMTP id 11mr4381730wmr.109.1499609237276; Sun, 09 Jul 2017 07:07:17 -0700 (PDT) MIME-Version: 1.0 References: <684e8346-c4a8-a0c5-cb2a-cd5159d2af1c@gmx.net> In-Reply-To: <684e8346-c4a8-a0c5-cb2a-cd5159d2af1c@gmx.net> From: Johannes Lundberg Date: Sun, 09 Jul 2017 14:07:06 +0000 Message-ID: Subject: Re: Getting PID of socket client To: Stefan Ehmann Cc: freebsd-current Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 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 14:07:19 -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 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. >