2 .\" Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .Nd "execute a command inside an existing jail"
35 .Op Fl u Ar username | Fl U Ar username
36 .Ar jail Op Ar command ...
44 identified by its jid or name.
47 is not specified then the user's shell is used.
49 The following options are available:
50 .Bl -tag -width indent
52 Execute in a clean environment.
53 The environment is discarded except for
54 .Ev HOME , SHELL , TERM , USER ,
55 and anything from the login class capability database for the user.
57 is set to "/bin:/usr/bin".
59 The user name from host environment as whom the
64 The user name from jailed environment as whom the
69 .Ss Example 1 : Open a shell in a jail
70 The following command specifies a jail by its name and utilizes the current
75 It is also possible to specify a jail by its jid:
78 .Ss Example 2 : Run a single command without opening a shell
79 The following command runs
83 Since a command is specified explicitly,
85 does not spawn an interactive shell.
88 executes the specified command directly.
90 .Dl # jexec name uname -a
91 .Ss Example 3 : Open a shell in a jail with a clean environment
92 The following command opens a
94 shell in a jail with a clean environment:
96 .Dl # jexec -l name sh
97 .Ss Example 4 : Open a shell in a jail with the login command
98 The following command utilizes
100 to access the jail, submitting an audit record, and displaying the
101 user's last login, system copyright, and
105 .Dl # jexec -l name login -f root
116 If the jail is not identified by
118 there is a possible race in between the lookup of the jail
119 and executing the command inside the jail.
122 has a similar race as another process can stop the jail and
123 start another one after the user looked up the