Documentation
¶
Overview ¶
Package helperinstall lets the running root daemon replace its own installed copy with a newer release binary the app hands it — without an admin prompt.
The root-owned copy under /Library/PrivilegedHelperTools exists so that nothing running as the user can change what launchd starts as root (the bundle in /Applications is user-writable). Copying "whatever is in the bundle" would hand that protection straight back. So the daemon does not trust the file it is given: it fetches the checksums.txt GitHub published for the claimed version over an allowlisted HTTPS path and installs the bytes only if their SHA-256 is the one the release lists for netscoped, and only if that version is newer than the one running. A local process can offer any file it likes; unless it is byte-for-byte the release, nothing happens. The version gate also means nothing can talk the daemon back down to an older, buggier build.
Index ¶
Constants ¶
const ( Label = "io.netscope.daemon" DefaultHelperPath = "/Library/PrivilegedHelperTools/" + Label DefaultPlistPath = "/Library/LaunchDaemons/" + Label + ".plist" )
Where install.sh and the app's privileged install put the helper. The label is the launchd service name; daemonctl derives the same paths from it.
const ( // ChecksumName is the entry in checksums.txt that vouches for the daemon // binary inside the app bundle (scripts/package.sh writes it). ChecksumName = "netscoped" )
Variables ¶
var ( ErrNotRoot = errors.New("the daemon is not running as root") ErrNotManaged = errors.New("no launchd service is installed for the helper") ErrRejected = errors.New("candidate rejected") )
Errors the API maps to status codes. Everything else is a 500-ish surprise.
Functions ¶
This section is empty.
Types ¶
type Installer ¶
type Installer struct {
Repo string // "owner/name" on GitHub
Current string // version of the running daemon (buildinfo.Version)
HelperPath string // root-owned copy launchd runs
PlistPath string // launchd service definition; its absence means "not installed"
// Fetch downloads url (https, GitHub hosts only) and returns at most max
// bytes. The daemon wires the same allowlisted client the update check uses.
Fetch func(url string, max int64) ([]byte, error)
// EUID reports the effective uid; only root may install. Overridable so
// the install path itself is testable.
EUID func() int
}
Installer holds what the daemon needs to vet and install a successor. Every field that touches the machine or the network is a value so tests can point it at a temp dir and a canned checksums.txt.