-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/sys/unix: Enable pid lookup of unix socket peer for darwin #27613
Comments
Change https://golang.org/cl/134535 mentions this issue: |
After looking more at the
would still be nice to figure out the symmetry with respect to its linux counterpart, or get those constants defined otherwise :) |
Given that Also, I don't think we need a specific |
But then again, we also conform to the Linux specific API on Darwin/BSD e.g. for xattrs, so we might add |
Definitely agree, we can stick with just |
Me too, however perhaps also with documentation that it duplicates GetsockoptPID. |
@tklauser, I just noticed you asked me a question 2.5 years ago, sorry. But to answer your question, I just went and added So, yes, (2) sounds fine. That https://golang.org/cl/134535 looks like it's much of the way there, but stopped short of finishing it when they were asked to re-send it to a different repo. I don't think we need unix.GetsockoptPID if we export some new consts instead. Then I plan to write a high-level portable package around the different ways OSes get this peercred info. |
Change https://golang.org/cl/292330 mentions this issue: |
Updates golang/go#27613 Updates tailscale/tailscale#1347 Updates tailscale/tailscale#1348
I've published a high-level package that does both the Linux thing and the Darwin thing: inet.af/peercred. I'll be moving my Windows code to it too (that does localhost TCP mapping) |
Package syscall on linux currently has behavior to look up a
Ucred
object, which contains the PID of the remote end of a Unix socket usinggetsockopt
+SO_PEERCRED
.This feature request seeks to add similar behavior for darwin (and perhaps BSD). This can be done using
getsockopt
+LOCAL_PEERPID
. Note that we can't useLOCAL_PEERCRED
, as the behavior isn't identical to linux: we get axucred
struct, which doesn't contain a pid.Open question: linux's
type syscall.Ucred
exposes UID, GID, and PID. These are all useful, however an exact darwin analog doesn't exist. Options:type syscall.Ucred
type for darwin that contains UID, GID, and PID.func syscall.GetsockoptUcred(...) (syscall.Ucred, error)
for darwin that abstracts twogetsockopt
system calls: (1)LOCAL_PEERPID
for the pid, and (2)LOCAL_PEERCRED
for the user and groupor
xucred
struct that contains UID and GID (type syscall.Xucred
)func syscall.GetsockoptXucred(...) (syscall.Xucred, error)
to look up UID and GIDfunc syscall.GetsockoptPID(...) (int, error)
to look up PIDThe text was updated successfully, but these errors were encountered: