blob: 1f3b1267df158b9bb7db8939a0f804bb8664a436 [file] [log] [blame]
Elly Jonese58176c2012-01-23 11:46:17 -05001.TH MINIJAIL0 "1" "January 2012" "Chromium OS" "User Commands"
Elly Jonescd7a9042011-07-22 13:56:51 -04002.SH NAME
3minijail0 \- sandbox a process
4.SH SYNOPSIS
5.B minijail0
6[\fIOPTION\fR]... <\fIprogram\fR> [\fIargs\fR]...
7.SH DESCRIPTION
8.PP
9Runs PROGRAM inside a sandbox.
10.TP
Andrew Brestickereac28942015-11-11 16:04:46 -080011\fB-a <table>\fR
12Run using the alternate syscall table named <table>. Only available on kernels
13and architectures that support the PR_ALT_SYSCALL option of prctl(2).
14.TP
Elly Jones51a5b6c2011-10-12 19:09:26 -040015\fB-b <src>,<dest>[,<writeable>]
16Bind-mount <src> into the chroot directory at <dest>, optionally writeable.
17.TP
Elly Jonescd7a9042011-07-22 13:56:51 -040018\fB-c <caps>\fR
19Restrict capabilities to \fIcaps\fR. When used in conjunction with \fB-u\fR and
Elly Jones51a5b6c2011-10-12 19:09:26 -040020.TP
21\fB-C <dir>\fR
22Change root (using chroot(2)) to <dir>.
23.TP
Lee Campbell11af0622014-05-22 12:36:04 -070024\fB-t\fR
25Mounts a tmpfs filesystem on /tmp. /tmp must exist in the chroot.
26This must be used with -C. The default filesystem has a max size of 128M
27and has standard /tmp permissions (777).
28.TP
Elly Jonescd7a9042011-07-22 13:56:51 -040029\fB-g\fR, this allows a program to have access to only certain parts of root's
30default privileges while running as another user and group ID altogether. Note
31that these capabilities are not inherited by subprocesses of the process given
32capabilities unless those subprocesses have POSIX file capabilities. See
33\fBcapabilities\fR(7).
34.TP
35\fB-G\fR
36Inherit all the supplementary groups of the user specified with \fB-u\fR. It
37is an error to use this option without having specified a \fBuser name\fR to
38\fB-u\fR.
39.TP
40\fB-g <group>\fR
41Change groups to \fIgroup\fR, which may be either a group name or a numeric
42group ID.
43.TP
44\fB-h\fR
45Print a help message.
46.TP
Will Drewry32ac9f52011-08-18 21:36:27 -050047\fB-H\fR
48Print a help message detailing supported system call names for seccomp_filter.
49(Other direct numbers may be specified if minijail0 is not in sync with the
50 host kernel or something like 32/64-bit compatibility issues exist.)
51.TP
Elly Jonescd7a9042011-07-22 13:56:51 -040052\fB-p\fR
53Run inside a new PID namespace. This option will make it impossible for the
Elly Jonese58176c2012-01-23 11:46:17 -050054program to see or affect processes that are not its descendants. This implies
55\fB-v\fR and \fB-r\fR, since otherwise the process can see outside its namespace
56by inspecting /proc.
Elly Jonescd7a9042011-07-22 13:56:51 -040057.TP
58\fB-r\fR
59Remount certain filesystems readonly. Currently this only remounts /proc. This
60implies \fB-v\fR. Remounting /proc readonly means that even if the process has
61write access to a system config knob in /proc (e.g., in /sys/kernel), it cannot
62change the value.
63.TP
64\fB-s\fR
65Enable seccomp(2) in mode 1, which restricts the child process to a very small
Will Drewry32ac9f52011-08-18 21:36:27 -050066set of system calls.
67.TP
68\fB-S <arch-specific seccomp_filter policy file>\fR
69Enable seccomp(2) in mode 13 which restricts the child process to a set of
70system calls defined in the policy file. Note that system calls often change
71names based on the architecture or mode. (uname -m is your friend.)
Elly Jonescd7a9042011-07-22 13:56:51 -040072.TP
73\fB-u <user>\fR
74Change users to \fIuser\fR, which may be either a user name or a numeric user
75ID.
76.TP
77\fB-v\fR
78Run inside a new VFS namespace. This option makes the program's mountpoints
79independent of the rest of the system's.
80.SH IMPLEMENTATION
81This program is broken up into two parts: \fBminijail0\fR (the frontend) and a helper
82library called \fBlibminijailpreload\fR. Some jailings can only be achieved from
83the process to which they will actually apply - specifically capability use
84(since capabilities are not inherited to an exec'd process unless the exec'd
85process has POSIX file capabilities), seccomp (since we can't exec() once we're
86seccomp'd), and ptrace-disable (which is always cleared on exec().
87
88To this end, \fBlibminijailpreload\fR is forcibly loaded into all
89dynamically-linked target programs if any of these restrictions are in effect;
90we pass the specific restrictions in an environment variable which the preloaded
91library looks for. The forcibly-loaded library then applies the restrictions
92to the newly-loaded program.
93.SH AUTHOR
94Written by Elly Jones (ellyjones@chromium.org)
95.SH COPYRIGHT
96Copyright \(co 2011 The Chromium OS Authors
97License BSD-like.
98.SH "SEE ALSO"
Will Drewry32ac9f52011-08-18 21:36:27 -050099\fBlibminijail.h\fR \fBminijail0(5)\fR