sudoers

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 12 Imported by: ? 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

Index

Constants

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

func Args(user, group string, args ...string) []string

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

func AssembleSudoersFragments(fragments ...string) string

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 ContainsActiveFragment(file, fragment string) bool

func ContainsFragment

func ContainsFragment(file, fragment string) bool

ContainsFragment is ContainsActiveFragment that also accepts the unpinned form of fragment. A pinned grant with a stale digest is still rejected.

func NOPASSWD

func NOPASSWD(subject, runAsUser, runAsGroup string, commands ...string) (string, error)

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 NewCommand(ctx context.Context, user, group string, stdin io.Reader, stdout, stderr io.Writer, dir string, args ...string) *exec.Cmd

func ReadFile

func ReadFile(path string) (content string, ok bool, err error)

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

func RegenerateHint(exe, file string, blockDevices []string) string

RegenerateHint is the single wording for re-creating a sudoers file, so that every caller keeps advising the same ownership and mode.

func Run

func Run(ctx context.Context, user, group string, stdin io.Reader, stdout, stderr io.Writer, dir string, args ...string) error

func Unpin

func Unpin(fragment string) string

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

func VerifyFragment(ctx context.Context, file, fragment, hint string, runAs ...RunAs) error

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

func VerifyPasswordLess(ctx context.Context, runAs ...RunAs) error

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.

Types

type RunAs

type RunAs struct {
	User  string
	Group string
}

RunAs is an identity a generated grant is exercised as.

Jump to

Keyboard shortcuts

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