agentconfig

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package agentconfig stores the persistent agent token at /etc/ghostpsy/agent.conf.

The file holds a single line: the raw bearer token. Permissions are enforced to 0600 owner=root so a non-privileged user on the host cannot read the credential. Tests override the path via GHOSTPSY_AGENT_CONFIG_PATH.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConfigured = errors.New("agent not registered: agent.conf is missing")

ErrNotConfigured signals that no persistent token exists yet (the agent has not been registered on this host).

Functions

func Exists

func Exists() bool

Exists reports whether the persistent agent token file is already on disk.

Used by “register“ to refuse re-runs (with a clear error) and by idempotent install scripts to decide between “register“ and a plain “scan --yes“. Permission errors fall through as "does not exist" so callers see a single source of truth: the file is treated as already-configured when it is readable; anything else means register should attempt to write it.

func Load

func Load() (string, error)

Load reads the persistent agent token.

Returns ErrNotConfigured if the file does not exist. Refuses to read if the file mode is looser than 0600 (the caller should then re-register rather than continue with an exposed credential).

func Path

func Path() string

Path returns the resolved configuration file path.

func Save

func Save(token string) error

Save writes the persistent agent token with mode 0600.

The parent directory is created if missing. The file is written via a temp file + rename so a concurrent reader never sees a half-written credential.

Types

This section is empty.

Jump to

Keyboard shortcuts

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