Changeset View
Changeset View
Standalone View
Standalone View
head/usr.sbin/chroot/chroot.8
Show All 22 Lines | |||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
.\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" @(#)chroot.8 8.1 (Berkeley) 6/9/93 | .\" @(#)chroot.8 8.1 (Berkeley) 6/9/93 | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd June 7, 2003 | .Dd March 14, 2019 | ||||
.Dt CHROOT 8 | .Dt CHROOT 8 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm chroot | .Nm chroot | ||||
.Nd change root directory | .Nd change root directory | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
.Nm | .Nm | ||||
.Op Fl u Ar user | .Op Fl G Ar group Ns Op Cm \&, Ns Ar group ... | ||||
.Op Fl g Ar group | .Op Fl g Ar group | ||||
.Op Fl G Ar group,group,... | .Op Fl u Ar user | ||||
.Ar newroot | .Ar newroot | ||||
.Op Ar command | .Op Ar command Op Ar arg ... | ||||
.Sh DESCRIPTION | .Sh DESCRIPTION | ||||
The | The | ||||
.Nm | .Nm | ||||
utility changes its current and root directories to the supplied directory | utility changes its current and root directories to the supplied directory | ||||
.Ar newroot | .Ar newroot | ||||
and then exec's | and then exec's | ||||
.Ar command , | .Ar command | ||||
if supplied, | with provided arguments, if supplied, | ||||
or an interactive copy of the user's login shell. | or an interactive copy of the user's login shell. | ||||
.Pp | .Pp | ||||
If the | The options are as follows: | ||||
.Fl u , | .Bl -tag -width "-G group[,group ...]" | ||||
.Fl g | .It Fl G Ar group Ns Op Cm \&, Ns Ar group ... | ||||
or | Run the command with the permissions of the specified groups. | ||||
.Fl G | .It Fl g Ar group | ||||
options are given, | Run the command with the permissions of the specified | ||||
the user, | .Ar group . | ||||
group and group list of the process are set to | .It Fl u Ar user | ||||
these values after the | Run the command as the | ||||
.Nm | .Ar user . | ||||
has taken place. | .El | ||||
.Sh ENVIRONMENT | .Sh ENVIRONMENT | ||||
The following environment variable is referenced by | The following environment variable is referenced by | ||||
.Nm : | .Nm : | ||||
.Bl -tag -width ".Ev SHELL" | .Bl -tag -width "SHELL" | ||||
.It Ev SHELL | .It Ev SHELL | ||||
If set, | If set, | ||||
the string specified by | the string specified by | ||||
.Ev SHELL | .Ev SHELL | ||||
is interpreted as the name of | is interpreted as the name of | ||||
the shell to exec. | the shell to exec. | ||||
If the variable | If the variable | ||||
.Ev SHELL | .Ev SHELL | ||||
is not set, | is not set, | ||||
.Pa /bin/sh | .Pa /bin/sh | ||||
is used. | is used. | ||||
.El | |||||
.Sh EXAMPLES | |||||
.Bl -tag -width 0n | |||||
.It Sy Example 1\&: No Chrooting into a New Root Directory | |||||
.Pp | |||||
The following command opens the | |||||
.Xr csh 1 | |||||
shell after chrooting to the standard root directory. | |||||
.Bd -literal -offset 2n | |||||
.Li # Ic chroot / /bin/csh | |||||
.Ed | |||||
.It Sy Example 2\&: No Execution of a Command with a Changed Root Directory | |||||
.Pp | |||||
The following command changes a root directory with | |||||
.Nm | |||||
and then runs | |||||
.Xr ls 1 | |||||
to list the contents of | |||||
.Pa /sbin . | |||||
.Bd -literal -offset 2n | |||||
.Li # Ic chroot /tmp/testroot ls /sbin | |||||
.Ed | |||||
.El | .El | ||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||
.Xr chdir 2 , | .Xr chdir 2 , | ||||
.Xr chroot 2 , | .Xr chroot 2 , | ||||
.Xr setgid 2 , | .Xr setgid 2 , | ||||
.Xr setgroups 2 , | .Xr setgroups 2 , | ||||
.Xr setuid 2 , | .Xr setuid 2 , | ||||
.Xr getgrnam 3 , | .Xr getgrnam 3 , | ||||
.Xr environ 7 , | .Xr environ 7 , | ||||
.Xr jail 8 | .Xr jail 8 | ||||
.Sh HISTORY | .Sh HISTORY | ||||
The | The | ||||
.Nm | .Nm | ||||
utility first appeared in | utility first appeared in | ||||
.Bx 4.4 . | .Bx 4.4 . |