daemonctl

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package daemonctl lets the unprivileged menu-bar app bring up the privileged capture daemon itself, so the user only ever launches one app. If the daemon isn't already running, it copies netscoped to a root-owned location and installs a system LaunchDaemon that runs it at boot — one macOS admin prompt, and another only when an app update brings a new daemon binary.

Running from a root-owned copy is what stops the registered daemon from being swapped after installation. It does not vouch for the binary that gets copied; see the note on findNetscoped for what that would take.

This is the pragmatic path that works for an un-notarized build. A fully click-once experience (SMAppService) needs a Developer ID signature.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ensure

func Ensure(client *http.Client, sock string) error

Ensure makes the daemon available: returns nil if it is already running (or comes up shortly — e.g. just installed by the installer), otherwise installs and starts the LaunchDaemon (prompting for admin once) and waits for it.

A stale helper (the app updated but the root-owned copy is still the old build) is deliberately NOT reinstalled here. Refreshing it needs an admin prompt, and doing that unbidden on every launch would nag a user who declined with no way to stop it — and a locally built app run next to a released one would ping-pong. Detecting staleness on launch is fine; acting on it is the user's to trigger, via HelperStale/RefreshHelper surfaced in the popover.

func HelperStale added in v0.21.0

func HelperStale() (stale bool, digest string)

HelperStale reports whether the root-owned daemon copy differs from the one shipped in the running bundle — the app updated but launchd is still running the old build — with a short digest of the bundled daemon that identifies this particular staleness, so a caller can remember which one it already told the user about. It is quiet: any error, or a dev/CLI build with no bundled daemon, reports "not stale" rather than surfacing noise.

func IsRunning

func IsRunning(client *http.Client) bool

IsRunning reports whether the daemon answers on the socket.

func RefreshHelper added in v0.21.0

func RefreshHelper(client *http.Client, sock string) error

RefreshHelper re-runs the privileged install when the copy under helperPath no longer matches the daemon shipped in the running bundle — i.e. after the app updated itself. Without it the installed helper would stay on the old build forever, since restarting only re-runs the same file. It costs one admin prompt, the same trade SMJobBless makes when a helper's version changes, so it runs only when the user asks for it (see HelperStale). A no-op when nothing is stale; anything unexpected is logged and ignored, since a stale-but-working daemon beats an app that won't start.

Types

This section is empty.

Jump to

Keyboard shortcuts

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