tokio-rs / tokio

A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ...
https://tokio.rs
MIT License
26.25k stars 2.41k forks source link

Add PID to UCred on remaining platforms #3102

Open Darksonn opened 3 years ago

Darksonn commented 3 years ago

Implement pid on windows for UCred. See #3085 and #2633.

What other platforms are missing?

cc @de-vri-es, @Kloenk

kloenk commented 3 years ago

IIRC I left open nearly all BSDs (only MacOS) and Solaris.

EDIT: Solaris got already implemented by somebody else

Darksonn commented 3 years ago

The currently supported platforms are listed here:

https://github.com/tokio-rs/tokio/blob/90c2a510e28a05cc72f76eb5e8bd4a7f7751e333/tokio/src/net/unix/ucred.rs#L25-L28

de-vri-es commented 3 years ago

Windows doesn't have UCred at all right? Makes sense since Windows doesn't have Unix sockets. Although maybe there's something similar for pipes on Windows? I'm really not familiar with Windows.

OpenBSD and NetBSD do support PID though.

NetBSD supports it with the LOCAL_PEEREID socket option: https://man.netbsd.org/NetBSD-9.0/unix.4

OpenBSD supports it with the SO_PEERCRED socket option: https://man.openbsd.org/getsockopt.2

FreeBSD doesn't support it as far as I can tell. The struct returned with the LOCAL_PEERCRED option doesn't include a PID: https://www.freebsd.org/cgi/man.cgi?query=unix&apropos=0&sektion=0&manpath=FreeBSD+12.2-RELEASE+and+Ports&arch=default&format=html

DragonFly BSD also doesn't seem to support it. They seem to have the same system as FreeBSD: https://leaf.dragonflybsd.org/cgi/web-man?command=unix&section=ANY

sisungo commented 2 months ago

It appears that FreeBSD 13 added support of PID in credentials?

https://man.freebsd.org/cgi/man.cgi?query=unix&apropos=0&sektion=0&manpath=FreeBSD+14.1-RELEASE+and+Ports&arch=default&format=html

In the section of LOCAL_PEERCRED and LOCAL_CREDS_PERSISTENT is mentioned PID, which wasn't mentioned in FreeBSD 12 man pages.