guardsvc

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package guardsvc hosts the Extension Guard as a long-running service and its watchdog companion. The service applies the force-install policy on start, re-applies it on registry tamper (via the watcher) and on a backstop timer, and spawns a watchdog process. The watchdog re-asserts service recovery, restarts the service if it is stopped or disabled, and re-installs it if the service entry is deleted - so stopping or killing the guard does not stick.

Index

Constants

View Source
const (
	// ServiceName is the SCM service name; the watchdog references it too.
	ServiceName = "ExtensionGuard"
)

Variables

This section is empty.

Functions

func Disable

func Disable(cfg policy.Config, configPath string) error

Disable temporarily turns protection off. It performs the same teardown as an uninstall - stop and remove the service and lift the browser lock so browsing is unfiltered - but the caller deliberately keeps the stored uninstall password so Enable can restore protection later. The disabled sentinel it sets also stops the watchdog from resurrecting anything, and because the service entry is removed nothing auto-starts on reboot.

func Enable

func Enable(cfg policy.Config, configPath string) error

Enable restores protection after a Disable: it clears the disabled sentinel and reinstalls, hardens, and starts the service, which re-applies the browser lock. It assumes an uninstall password is already stored (set at install).

func Install

func Install(cfg policy.Config, configPath string) error

Install registers the service, hardens it (recovery + Automatic start), clears the disabled sentinel, and starts it.

func New

func New(cfg policy.Config, configPath string) (service.Service, error)

New builds the service. configPath is embedded into the service's launch arguments so the Service Control Manager passes it back to `guard run` - a service's working directory is System32, so the config can't be located by walking up the tree. Flags precede the subcommand because Go's flag parser stops at the first non-flag argument.

func RunWatchdog

func RunWatchdog(cfg policy.Config, configPath string) error

RunWatchdog is the watchdog companion loop. A single instance runs at a time; it exits when the disabled sentinel is set.

func Uninstall

func Uninstall(cfg policy.Config, configPath string) error

Uninstall sets the disabled sentinel (so the watchdog stops resurrecting), waits long enough for the watchdog to observe it and exit, then stops and removes the service. The wait closes a race where the watchdog could re-install the service mid-teardown.

Types

This section is empty.

Jump to

Keyboard shortcuts

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