1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
.Dd September 27, 2026
.Dt LOCKBOX 7
.Os
.Sh NAME
.Nm lockbox
.Nd Landlock build isolation for mkpkg
.Sh DESCRIPTION
The lockbox restricts what a build can see of the file system, using
the Linux Landlock security module.
A build in the lockbox can read only the files that the package
database lists for its declared dependencies and for a fixed set of
base packages.
A library or header that is installed but not declared is invisible:
configure scripts and linkers do not find it, so the build either
leaves the feature out or fails.
It never links an undeclared dependency silently.
.Pp
The lockbox needs Linux 5.13 or later with
.Dv CONFIG_SECURITY_LANDLOCK=y .
It needs no container runtime, overlay file system or extra
privileges.
.Pp
There are two forms, which may be combined.
.Ss Full lockbox
The whole build runs in the lockbox: unpacking,
.Fn patch ,
.Fn build
and
.Fn post_build ,
and the packaging steps after them.
.Xr mkpkg 8
runs this part in a child process that restricts itself and then
builds; the rest of
.Xr mkpkg 8
is not restricted, so the footprint check, signing, the second
.Fn shell
hook and installing with
.Fl r
work as usual.
The first
.Fn shell
hook runs before the lockbox is entered.
.Pp
The build can read the files of:
.Bl -bullet -offset indent
.It
the base packages, see
.Sx BASE PACKAGES ;
.It
the packages in
.Va depends
and
.Va makedeps .
Every one of them must be installed.
.El
.Pp
It can read and write the work directory, the source directory, the
package directory, the port directory, the directory named by
.Ev MKPKG_TMP_DIR ,
.Pa /tmp
and
.Pa /dev .
It can read
.Pa /proc
and
.Pa /etc .
.Pp
The full lockbox is turned on by
.Li lockbox=(yes)
in the recipe, or for one build by
.Ic mkpkg -b .
.Ss Per-command lockbox
Only chosen commands run in a lockbox:
.Bd -literal -offset indent
lockbox=(make ninja cargo)
.Ed
.Pp
Every line of
.Fn build
whose first word is one of the listed names is run through
.Xr lbexec 8 ,
which restricts itself and then runs the command.
The shell around it is not restricted.
Only lines that start with the command are wrapped: in
.Ql cd src && make
nothing is.
Other hooks are never wrapped.
The name
.Li cargo
selects the cargo profile of
.Xr lbexec 8 ,
every other name the standard profile.
.Ss Turning it off
.Ic mkpkg -ib
builds without either form, whatever the recipe says, and overrides
.Fl b .
.Sh BASE PACKAGES
These packages are readable in every lockbox, whether declared or not.
A missing one is reported but is not an error.
.Bl -column "signify-openbsd" -offset indent
.It Li llvm Ta clang, lld and the LLVM tools
.It Li libffi , libedit , ncurses , libxml2 Ta libraries LLVM links
.It Li musl Ta C library and headers
.It Li linux-headers Ta kernel headers
.It Li bash , dash , readline Ta shells for the hooks
.It Li mawk Ta awk for configure scripts
.It Li coreutils , gmp , libcap2 Ta basic commands
.It Li tar , acl , attr Ta unpacking sources
.It Li gzip , xz , bzip2 , zstd Ta decompressors
.It Li grep , pcre2 , sed Ta configure scripts
.It Li findutils , diffutils , file Ta configure and make
.It Li patch Ta the Fn patch hook
.It Li make Ta GNU make
.It Li autoconf , automake , libtool , m4 , perl Ta autotools
.It Li pkgconf Ta pkg-config
.It Li mkpkg , libressl , zlib Ta the package tools
.It Li signify-openbsd Ta signing
.El
.Sh FILES
.Bl -tag -width Ds -compact
.It Pa /var/lib/pkg/db
Package database, source of the read rules.
.El
.Sh DIAGNOSTICS
.Bl -tag -width Ds
.It "mkpkg: lockbox: Landlock ABI vN"
The lockbox is being set up with Landlock ABI version N.
.It "mkpkg: lockbox: N rules added from mkpkg db"
Read access was granted to N files and directories.
.It "mkpkg: lockbox: filesystem restricted to declared deps + build paths"
The build now runs in the lockbox.
.It "mkpkg: error: lockbox: dep 'X' not installed"
.Li X
is declared in
.Va depends
or
.Va makedeps
but is not in the package database.
The build does not start.
.It "mkpkg: warning: lockbox: base package 'X' not in db"
A base package is missing; the build continues without it.
.It "mkpkg: warning: lockbox: dep 'X' missing: path"
The database lists a file of a declared dependency that does not
exist.
.It "mkpkg: error: lockbox: Landlock not available"
The kernel has no Landlock support.
.El
.Sh SEE ALSO
.Xr MAKEPKG 5 ,
.Xr mkpkg.conf 5 ,
.Xr lbexec 8 ,
.Xr mkpkg 8
|