perms

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package perms centralizes the file modes ssh-manager enforces and applies them in a platform-correct way - POSIX chmod on Unix, ACLs via icacls on Windows. Ported.set_perms layer.

Index

Constants

View Source
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 ModeFor

func ModeFor(path string, isDir bool) os.FileMode

ModeFor returns the canonical mode for a path by its role. Mirrors perms.mode_for.

func PermsOK

func PermsOK(path string, mode os.FileMode) bool

PermsOK reports whether path already has exactly the expected low-9-bit mode. Mirrors platforms.base.perms_ok ((st_mode & 0o777) == mode).

func SetPerms

func SetPerms(path string, mode os.FileMode) error

SetPerms applies a POSIX mode. Mirrors platforms/{macos,linux}.set_perms.

func WindowsPermsOK

func WindowsPermsOK(path string) bool

WindowsPermsOK is windowsPermsOK, exported so callers can test their Windows branch on any host.

Types

type ManagedPath

type ManagedPath struct {
	Path string
	Mode os.FileMode
}

ManagedPath is a tool-managed path and the canonical mode it should carry.

func IterManagedPaths

func IterManagedPaths(sshDir string) []ManagedPath

IterManagedPaths returns (path, canonical mode) for every tool-managed path under sshDir: ~/.ssh itself, the root config, the trust store, and the whole profiles/ subtree. 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.

Jump to

Keyboard shortcuts

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