From owner-svn-src-head@freebsd.org Thu Mar 14 14:34:37 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 079C11545A86; Thu, 14 Mar 2019 14:34:37 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9C06C82527; Thu, 14 Mar 2019 14:34:36 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8D6F923D0C; Thu, 14 Mar 2019 14:34:36 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2EEYajY010514; Thu, 14 Mar 2019 14:34:36 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2EEYaaE010513; Thu, 14 Mar 2019 14:34:36 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <201903141434.x2EEYaaE010513@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Thu, 14 Mar 2019 14:34:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345132 - head/usr.sbin/chroot X-SVN-Group: head X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: head/usr.sbin/chroot X-SVN-Commit-Revision: 345132 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9C06C82527 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.977,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Mar 2019 14:34:37 -0000 Author: 0mp (ports committer) Date: Thu Mar 14 14:34:36 2019 New Revision: 345132 URL: https://svnweb.freebsd.org/changeset/base/345132 Log: chroot.8: Add examples & clean up - Sort arguments in synopsis. - Clarify that it is possible to specify arguments to the command (and that they could be passed as further arguments to chroot(1)). - Standardize the description of the flags. - Improve formatting (e.g., do not use macros in strings specifying width). - Add examples. Reviewed by: bcr Approved by: bcr (doc) Approved by: krion (mentor, implicit), mat (mentor, implicit) Differential Revision: https://reviews.freebsd.org/D19582 Modified: head/usr.sbin/chroot/chroot.8 Modified: head/usr.sbin/chroot/chroot.8 ============================================================================== --- head/usr.sbin/chroot/chroot.8 Thu Mar 14 13:28:21 2019 (r345131) +++ head/usr.sbin/chroot/chroot.8 Thu Mar 14 14:34:36 2019 (r345132) @@ -28,7 +28,7 @@ .\" @(#)chroot.8 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd June 7, 2003 +.Dd March 14, 2019 .Dt CHROOT 8 .Os .Sh NAME @@ -36,36 +36,36 @@ .Nd change root directory .Sh SYNOPSIS .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,group,... +.Op Fl u Ar user .Ar newroot -.Op Ar command +.Op Ar command Op Ar arg ... .Sh DESCRIPTION The .Nm utility changes its current and root directories to the supplied directory .Ar newroot and then exec's -.Ar command , -if supplied, +.Ar command +with provided arguments, if supplied, or an interactive copy of the user's login shell. .Pp -If the -.Fl u , -.Fl g -or -.Fl G -options are given, -the user, -group and group list of the process are set to -these values after the -.Nm -has taken place. +The options are as follows: +.Bl -tag -width "-G group[,group ...]" +.It Fl G Ar group Ns Op Cm \&, Ns Ar group ... +Run the command with the permissions of the specified groups. +.It Fl g Ar group +Run the command with the permissions of the specified +.Ar group . +.It Fl u Ar user +Run the command as the +.Ar user . +.El .Sh ENVIRONMENT The following environment variable is referenced by .Nm : -.Bl -tag -width ".Ev SHELL" +.Bl -tag -width "SHELL" .It Ev SHELL If set, the string specified by @@ -77,6 +77,28 @@ If the variable is not set, .Pa /bin/sh 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 .Sh SEE ALSO .Xr chdir 2 ,