mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-29 19:11:28 +02:00
21 lines
518 B
Go
21 lines
518 B
Go
//go:build !windows
|
|
|
|
package server
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/netbirdio/netbird/client/internal/ipcauth"
|
|
"github.com/netbirdio/netbird/client/internal/shell"
|
|
)
|
|
|
|
// usernameForIdentity resolves a Unix caller's UID to its username via NSS
|
|
// (getent), so LDAP/AD users resolve correctly under CGO_ENABLED=0.
|
|
func usernameForIdentity(id ipcauth.Identity) (string, error) {
|
|
u, err := shell.GetUserFromGetent(strconv.FormatUint(uint64(id.UID), 10))
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return u.Username, nil
|
|
}
|