sandboxsetup

package
v0.8.9 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 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 sandboxsetup is Linux's OS sandbox, from outside the engine: whether bubblewrap can run here, and, where AppArmor's restriction on unprivileged user namespaces stops it (Ubuntu 24.04 and later), an AppArmor profile that lets bwrap alone have them, installed with the user's password (sudo or pkexec). The CLI (blitz security) and the desktop app's settings use it.

Index

Constants

View Source
const ProfileName = "blitz-bwrap"

ProfileName is the AppArmor profile Fix installs, and its file's name in /etc/apparmor.d: Blitz's own, so a distribution's bwrap profile stays.

Variables

View Source
var ErrCantFix = errors.New("not something an AppArmor profile fixes")

ErrCantFix means the sandbox's problem isn't one Fix can help.

View Source
var ErrNoElevation = errors.New("neither sudo nor pkexec is installed")

ErrNoElevation means neither sudo nor pkexec is installed.

Functions

func Commands

func Commands(st Status) string

Commands are the commands Fix runs, for someone to run by hand: as root, write Profile(bwrap) to the profile's path and load it.

func Profile

func Profile(bwrap string) string

Profile is the AppArmor profile that lets bwrap (its real path) create user namespaces, unconfined otherwise: what Ubuntu ships for programs that need them (/etc/apparmor.d/devhelp, say), for bwrap alone, while every other program stays restricted.

Types

type Elevation

type Elevation struct {
	Command        string
	Stdin          io.Reader
	Stdout, Stderr io.Writer
	// Graphical uses pkexec only: without a terminal, sudo can't ask.
	Graphical bool
}

Elevation is how Fix runs its one privileged step: Command is sudo (in a terminal, which asks for the password there) or pkexec (the desktop's password dialog). Stdin, Stdout and Stderr are the terminal's, for sudo.

type State

type State string

State is what Check found.

const (
	// Unsupported means the OS isn't Linux: its sandbox (Seatbelt on macOS)
	// needs no set-up, or it has none.
	Unsupported State = "unsupported"
	// Ready means bubblewrap runs.
	Ready State = "ready"
	// NoBwrap means bubblewrap isn't installed.
	NoBwrap State = "no_bwrap"
	// Restricted means AppArmor's restriction on unprivileged user namespaces
	// stops bubblewrap, and Fix can lift it for bwrap alone.
	Restricted State = "restricted"
	// Broken means bubblewrap fails for another reason (a container's seccomp
	// profile, a kernel without user namespaces) that Fix can't help.
	Broken State = "broken"
)

The states.

type Status

type Status struct {
	State  State  `json:"state"`
	Bwrap  string `json:"bwrap,omitempty"`  // its real path
	Detail string `json:"detail,omitempty"` // bwrap's error
	// Profile is where Fix writes (or wrote) the profile.
	Profile string `json:"profile,omitempty"`
}

Status is the sandbox's state here, with the bwrap it found and why it fails, if it does.

func Check

func Check(ctx context.Context) Status

Check reports whether bubblewrap runs here and, if not, whether Fix can make it.

func Fix

func Fix(ctx context.Context, el Elevation) (Status, error)

Fix installs and loads the profile with one password prompt (el), then checks again. It does nothing when the sandbox works, and fails with ErrCantFix when its problem isn't AppArmor's restriction.

Jump to

Keyboard shortcuts

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