Documentation
¶
Index ¶
- Constants
- func DaemonRunsAsSelf(addr string) bool
- func DialTarget(addr string) (string, []grpc.DialOption)
- func IsProtectedPipePath(path string) bool
- func MigrateLegacy(addr string) (string, bool)
- func PipePath(name string) string
- func PipePaths(name string) []string
- func ResolveDaemonAddr(addr string) string
- func ResolveUnixDaemonAddr(addr string) string
Constants ¶
const ( // WindowsPipeAddr is the default daemon address on Windows. A named pipe // carries the connecting process's token, which loopback TCP does not, so // it is the only Windows transport on which the daemon can tell who is // calling it. WindowsPipeAddr = "npipe://netbird" )
Variables ¶
This section is empty.
Functions ¶
func DaemonRunsAsSelf ¶ added in v0.76.0
DaemonRunsAsSelf reports whether the daemon listening at addr runs as this very user. That is what makes an unprivileged daemon authorize this process for the changes it otherwise restricts to root or an administrator, so a client can tell up front whether those controls are usable instead of letting a save fail.
It is answered from the ownership of the socket or pipe the daemon created, so it costs no round trip and needs no cooperation from the daemon. Ownership that cannot be read is reported as false, including for a TCP address, so a caller reading this as "the daemon would allow it" fails closed. The daemon remains the only thing that authorizes anything: this only decides what a client offers.
func DialTarget ¶ added in v0.76.0
func DialTarget(addr string) (string, []grpc.DialOption)
DialTarget returns the gRPC dial target and transport options for a daemon address. The npipe scheme needs a context dialer because gRPC has no named-pipe resolver; unix and tcp are handled by gRPC itself.
func IsProtectedPipePath ¶ added in v0.76.0
IsProtectedPipePath reports whether a pipe path is in the namespace only an administrator or LocalSystem can create in, which is what lets a client trust such a pipe from its name alone.
func MigrateLegacy ¶ added in v0.76.0
MigrateLegacy upgrades the pre-named-pipe Windows daemon address to the named pipe, reporting whether it rewrote the address. Existing installs persist the daemon address, so without this an upgraded daemon would keep listening on loopback TCP, where callers carry no identity and privileged operations would have to be refused for everyone. Only the exact legacy default is rewritten: a deliberately chosen custom address is left alone.
func PipePath ¶ added in v0.76.0
PipePath maps an npipe address name ("netbird", from "npipe://netbird") to a Windows named-pipe path (\\.\pipe\netbird). A fully qualified path is left as is.
func PipePaths ¶ added in v0.76.0
PipePaths returns the paths a daemon control pipe may live at for an npipe address name, in the order both sides must try them: the protected name first, then the plain one.
The daemon serves the first it can create, which is the protected name when it runs as the service account and the plain one when it runs as an ordinary user, as it does in netstack mode. Clients therefore have to try both, and because a client cannot tell from the name alone who created the pipe, the plain name is only usable once the server's identity has been checked: see verifyPipeServer.
A fully qualified path is what the operator asked for and is used as is.
func ResolveDaemonAddr ¶ added in v0.76.0
ResolveDaemonAddr is a no-op off Windows, where there is no named-pipe default to fall back from.
func ResolveUnixDaemonAddr ¶
ResolveUnixDaemonAddr checks whether the default Unix socket exists and, if not, scans /var/run/netbird/ for a single .sock file to use instead. This handles the mismatch between the netbird@.service template (which places the socket under /var/run/netbird/<instance>.sock) and the CLI default (/var/run/netbird.sock).
Types ¶
This section is empty.