Documentation
¶
Index ¶
- Constants
- func Args(user, group string, args ...string) []string
- func AssembleSudoersFragments(fragments ...string) string
- func ContainsActiveFragment(file, fragment string) bool
- func ContainsFragment(file, fragment string) bool
- func NOPASSWD(subject, runAsUser, runAsGroup string, commands ...string) (string, error)
- func NewCommand(ctx context.Context, user, group string, stdin io.Reader, ...) *exec.Cmd
- func ReadFile(path string) (content string, ok bool, err error)
- func RegenerateHint(exe, file string, blockDevices []string) string
- func Run(ctx context.Context, user, group string, stdin io.Reader, ...) error
- func Unpin(fragment string) string
- func VerifyFragment(ctx context.Context, file, fragment, hint string, runAs ...RunAs) error
- func VerifyPasswordLess(ctx context.Context, runAs ...RunAs) error
- type RunAs
Constants ¶
const RegenerateGrantWarning = "" /* 190-byte string literal not displayed */
RegenerateGrantWarning applies even to network-only callers: they may be replacing a file that also contains block-device grants.
Variables ¶
This section is empty.
Functions ¶
func Args ¶
Args is the one place that defines Lima's non-interactive sudo invocation shape. Callers own the actual helper command names and sudoers policy; this package only keeps the invocation mechanics consistent.
func AssembleSudoersFragments ¶
AssembleSudoersFragments joins already-rendered sudoers fragments into a single file. The individual fragments stay owned by their domain packages; this helper only handles the generic newline normalization needed to concatenate them.
func ContainsActiveFragment ¶
func ContainsFragment ¶
ContainsFragment is ContainsActiveFragment that also accepts the unpinned form of fragment. A pinned grant with a stale digest is still rejected.
func NOPASSWD ¶
NOPASSWD renders a sudoers entry for one or more commands. Commands that run one of Lima's privileged helpers are pinned to the helper's digest.
func NewCommand ¶
func ReadFile ¶
ReadFile returns the contents of a sudoers file. It reports ok=false without an error when the file exists but is not readable: /etc/sudoers.d is typically 0750 root:root, so a correctly installed file cannot be verified from an unprivileged process. A wrong one would still make the sudo invocation fail loudly later.
func RegenerateHint ¶
RegenerateHint is the single wording for re-creating a sudoers file, so that every caller keeps advising the same ownership and mode.
func Unpin ¶
Unpin removes the digests that NOPASSWD adds to a rendered fragment, for hosts that opt out of pinning with `limactl sudoers --digest=false`. sudo then runs whatever binary is installed at the helper path, so the file does not have to be regenerated when the helper is upgraded.
func VerifyFragment ¶
VerifyFragment checks that file still grants fragment. A missing file is accepted as long as every runAs identity works without a password anyway, because otherwise the file could never be bootstrapped.
func VerifyPasswordLess ¶
VerifyPasswordLess flushes the cached sudo credentials and then checks that every runAs identity is usable without a password, e.g. because the host has a blanket "%admin ALL = (ALL:ALL) NOPASSWD: ALL" rule.