Documentation ¶
Overview ¶
Package landlock provides a Go library for using the landlock feature of the modern Linux kernel.
The landlock feature of the kernel is used to isolate a process from accessing the filesystem except for blessed paths and access modes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrLandlockNotAvailable = errors.New("landlock not available") ErrLandlockFailedToLock = errors.New("landlock failed to lock") )
var ( // ErrImproperType indicates an improper filetype string ErrImproperType = errors.New("improper filetype") // ErrImproperMode indicates an improper mode string ErrImproperMode = errors.New("improper mode") // ErrImproperPath indicates an improper filepath string ErrImproperPath = errors.New("improper path") )
var ( // ErrVersionUndetectable indicates a failure when checking landlock version ErrVersionUndetectable = errors.New("landlock version detection failure") // ErrNotSupported indicates landlock is not supported on this system ErrNotSupported = errors.New("landlock not supported") )
Functions ¶
func Available ¶
func Available() bool
Available returns true if landlock is available, false otherwise.
func IsProperMode ¶
IsProperMode returns whether mode conforms to the "rwcx" characters of a mode string.
func IsProperPath ¶
IsProperPath returns whether fp conforms to a valid filepath.
func IsProperType ¶
Types ¶
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
func Certs ¶
func Certs() *Path
Certs creates a Path representing the common files needed for SSL/TLS certificate validation.
func DNS ¶
func DNS() *Path
DNS creates a Path representing the common files needed for DNS related operations.
func File ¶
File creates a Path given the path and mode, associated with a file.
File should be used with regular files, FIFOs, sockets, symlinks.
A File cannot be used to create or delete files.
func ParsePath ¶
ParsePath parses s into a Path.
s must contain 'd' or 'f' indicating whether the path represents a file or directory, followed by a mode string indicating the permissions of the path, followed by a filepath.
A mode is zero or more of: - 'r' - enable read permission - 'w' - enable write permission - 'c' - enable create permission - 'x' - enable execute permission
s must be in the form "[kind]:[mode]:path"
"d:rw:$HOME" would enable reading and writing to the users home directory.
"f:x:/bin/cat" would enable executing the /bin/cat file.
It is recommended to use the File or Dir helper functions.
func Shared ¶
func Shared() *Path
Shared creates a Path representing the common files and directories needed for dynamic shared object files.
Use Shared when allowing the execution of dynamically linked binaries.
func Stdio ¶
func Stdio() *Path
Stdio creates a Path representing the common files and directories needed for standard I/O operations.
func TTY ¶
func TTY() *Path
TTY creates a path representing common files needed for terminal operations.
func Tmp ¶
func Tmp() *Path
Tmp creates a Path representing the common files and directories needed for reading and writing to the system tmp space.
func VMInfo ¶
func VMInfo() *Path
VMInfo creates a Path representing the common files and directories needed for virtual machines and system introspection.
type Safety ¶
type Safety byte
Safety indicates the enforcement behavior on systems where landlock does not exist or operate as expected.
const ( // Mandatory mode will return an error on failure, including on // systems where landlock is not supported. Mandatory Safety = iota // OnlySupported will return an error on failure if running on a supported // operating system (Linux), or no error otherwise. Unlike OnlyAvailable, // this includes returning an error on systems where the Linux kernel was // built without landlock support. OnlySupported // OnlyAvailable will return an error on failure if running in an environment // where landlock is detected and available, or no error otherwise. Unlike // OnlySupported, OnlyAvailable does not cause an error on Linux systems built // without landlock support. OnlyAvailable // Try mode will continue with no error on failure. Try )