Documentation
¶
Overview ¶
Package perms centralizes the file modes authama enforces and applies them in a platform-correct way - POSIX chmod on Unix, ACLs via icacls on Windows. Ported.set_perms layer.
Index ¶
Constants ¶
const ( DirMode os.FileMode = 0o700 PrivateKeyMode os.FileMode = 0o600 ConfigMode os.FileMode = 0o600 PublicKeyMode os.FileMode = 0o644 // KnownHostsMode is owner-only, not 0644. ssh has never needed the trust // store to be world-readable, and its contents are an inventory of every host // the user connects to - which is why the names are hashed as well. KnownHostsMode os.FileMode = 0o600 )
Modes SSH expects. Private keys and configs must not be group/other readable; dirs are 0700; host public keys are world-readable.
Variables ¶
This section is empty.
Functions ¶
func PermsOK ¶
PermsOK reports whether path already has exactly the expected low-9-bit mode. Mirrors platforms.base.perms_ok ((st_mode & 0o777) == mode).
func WindowsPermsOK ¶
WindowsPermsOK is windowsPermsOK, exported so callers can test their Windows branch on any host.
Types ¶
type ManagedPath ¶
ManagedPath is a tool-managed path and the canonical mode it should carry.
func IterManagedPathsIn ¶ added in v0.1.6
func IterManagedPathsIn(sshDir, root string) []ManagedPath
IterManagedPathsIn returns (path, canonical mode) for every tool-managed path under sshDir: ~/.ssh itself, the root config, the trust store, and the whole key-root subtree (~/.ssh/<root>). It deliberately excludes unrelated user files (id_rsa, agent sockets), skips symlinks, and skips dot-prefixed cruft it did not create (.DS_Store and friends). This is the single enumeration both reconcile (the fixer) and doctor (the checker) walk, so they can't disagree.