Documentation
¶
Overview ¶
Package scm's Linux implementation replaces the Windows Service Control Manager + registry with systemd (via systemctl) and a root-owned JSON state file. The guard's persistent state - the "disabled" teardown sentinel and the uninstall password hash - lives in that file instead of the registry.
Index ¶
- func AcquireSingleton(name string) bool
- func ClearPasswordHash() error
- func EnsureRunning(name string) (string, error)
- func Exists(name string) bool
- func GetPasswordHash() (string, bool)
- func Harden(name string) error
- func IsDisabled() bool
- func IsRunning(name string) bool
- func IsUpdating() bool
- func SetDisabled(v bool) error
- func SetPasswordHash(hash string) error
- func SetUpdating(v bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcquireSingleton ¶
AcquireSingleton takes an advisory file lock so only one watchdog runs at a time. The file handle is intentionally leaked for the process lifetime; the OS releases the lock on exit.
func ClearPasswordHash ¶
func ClearPasswordHash() error
ClearPasswordHash removes the stored hash (after a verified uninstall).
func EnsureRunning ¶
EnsureRunning enables the service and starts it if it is not already active. It returns "restarted" if it had to start it, otherwise "ok".
func GetPasswordHash ¶
GetPasswordHash returns the stored hash and whether one is set.
func Harden ¶
Harden ensures the service starts at boot. Auto-restart on failure is set in the unit at install time (Restart=always, via the guardsvc service options); enabling here covers boot start. Safe to call repeatedly.
func IsRunning ¶
IsRunning reports whether the systemd unit is currently active. It works for an unprivileged caller, so the status UI can use it.
func IsUpdating ¶
func IsUpdating() bool
IsUpdating reports whether an update is currently in progress.
func SetDisabled ¶
SetDisabled writes the teardown sentinel; IsDisabled reads it.
func SetPasswordHash ¶
SetPasswordHash stores the bcrypt hash of the uninstall password.
func SetUpdating ¶
SetUpdating writes the sentinel that tells the watchdog to stand down while an update swaps the binaries and restarts the service. IsUpdating reads it.
Types ¶
This section is empty.