| 1 |
📚 [Godoc](https://pkg.go.dev/github.com/landlock-lsm/go-landlock/landlock) |
| 2 |
| 🌍 [landlock.io](https://landlock.io/) |
| 3 |
|
| 4 |
# Go Landlock library |
| 5 |
|
| 6 |
The Go-Landlock library restricts the current processes' ability to |
| 7 |
use files, using Linux 5.13's Landlock feature. |
| 8 |
|
| 9 |
## TL;DR: Example |
| 10 |
|
| 11 |
In a Go program, after starting up and doing program initialization work, run: |
| 12 |
|
| 13 |
``` |
| 14 |
err := landlock.V9.BestEffort().RestrictPaths( |
| 15 |
landlock.RODirs("/usr", "/bin"), |
| 16 |
landlock.RWDirs("/tmp"), |
| 17 |
) |
| 18 |
``` |
| 19 |
|
| 20 |
After this invocation, your program can only access the specified paths. |
| 21 |
|
| 22 |
Landlock is a Linux kernel feature and can restrict the following types of access: |
| 23 |
|
| 24 |
* Filesystem access |
| 25 |
* Some network operations |
| 26 |
* Some IPC operations |
| 27 |
|
| 28 |
More details and examples in the [Go-Landlock |
| 29 |
documentation](https://pkg.go.dev/github.com/landlock-lsm/go-landlock/landlock). |
| 30 |
|
| 31 |
## Goals |
| 32 |
|
| 33 |
Goals of Go-Landlock are: |
| 34 |
|
| 35 |
* Make unprivileged sandboxing easy to use and effective. |
| 36 |
* Keep Go-Landlock's implementation at an easily auditable size. |
| 37 |
|
| 38 |
## How to... |
| 39 |
|
| 40 |
* [...onboard a program to use Go-Landlock](docs/onboarding.md) |
| 41 |
* [...upgrade a Go-Landlock usage to use more advanced features](docs/upgrade.md) |