summaryrefslogtreecommitdiff
path: root/doc/linux-user-chroot.8
blob: dfd420b39252ae0de84a52e4fb6bc06463e59eff (plain)
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
.\" Copyright 2012  Codethink Limited
.\" 
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it would be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program; if not, write to the Free Software Foundation,
.\" Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
.\"
.TH LINUX-USER-CHROOT 8
.SH NAME
linux\-user\-chroot \- safely allow normal users to chroot
.SH SYNOPSIS
.B linux\-user\-chroot
.RB [ --unshare-ipc ] 
.RB [ --unshare-pid ] 
.RB [ --unshare-net ] 
.RB [ --seccomp-profile-version ] 
.RB [ --mount-proc " \fIDIR\fR] 
.RB [ --mount-readonly " \fIDIR\fR"] 
.RB [ --mount-bind " \fISOURCE DEST\fR"] 
.RB [ --chdir " \fIDIR\fR"]
.I ROOTDIR 
.I PROGRAM 
.IR ARGS...
.SH DESCRIPTION
.B linux\-user\-chroot
is a setuid program that allows non-root users to safely use some Linux
kernel container features.  It is primarily intended for use by build systems.
The user needs to create a directory tree with the build dependencies needed,
and only those,
and then
.B linux\-user\-chroot
runs the actual build commands such that the commands only see the directory
tree.
This is useful for ensuring the build gets the right version of its build
dependencies, for example.
.PP
.B linux\-user\-chroot
works similary to
.BR chroot (8),
but does not require the caller to have root privileges.
It uses Linux containers to restrict the chroot to make this safe.
The command run inside the chroot is run as the calling user, not as root.
.PP
.B linux\-user\-chroot
executes a command, and sets the root directory for the command to the
directory specified by the user
.RI ( ROOTDIR ).
Additionally, it creates a "nosuid" bind mount over the root filesystem,
to prevent the build from gaining privileges using setuid binaries.
The command can further be restricted from accessing the network,
and it can be set up with new process ID and SysV IPC namespaces.
.SH OPTIONS
.TP
.BR \-\-unshare\-ipc
Create a new SysV IPC namespace for the command.
.TP
.BR \-\-unshare\-pid
Create a new process ID (PID) namespace for the command.
This prevents the command from seeing any other processes in the system,
except itself and the processes it itself creates.
.TP
.BR \-\-unshare\-net
Create a new, empty networking stack.
This prevents the command from using any networking,
including loopback.
.TP
.BI \-\-mount\-proc " DIR"
Mount the proc filesystem at
.IR DIR .
.TP
.BI \-\-mount\-devapi " DIR"
Mount just the API devices (null, full, urandom etc) at
.IR DIR .
.TP
.BI \-\-mount\-readonly " DIR"
Make 
.I DIR
be read-only for the command.
.TP
.BI \-\-mount\-bind " SOURCE DEST"
Add a bind mount while the command is executing.
.TP
.BI \-\-chdir " DIR"
After setting the new root directory for the command,
change the current working directory to be 
.IR DIR .
.TP
.BI \-\-seccomp-profile-version " VERSION"
Seccomp is a tool to restrict the system calls applications
can make.  As linux-user-chroot is designed for build systems,
we do not need to expose the entire kernel system call interface.
Currently a number of 

This argument is an integer, where -1 means "no seccomp",
and "0" enables the first profile version.  This is an
opt-in system to any future versions.
.SH "EXIT STATUS"
The exit status is the exit status of the executed command,
or 1 if 
.B linux\-user\-chroot
failed to execute the command.
.SH EXAMPLE
To build software in the real system, but without networking:
.IP
.nf
linux\-user\-chroot \-\-unshare\-net \-\-chdir "$(pwd)"
make clean all check
.fi
.SH "SEE ALSO"
.BR chroot (8).