helperinstall

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 9 Imported by: 0

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

View Source
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.

View Source
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

View Source
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.

func (*Installer) Install

func (in *Installer) Install(req Request) error

Install vets req and, if it passes, atomically replaces HelperPath with the candidate's bytes. The caller restarts the daemon afterwards; this function never does, so a rejected request leaves the running daemon untouched.

type Request

type Request struct {
	Path    string `json:"path"`    // absolute path to the candidate netscoped
	Version string `json:"version"` // release tag it claims to be, "vX.Y.Z"
}

Request names a candidate daemon binary and the release it claims to be.

Jump to

Keyboard shortcuts

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