Documentation
¶
Overview ¶
Package paths resolves the per-user home and the on-disk layout, ported from the platform config_dir logic. Resolution: $SSH_MANAGER_HOME (alias $SSH_MANAGER_CONFIG_DIR), else the OS-standard config dir + the "ssh-manager" folder ($XDG_CONFIG_HOME or ~/.config on Unix/macOS, %APPDATA% on Windows).
Index ¶
- Constants
- func ConfigDir(get Getenv, cwd string) string
- type Getenv
- type Paths
- func (p Paths) AgeIdentity() string
- func (p Paths) AuditLog() string
- func (p Paths) Contains(path string) bool
- func (p Paths) DistDir() string
- func (p Paths) EnvFile() string
- func (p Paths) ExpiryCache() string
- func (p Paths) FirstLegacyHome() string
- func (p Paths) HistoryDB() string
- func (p Paths) Home() string
- func (p Paths) Inventory() string
- func (p Paths) IsDev() bool
- func (p Paths) LegacyHomes() []string
- func (p Paths) LockFile() string
- func (p Paths) LogDir() string
- func (p Paths) Manifest() string
- func (p Paths) NotifyCache() string
- func (p Paths) Providers() string
- func (p Paths) RefuseOutsideSandbox(action string) error
- func (p Paths) SnapshotsDir() string
- func (p Paths) StateDir() string
- func (p Paths) TokenHome(get Getenv) string
- func (p Paths) Tokens() string
Constants ¶
const ( DevSSHDir = "ssh" DevConfigDir = "config" // DevHomeDir stands in for $HOME for the token targets. DevHomeDir = "home" )
DevSSHDir and DevConfigDir are the fixed subdirectories a dev root is split into.
const DevRootEnv = "SSHMGR_DEV_ROOT"
DevRootEnv is the environment variable form of --dev-root.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Paths ¶
type Paths struct {
SSHDir string
ConfigDir string
// DevRoot is the sandbox root when this layout came from --dev-root, and
// empty otherwise. Its presence is what every "am I sandboxed" check reads,
// so there is one answer rather than a comparison rebuilt per call site.
DevRoot string
}
Paths is the resolved on-disk layout for one invocation.
func ResolveDev ¶
ResolveDev builds the layout for a sandboxed run: one root, holding both the sandbox's ~/.ssh and its config home.
It is deliberately ONE root rather than two independent overrides. The config home already had an override ($SSH_MANAGER_HOME) and ~/.ssh had none, so the only way to test against a scratch tree was to move $HOME - which also moves the ssh-agent socket, the launchd session and everything else that reads it. Two knobs would allow the worse failure: a run with its config redirected and its keys still going to the real ~/.ssh, which looks sandboxed right up until it overwrites a key you use.
The root is created on demand by the caller; this only computes and checks it.
func (Paths) AgeIdentity ¶
func (Paths) Contains ¶
Contains reports whether path is at or below the sandbox root, after resolving symlinks in the part of path that exists. Outside dev mode every path qualifies.
func (Paths) ExpiryCache ¶
func (Paths) FirstLegacyHome ¶
FirstLegacyHome returns the first real legacy dir worth migrating (a directory, not a symlink, not the standard home), or "". Mirrors facade._first_legacy_home.
func (Paths) LegacyHomes ¶
LegacyHomes are pre-rename / pre-XDG home locations in priority order: the "sshmgr" sibling of the standard home (pre-rename OS-standard dir) and the original dot-home ~/.sshmgr. Mirrors facade._legacy_homes.
A sandbox has none outside its root: ~/.sshmgr is the real user's, and dev-mode `migrate` used to move it into the sandbox.
func (Paths) NotifyCache ¶
func (Paths) RefuseOutsideSandbox ¶
RefuseOutsideSandbox refuses, in dev mode, an action that takes effect on a server or account. Dev mode sandboxes files; it cannot sandbox a key installed on a real host or removed from one. It lives on Paths, and the services that reach targets (deploy, rotate, rollback, revoke) call it themselves, so no caller - a verb, the TUI, a future one - can skip it.