3 ms·
But of course there is, it's part of POSIX, implemented in libc. And if you're using a higher level language, they all have their own wrappers around libc/POSIX
by pferde 3mo ago
But of course there is, it's part of POSIX, implemented in libc. And if you're using a higher level language, they all have their own wrappers around libc/POSIX APIs. Here is golang's: https://pkg.go.dev/os/user https://pkg.go.dev/os/user
- eviks 3mo agoThanks, that's what I didn't get from the other discussion, so it seems to be a rather trivial fix - just use the existing language functionality
- dchest 3mo agoWhich uses libc via CGO or parses /etc/passwd with no CGO, which won't work for some cases. https://github.com/tailscale/tailscale/blob/e4144230f410204aa2f43a07a57182c751239597/util/osuser/user.go#L144-L148 https://github.com/tailscale/tailscale/blob/e4144230f410204a... // userLookupGetent uses "getent" to look up users so that even with static // tailscaled binaries without cgo (as we distribute), we can still look up // PAM/NSS users which the standard library's os/user without cgo won't get // (because of no libc hooks). If "getent" fails, userLookupGetent falls back // to the standard library.