localuser

package
v0.2.39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package localuser resolves the local account a privileged installer or supervisor drops privileges to. It exists because two callers need the same answer and the same refusals: the macOS LaunchDaemon installer (pkg/cli/cmd/launchd.go) and the edge add-on supervisor, which launches a code-execution child from a root agent.

The refusals are the point. uid 0 is rejected, and so is a home directory that is relative or is "/" — a state directory created under "/" would scatter owner-only files across the filesystem root.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	// Username as it appears in the account database.
	Username string
	// Group is the canonical PRIMARY GROUP NAME, not a gid string: launchd's
	// GroupName key is a name field, and numeric values are not portable across
	// macOS releases.
	Group string
	// Home is an absolute, cleaned home directory that is not "/".
	Home string
	// UID and GID of the account.
	UID int
	GID int
}

Account is a resolved non-root local account.

func Current

func Current() (Account, error)

Current resolves the account the calling process already runs as. It applies the same refusals, so a root process never gets an Account back.

func Resolve

func Resolve(username, homeOverride, groupOverride string) (Account, error)

Resolve looks up username and applies the shared refusals. homeOverride and groupOverride are optional; an empty value takes the account database's. groupOverride may be a gid or a group name and is normalized to a name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL