capability

package
v3.0.0-rc76 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 3 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 capability names the Linux capabilities and parses a capability bounding set as the capability_bounding_set keyword writes it, after the CapabilityBoundingSet of systemd: the capabilities the command keeps, all others dropped, or, the list prefixed with ~, the capabilities it drops.

Index

Constants

View Source
const All = "ALL"

All is the name standing for every capability, as the engines take it in --cap-add and --cap-drop.

Variables

This section is empty.

Functions

func Canonical

func Canonical(s string) (string, error)

Canonical returns the capability named s, in any case, with or without its CAP_ prefix, as the engines name it in --cap-add and --cap-drop: in upper case, without the prefix, as NET_BIND_SERVICE, or All. A name of no capability is an error.

func CanonicalList

func CanonicalList(s string) ([]string, error)

CanonicalList returns the capabilities of the whitespace separated list s as Canonical names them, each once, in the order they are first named. A name of no capability is an error.

func Name

func Name(n int) string

Name returns the name of the capability of number n, or "cap_<n>" for a number this package does not name, as one of a kernel newer than it.

func Number

func Number(s string) (int, bool)

Number returns the number of the capability named s, in any case, and false when s names none.

func ValidateList

func ValidateList(s string) error

ValidateList says whether s is a list of capabilities, for the keywords taking one: a name of no capability, as a typo or a comma separated list, is refused.

Types

type BoundingSet

type BoundingSet struct {
	// Drop says the listed capabilities are the ones dropped, all others
	// kept: the list was prefixed with ~.
	Drop bool

	// Caps are the numbers of the listed capabilities, sorted.
	Caps []int
}

BoundingSet is a capability bounding set: the capabilities it lists, and whether they are the ones kept or the ones dropped.

func ParseBoundingSet

func ParseBoundingSet(s string) (BoundingSet, error)

ParseBoundingSet parses s, a list of capability names separated by spaces, optionally prefixed with ~. A name it does not know is an error, so a typo does not leave the command with a capability its configuration meant to drop. An empty s is the empty set kept: every capability is dropped.

func (BoundingSet) Keeps

func (t BoundingSet) Keeps(n int) bool

Keeps says whether the bounding set keeps the capability of number n.

func (BoundingSet) String

func (t BoundingSet) String() string

String returns the bounding set as ParseBoundingSet parses it back, the names in upper case and in number order.

Jump to

Keyboard shortcuts

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