19395ecb1SRobert Watson.\" Copyright (c) 2000, 2003 Robert N. M. Watson 291b24c18SJamie Gritton.\" Copyright (c) 2008-2012 James Gritton 3d98722bcSRobert Watson.\" All rights reserved. 4d98722bcSRobert Watson.\" 5d98722bcSRobert Watson.\" Redistribution and use in source and binary forms, with or without 6d98722bcSRobert Watson.\" modification, are permitted provided that the following conditions 7d98722bcSRobert Watson.\" are met: 8d98722bcSRobert Watson.\" 1. Redistributions of source code must retain the above copyright 9d98722bcSRobert Watson.\" notice, this list of conditions and the following disclaimer. 10d98722bcSRobert Watson.\" 2. Redistributions in binary form must reproduce the above copyright 11d98722bcSRobert Watson.\" notice, this list of conditions and the following disclaimer in the 12d98722bcSRobert Watson.\" documentation and/or other materials provided with the distribution. 13d98722bcSRobert Watson.\" 14d98722bcSRobert Watson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15d98722bcSRobert Watson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16d98722bcSRobert Watson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17d98722bcSRobert Watson.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18d98722bcSRobert Watson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19d98722bcSRobert Watson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20d98722bcSRobert Watson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21d98722bcSRobert Watson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22d98722bcSRobert Watson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23d98722bcSRobert Watson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24d98722bcSRobert Watson.\" SUCH DAMAGE. 25d98722bcSRobert Watson.\" 26ae1a0648SJamie Gritton.Dd September 19, 2024 2775c13541SPoul-Henning Kamp.Dt JAIL 8 28a4c37c81SRuslan Ermilov.Os 2975c13541SPoul-Henning Kamp.Sh NAME 3075c13541SPoul-Henning Kamp.Nm jail 312671ee73SJamie Gritton.Nd "manage system jails" 3275c13541SPoul-Henning Kamp.Sh SYNOPSIS 33dab7fc49SJamie Gritton.Ss From Configuration File 34e97407b4SRuslan Ermilov.Nm 35dab7fc49SJamie Gritton.Op Fl cm 36d50685b3SJamie Gritton.Op Fl Cdqv 37dab7fc49SJamie Gritton.Op Fl f Ar conf_file 38dab7fc49SJamie Gritton.Op Fl p Ar limit 39dab7fc49SJamie Gritton.Op Ar jail 40dab7fc49SJamie Gritton.Nm 41dab7fc49SJamie Gritton.Op Fl r 42d50685b3SJamie Gritton.Op Fl Cqv 43dab7fc49SJamie Gritton.Op Fl f Ar conf_file 44dab7fc49SJamie Gritton.Op Fl p Ar limit 45dab7fc49SJamie Gritton.Op Cm * | Ar jail ... 46dab7fc49SJamie Gritton.Ss Without Configuration File 47dab7fc49SJamie Gritton.Nm 48dab7fc49SJamie Gritton.Op Fl cm 492671ee73SJamie Gritton.Op Fl dhilqv 5073d0971bSJamie Gritton.Op Fl J Ar jid_file 512671ee73SJamie Gritton.Op Fl u Ar username 522671ee73SJamie Gritton.Op Fl U Ar username 532671ee73SJamie Gritton.Ar param Ns = Ns Ar value ... 542671ee73SJamie Gritton.Op Cm command Ns = Ns Ar command ... 5573d0971bSJamie Gritton.Nm 562671ee73SJamie Gritton.Op Fl rR 57dab7fc49SJamie Gritton.Op Fl qv 582671ee73SJamie Gritton.Op Cm * | Ar jail ... 59dab7fc49SJamie Gritton.Ss Show Parameters 60dab7fc49SJamie Gritton.Nm 61dab7fc49SJamie Gritton.Op Fl f Ar conf_file 62dab7fc49SJamie Gritton.Fl e 63dab7fc49SJamie Gritton.Ar separator 64dab7fc49SJamie Gritton.Ss Backward Compatibility 652671ee73SJamie Gritton.Nm 662671ee73SJamie Gritton.Op Fl dhilqv 672671ee73SJamie Gritton.Op Fl J Ar jid_file 682671ee73SJamie Gritton.Op Fl u Ar username 692671ee73SJamie Gritton.Op Fl U Ar username 70413628a7SBjoern A. Zeeb.Op Fl n Ar jailname 717deb00ccSMatteo Riondato.Op Fl s Ar securelevel 72203be093SMateusz Piotrowski.Ar path hostname ip Ns Op Cm \&, Ns Ar ... 73203be093SMateusz Piotrowski.Ar command ... 7475c13541SPoul-Henning Kamp.Sh DESCRIPTION 7575c13541SPoul-Henning KampThe 7675c13541SPoul-Henning Kamp.Nm 772671ee73SJamie Grittonutility creates new jails, or modifies or removes existing jails. 781e1a4743SEugene GrosbeinIt can also print a list of configured jails and their parameters. 7906e36338SBenjamin KadukA jail 8006e36338SBenjamin Kaduk.Pq or Dq prison 8106e36338SBenjamin Kadukis specified via parameters on the command line, or in the 822671ee73SJamie Gritton.Xr jail.conf 5 832671ee73SJamie Grittonfile. 8475c13541SPoul-Henning Kamp.Pp 852671ee73SJamie GrittonAt least one of the options 862671ee73SJamie Gritton.Fl c , 871e1a4743SEugene Grosbein.Fl e , 882671ee73SJamie Gritton.Fl m 892671ee73SJamie Grittonor 902671ee73SJamie Gritton.Fl r 912671ee73SJamie Grittonmust be specified. 9206e36338SBenjamin KadukThese options are used alone or in combination to describe the operation to 932671ee73SJamie Grittonperform: 9473d0971bSJamie Gritton.Bl -tag -width indent 9573d0971bSJamie Gritton.It Fl c 9673d0971bSJamie GrittonCreate a new jail. 972671ee73SJamie GrittonThe jail 9873d0971bSJamie Gritton.Va jid 9973d0971bSJamie Grittonand 10073d0971bSJamie Gritton.Va name 10106e36338SBenjamin Kadukparameters (if specified on the command line) 1022671ee73SJamie Grittonmust not refer to an existing jail. 1031e1a4743SEugene Grosbein.It Fl e Ar separator 1041e1a4743SEugene GrosbeinExhibit a list of all configured non-wildcard jails and their parameters. 1051e1a4743SEugene GrosbeinNo jail creation, modification or removal performed if this option is used. 1061e1a4743SEugene GrosbeinThe 1071e1a4743SEugene Grosbein.Ar separator 1081e1a4743SEugene Grosbeinstring is used to separate parameters. 1091e1a4743SEugene GrosbeinUse 1101e1a4743SEugene Grosbein.Xr jls 8 1111e1a4743SEugene Grosbeinutility to list running jails. 11273d0971bSJamie Gritton.It Fl m 11373d0971bSJamie GrittonModify an existing jail. 11473d0971bSJamie GrittonOne of the 11573d0971bSJamie Gritton.Va jid 11673d0971bSJamie Grittonor 11773d0971bSJamie Gritton.Va name 11873d0971bSJamie Grittonparameters must exist and refer to an existing jail. 1192671ee73SJamie GrittonSome parameters may not be changed on a running jail. 12073d0971bSJamie Gritton.It Fl r 12173d0971bSJamie GrittonRemove the 12273d0971bSJamie Gritton.Ar jail 12373d0971bSJamie Grittonspecified by jid or name. 12406e36338SBenjamin KadukAll jailed processes are killed, and all jails that are 12506e36338SBenjamin Kadukchildren of this jail are also 12673d0971bSJamie Grittonremoved. 1272671ee73SJamie Gritton.It Fl rc 1282671ee73SJamie GrittonRestart an existing jail. 1292671ee73SJamie GrittonThe jail is first removed and then re-created, as if 1302671ee73SJamie Gritton.Dq Nm Fl r 13106e36338SBenjamin Kadukand 13206e36338SBenjamin Kaduk.Dq Nm Fl c 1332671ee73SJamie Grittonwere run in succession. 1342671ee73SJamie Gritton.It Fl cm 1352671ee73SJamie GrittonCreate a jail if it does not exist, or modify the jail if it does exist. 1362671ee73SJamie Gritton.It Fl mr 1372671ee73SJamie GrittonModify an existing jail. 1382671ee73SJamie GrittonThe jail may be restarted if necessary to modify parameters than could 1392671ee73SJamie Grittonnot otherwise be changed. 1402671ee73SJamie Gritton.It Fl cmr 1412671ee73SJamie GrittonCreate a jail if it doesn't exist, or modify (and possibly restart) the 1422671ee73SJamie Grittonjail if it does exist. 14373d0971bSJamie Gritton.El 14473d0971bSJamie Gritton.Pp 1452671ee73SJamie GrittonOther available options are: 1462671ee73SJamie Gritton.Bl -tag -width indent 147d50685b3SJamie Gritton.It Fl C 148d50685b3SJamie GrittonClean up after an already-removed jail, running commands and operations 149d50685b3SJamie Grittonthat are typically run following jail removal. 1502671ee73SJamie Gritton.It Fl f Ar conf_file 1512671ee73SJamie GrittonUse configuration file 1522671ee73SJamie Gritton.Ar conf_file 1532671ee73SJamie Grittoninstead of the default 1542671ee73SJamie Gritton.Pa /etc/jail.conf . 1552671ee73SJamie Gritton.It Fl h 1562671ee73SJamie GrittonResolve the 1572671ee73SJamie Gritton.Va host.hostname 1582671ee73SJamie Grittonparameter (or 1592671ee73SJamie Gritton.Va hostname ) 1602671ee73SJamie Grittonand add all IP addresses returned by the resolver 16106e36338SBenjamin Kadukto the list of addresses for this jail. 1622671ee73SJamie GrittonThis is equivalent to the 1632671ee73SJamie Gritton.Va ip_hostname 1642671ee73SJamie Grittonparameter. 1652671ee73SJamie Gritton.It Fl i 1662671ee73SJamie GrittonOutput (only) the jail identifier of the newly created jail(s). 1672671ee73SJamie GrittonThis implies the 1682671ee73SJamie Gritton.Fl q 1692671ee73SJamie Grittonoption. 1702671ee73SJamie Gritton.It Fl J Ar jid_file 1712671ee73SJamie GrittonWrite a 1722671ee73SJamie Gritton.Ar jid_file 17306e36338SBenjamin Kadukfile, containing the parameters used to start the jail. 1742671ee73SJamie Gritton.It Fl l 1752671ee73SJamie GrittonRun commands in a clean environment. 1762671ee73SJamie GrittonThis is deprecated and is equivalent to the exec.clean parameter. 1772671ee73SJamie Gritton.It Fl n Ar jailname 1782671ee73SJamie GrittonSet the jail's name. 1792671ee73SJamie GrittonThis is deprecated and is equivalent to the 1802671ee73SJamie Gritton.Va name 1812671ee73SJamie Grittonparameter. 1822671ee73SJamie Gritton.It Fl p Ar limit 1832671ee73SJamie GrittonLimit the number of commands from 1842671ee73SJamie Gritton.Va exec.* 1852671ee73SJamie Grittonthat can run simultaneously. 1862671ee73SJamie Gritton.It Fl q 1872671ee73SJamie GrittonSuppress the message printed whenever a jail is created, modified or removed. 1882671ee73SJamie GrittonOnly error messages will be printed. 1892671ee73SJamie Gritton.It Fl R 1902671ee73SJamie GrittonA variation of the 19173d0971bSJamie Gritton.Fl r 1922671ee73SJamie Grittonoption that removes an existing jail without using the configuration file. 19306e36338SBenjamin KadukNo removal-related parameters for this jail will be used \(em the jail will 1942671ee73SJamie Grittonsimply be removed. 1952671ee73SJamie Gritton.It Fl s Ar securelevel 1962671ee73SJamie GrittonSet the 1972671ee73SJamie Gritton.Va kern.securelevel 1982671ee73SJamie GrittonMIB entry to the specified value inside the newly created jail. 1992671ee73SJamie GrittonThis is deprecated and is equivalent to the 2002671ee73SJamie Gritton.Va securelevel 2012671ee73SJamie Grittonparameter. 2022671ee73SJamie Gritton.It Fl u Ar username 2032671ee73SJamie GrittonThe user name from host environment as whom jailed commands should run. 2042671ee73SJamie GrittonThis is deprecated and is equivalent to the 2052671ee73SJamie Gritton.Va exec.jail_user 2062671ee73SJamie Grittonand 2072671ee73SJamie Gritton.Va exec.system_jail_user 2082671ee73SJamie Grittonparameters. 2092671ee73SJamie Gritton.It Fl U Ar username 21006e36338SBenjamin KadukThe user name from the jailed environment as whom jailed commands should run. 2112671ee73SJamie GrittonThis is deprecated and is equivalent to the 2122671ee73SJamie Gritton.Va exec.jail_user 2132671ee73SJamie Grittonparameter. 2142671ee73SJamie Gritton.It Fl v 2152671ee73SJamie GrittonPrint a message on every operation, such as running commands and 2162671ee73SJamie Grittonmounting filesystems. 217ed31b3f4SJamie Gritton.It Fl d 218ed31b3f4SJamie GrittonThis is deprecated and is equivalent to the 219ed31b3f4SJamie Gritton.Va allow.dying 220ed31b3f4SJamie Grittonparameter, which is also deprecated. 221ed31b3f4SJamie GrittonIt used to allow making changes to a 222ed31b3f4SJamie Gritton.Va dying 223ed31b3f4SJamie Grittonjail. 224ed31b3f4SJamie GrittonNow such jails are always replaced when a new jail is created with the same 225ed31b3f4SJamie Gritton.Va jid 226ed31b3f4SJamie Grittonor 227ed31b3f4SJamie Gritton.Va name . 2282671ee73SJamie Gritton.El 22973d0971bSJamie Gritton.Pp 2302671ee73SJamie GrittonIf no arguments are given after the options, the operation (except 2312671ee73SJamie Grittonremove) will be performed on all jails specified in the 2322671ee73SJamie Gritton.Xr jail.conf 5 2332671ee73SJamie Grittonfile. 2342671ee73SJamie GrittonA single argument of a jail name will operate only on the specified jail. 2352671ee73SJamie GrittonThe 2362671ee73SJamie Gritton.Fl r 2372671ee73SJamie Grittonand 2382671ee73SJamie Gritton.Fl R 2392671ee73SJamie Grittonoptions can also remove running jails that aren't in the 2402671ee73SJamie Gritton.Xr jail.conf 5 2412671ee73SJamie Grittonfile, specified by name or jid. 2427f4211ddSJoel Dahl.Pp 2432671ee73SJamie GrittonAn argument of 2442671ee73SJamie Gritton.Dq * 2454334a36aSJamie Grittonis a wildcard that will operate on all jails, regardless of whether 2464334a36aSJamie Grittonthey appear in 2474334a36aSJamie Gritton.Xr jail.conf 5 ; 2484334a36aSJamie Grittonthis is the surest way for 2492671ee73SJamie Gritton.Fl r 2502671ee73SJamie Grittonto remove all jails. 2512671ee73SJamie GrittonIf hierarchical jails exist, a partial-matching wildcard definition may 2522671ee73SJamie Grittonbe specified. 2532671ee73SJamie GrittonFor example, an argument of 2542671ee73SJamie Gritton.Dq foo.* 2552671ee73SJamie Grittonwould apply to jails with names like 2562671ee73SJamie Gritton.Dq foo.bar 2572671ee73SJamie Grittonand 2582671ee73SJamie Gritton.Dq foo.bar.baz . 2592671ee73SJamie Gritton.Pp 260dab7fc49SJamie GrittonA jail may also be specified via parameters directly on the command line in 261dab7fc49SJamie Gritton.Dq name=value 262dab7fc49SJamie Grittonform, ignoring the contents of 263dab7fc49SJamie Gritton.Xr jail.conf 5 . 2642671ee73SJamie GrittonFor backward compatibility, the command line may also have four fixed 2652671ee73SJamie Grittonparameters, without names: 2662671ee73SJamie Gritton.Ar path , 2672671ee73SJamie Gritton.Ar hostname , 2682671ee73SJamie Gritton.Ar ip , 2692671ee73SJamie Grittonand 2702671ee73SJamie Gritton.Ar command . 2712671ee73SJamie Gritton.Ss Jail Parameters 2722671ee73SJamie GrittonParameters in the 2732671ee73SJamie Gritton.Xr jail.conf 5 27406e36338SBenjamin Kadukfile, or on the command line, are generally of the form 27506e36338SBenjamin Kaduk.Dq name=value . 27673d0971bSJamie GrittonSome parameters are boolean, and do not have a value but are set by the 27773d0971bSJamie Grittonname alone with or without a 27873d0971bSJamie Gritton.Dq no 27973d0971bSJamie Grittonprefix, e.g. 28073d0971bSJamie Gritton.Va persist 28173d0971bSJamie Grittonor 28273d0971bSJamie Gritton.Va nopersist . 2832671ee73SJamie GrittonThey can also be given the values 2842671ee73SJamie Gritton.Dq true 28573d0971bSJamie Grittonand 2862671ee73SJamie Gritton.Dq false . 287344c81a1SWarren BlockOther parameters may have more than one value, specified as a 288*48c738b0SMark Johnstoncomma-separated list, or with 2892671ee73SJamie Gritton.Dq += 2902671ee73SJamie Grittonin the configuration file (see 2912671ee73SJamie Gritton.Xr jail.conf 5 2922671ee73SJamie Grittonfor details). 293*48c738b0SMark JohnstonList-based parameters may also be specified multiple times on the command 294*48c738b0SMark Johnstonline, i.e., 295*48c738b0SMark Johnston.Dq name=value1,value2 296*48c738b0SMark Johnstonand 297*48c738b0SMark Johnston.Dq name=value1 name=value2 298*48c738b0SMark Johnstonare equivalent for such parameters. 29973d0971bSJamie Gritton.Pp 3002671ee73SJamie GrittonThe 3012671ee73SJamie Gritton.Nm 30206e36338SBenjamin Kadukutility recognizes two classes of parameters. 30306e36338SBenjamin KadukThere are the true jail 3042671ee73SJamie Grittonparameters that are passed to the kernel when the jail is created, 30506e36338SBenjamin Kadukwhich can be seen with 3062671ee73SJamie Gritton.Xr jls 8 , 3072671ee73SJamie Grittonand can (usually) be changed with 3082671ee73SJamie Gritton.Dq Nm Fl m . 3092671ee73SJamie GrittonThen there are pseudo-parameters that are only used by 3102671ee73SJamie Gritton.Nm 3112671ee73SJamie Grittonitself. 3122671ee73SJamie Gritton.Pp 313b96bd95bSIan LeporeJails have a set of core parameters, and kernel modules can add their own 3142671ee73SJamie Grittonjail parameters. 31573d0971bSJamie GrittonThe current set of available parameters can be retrieved via 31673d0971bSJamie Gritton.Dq Nm sysctl Fl d Va security.jail.param . 3172671ee73SJamie GrittonAny parameters not set will be given default values, often based on the 3182671ee73SJamie Grittoncurrent environment. 31973d0971bSJamie GrittonThe core parameters are: 32073d0971bSJamie Gritton.Bl -tag -width indent 32173d0971bSJamie Gritton.It Va jid 32273d0971bSJamie GrittonThe jail identifier. 32373d0971bSJamie GrittonThis will be assigned automatically to a new jail (or can be explicitly 32473d0971bSJamie Grittonset), and can be used to identify the jail for later modification, or 32573d0971bSJamie Grittonfor such commands as 32673d0971bSJamie Gritton.Xr jls 8 32773d0971bSJamie Grittonor 32873d0971bSJamie Gritton.Xr jexec 8 . 32973d0971bSJamie Gritton.It Va name 33073d0971bSJamie GrittonThe jail name. 33173d0971bSJamie GrittonThis is an arbitrary string that identifies a jail (except it may not 33273d0971bSJamie Grittoncontain a 33373d0971bSJamie Gritton.Sq \&. ) . 33473d0971bSJamie GrittonLike the 33573d0971bSJamie Gritton.Va jid , 33673d0971bSJamie Grittonit can be passed to later 33773d0971bSJamie Gritton.Nm 33873d0971bSJamie Grittoncommands, or to 33973d0971bSJamie Gritton.Xr jls 8 34073d0971bSJamie Grittonor 34173d0971bSJamie Gritton.Xr jexec 8 . 34273d0971bSJamie GrittonIf no 34373d0971bSJamie Gritton.Va name 34473d0971bSJamie Grittonis supplied, a default is assumed that is the same as the 34573d0971bSJamie Gritton.Va jid . 34673d0971bSJamie GrittonThe 3472671ee73SJamie Gritton.Va name 3482671ee73SJamie Grittonparameter is implied by the 3492671ee73SJamie Gritton.Xr jail.conf 5 3502671ee73SJamie Grittonfile format, and need not be explicitly set when using the configuration 3512671ee73SJamie Grittonfile. 3522671ee73SJamie Gritton.It Va path 35306e36338SBenjamin KadukThe directory which is to be the root of the jail. 35406e36338SBenjamin KadukAny commands run inside the jail, either by 3552671ee73SJamie Gritton.Nm 3562671ee73SJamie Grittonor from 3572671ee73SJamie Gritton.Xr jexec 8 , 3582671ee73SJamie Grittonare run from this directory. 35973d0971bSJamie Gritton.It Va ip4.addr 36006e36338SBenjamin KadukA list of IPv4 addresses assigned to the jail. 36135939b04SDaniel GerzoIf this is set, the jail is restricted to using only these addresses. 36273d0971bSJamie GrittonAny attempts to use other addresses fail, and attempts to use wildcard 36373d0971bSJamie Grittonaddresses silently use the jailed address instead. 36406e36338SBenjamin KadukFor IPv4 the first address given will be used as the source address 36506e36338SBenjamin Kadukwhen source address selection on unbound sockets cannot find a better 36673d0971bSJamie Grittonmatch. 36706e36338SBenjamin KadukIt is only possible to start multiple jails with the same IP address 368413628a7SBjoern A. Zeebif none of the jails has more than this single overlapping IP address 36973d0971bSJamie Grittonassigned to itself. 370592bcae8SBjoern A. Zeeb.It Va ip4.saddrsel 371592bcae8SBjoern A. ZeebA boolean option to change the formerly mentioned behaviour and disable 37206e36338SBenjamin KadukIPv4 source address selection for the jail in favour of the primary 373592bcae8SBjoern A. ZeebIPv4 address of the jail. 3742671ee73SJamie GrittonSource address selection is enabled by default for all jails and the 375592bcae8SBjoern A. Zeeb.Va ip4.nosaddrsel 376592bcae8SBjoern A. Zeebsetting of a parent jail is not inherited for any child jails. 3777cbf7213SJamie Gritton.It Va ip4 378d4352d29SJoel DahlControl the availability of IPv4 addresses. 3797cbf7213SJamie GrittonPossible values are 3807cbf7213SJamie Gritton.Dq inherit 3817cbf7213SJamie Grittonto allow unrestricted access to all system addresses, 3827cbf7213SJamie Gritton.Dq new 3837cbf7213SJamie Grittonto restrict addresses via 38406e36338SBenjamin Kaduk.Va ip4.addr , 38506e36338SBenjamin Kadukand 3867cbf7213SJamie Gritton.Dq disable 3877cbf7213SJamie Grittonto stop the jail from using IPv4 entirely. 3887cbf7213SJamie GrittonSetting the 3897cbf7213SJamie Gritton.Va ip4.addr 3907cbf7213SJamie Grittonparameter implies a value of 3917cbf7213SJamie Gritton.Dq new . 392592bcae8SBjoern A. Zeeb.It Va ip6.addr , Va ip6.saddrsel , Va ip6 39306e36338SBenjamin KadukA set of IPv6 options for the jail, the counterparts to 394592bcae8SBjoern A. Zeeb.Va ip4.addr , 395592bcae8SBjoern A. Zeeb.Va ip4.saddrsel 3967cbf7213SJamie Grittonand 3977cbf7213SJamie Gritton.Va ip4 39873d0971bSJamie Grittonabove. 399464aad14SJamie Gritton.It Va vnet 40006e36338SBenjamin KadukCreate the jail with its own virtual network stack, 4012671ee73SJamie Grittonwith its own network interfaces, addresses, routing table, etc. 4022671ee73SJamie GrittonThe kernel must have been compiled with the 4032671ee73SJamie Gritton.Sy VIMAGE option 4042671ee73SJamie Grittonfor this to be available. 4052671ee73SJamie GrittonPossible values are 4062671ee73SJamie Gritton.Dq inherit 4072671ee73SJamie Grittonto use the system network stack, possibly with restricted IP addresses, 4082671ee73SJamie Grittonand 4092671ee73SJamie Gritton.Dq new 4102671ee73SJamie Grittonto create a new network stack. 41173d0971bSJamie Gritton.It Va host.hostname 41206e36338SBenjamin KadukThe hostname of the jail. 41376ca6f88SJamie GrittonOther similar parameters are 41476ca6f88SJamie Gritton.Va host.domainname , 41576ca6f88SJamie Gritton.Va host.hostuuid 41676ca6f88SJamie Grittonand 41776ca6f88SJamie Gritton.Va host.hostid . 4187cbf7213SJamie Gritton.It Va host 4197cbf7213SJamie GrittonSet the origin of hostname and related information. 4207cbf7213SJamie GrittonPossible values are 4217cbf7213SJamie Gritton.Dq inherit 4227cbf7213SJamie Grittonto use the system information and 4237cbf7213SJamie Gritton.Dq new 4247cbf7213SJamie Grittonfor the jail to use the information from the above fields. 4257cbf7213SJamie GrittonSetting any of the above fields implies a value of 4267cbf7213SJamie Gritton.Dq new . 42773d0971bSJamie Gritton.It Va securelevel 42873d0971bSJamie GrittonThe value of the jail's 42973d0971bSJamie Gritton.Va kern.securelevel 43073d0971bSJamie Grittonsysctl. 43106e36338SBenjamin KadukA jail never has a lower securelevel than its parent system, but by 43273d0971bSJamie Grittonsetting this parameter it may have a higher one. 43373d0971bSJamie GrittonIf the system securelevel is changed, any jail securelevels will be at 43473d0971bSJamie Grittonleast as secure. 4350cc207a6SMartin Matuska.It Va devfs_ruleset 4360cc207a6SMartin MatuskaThe number of the devfs ruleset that is enforced for mounting devfs in 437638f3782SMartin Matuskathis jail. 438638f3782SMartin MatuskaA value of zero (default) means no ruleset is enforced. 439638f3782SMartin MatuskaDescendant jails inherit the parent jail's devfs ruleset enforcement. 440638f3782SMartin MatuskaMounting devfs inside a jail is possible only if the 4410cc207a6SMartin Matuska.Va allow.mount 442bf3db8aaSMartin Matuskaand 443bf3db8aaSMartin Matuska.Va allow.mount.devfs 444bf3db8aaSMartin Matuskapermissions are effective and 4450cc207a6SMartin Matuska.Va enforce_statfs 446638f3782SMartin Matuskais set to a value lower than 2. 447638f3782SMartin MatuskaDevfs rules and rulesets cannot be viewed or modified from inside a jail. 44891b24c18SJamie Gritton.Pp 44991b24c18SJamie GrittonNOTE: It is important that only appropriate device nodes in devfs be 45091b24c18SJamie Grittonexposed to a jail; access to disk devices in the jail may permit processes 45191b24c18SJamie Grittonin the jail to bypass the jail sandboxing by modifying files outside of 45291b24c18SJamie Grittonthe jail. 45391b24c18SJamie GrittonSee 45491b24c18SJamie Gritton.Xr devfs 8 45591b24c18SJamie Grittonfor information on how to use devfs rules to limit access to entries 45691b24c18SJamie Grittonin the per-jail devfs. 45791b24c18SJamie GrittonA simple devfs ruleset for jails is available as ruleset #4 in 45891b24c18SJamie Gritton.Pa /etc/defaults/devfs.rules . 459b97457e2SJamie Gritton.It Va children.max 460b97457e2SJamie GrittonThe number of child jails allowed to be created by this jail (or by 461b97457e2SJamie Grittonother jails under this jail). 462b97457e2SJamie GrittonThis limit is zero by default, indicating the jail is not allowed to 463b97457e2SJamie Grittoncreate child jails. 464b97457e2SJamie GrittonSee the 4652671ee73SJamie Gritton.Sx "Hierarchical Jails" 466b97457e2SJamie Grittonsection for more information. 467b97457e2SJamie Gritton.It Va children.cur 4688972c8b6SJoel DahlThe number of descendants of this jail, including its own child jails 469b97457e2SJamie Grittonand any jails created under them. 47073d0971bSJamie Gritton.It Va enforce_statfs 47106e36338SBenjamin KadukThis determines what information processes in a jail are able to get 47273d0971bSJamie Grittonabout mount points. 47373d0971bSJamie GrittonIt affects the behaviour of the following syscalls: 47473d0971bSJamie Gritton.Xr statfs 2 , 47573d0971bSJamie Gritton.Xr fstatfs 2 , 47606e36338SBenjamin Kaduk.Xr getfsstat 2 , 47773d0971bSJamie Grittonand 47873d0971bSJamie Gritton.Xr fhstatfs 2 47973d0971bSJamie Gritton(as well as similar compatibility syscalls). 48073d0971bSJamie GrittonWhen set to 0, all mount points are available without any restrictions. 48173d0971bSJamie GrittonWhen set to 1, only mount points below the jail's chroot directory are 48273d0971bSJamie Grittonvisible. 48373d0971bSJamie GrittonIn addition to that, the path to the jail's chroot directory is removed 48473d0971bSJamie Grittonfrom the front of their pathnames. 48573d0971bSJamie GrittonWhen set to 2 (default), above syscalls can operate only on a mount-point 48673d0971bSJamie Grittonwhere the jail's chroot directory is located. 48773d0971bSJamie Gritton.It Va persist 48873d0971bSJamie GrittonSetting this boolean parameter allows a jail to exist without any 48973d0971bSJamie Grittonprocesses. 4902671ee73SJamie GrittonNormally, a command is run as part of jail creation, and then the jail 4912671ee73SJamie Grittonis destroyed as its last process exits. 492743149d2SJamie GrittonA new jail must have either the 49310310d67SJamie Gritton.Va persist 494743149d2SJamie Grittonparameter or 4952671ee73SJamie Gritton.Va exec.start 4962671ee73SJamie Grittonor 497743149d2SJamie Gritton.Va command 498743149d2SJamie Grittonpseudo-parameter set. 49988812d9eSJamie Gritton.It Va cpuset.id 50073d0971bSJamie GrittonThe ID of the cpuset associated with this jail (read-only). 50173d0971bSJamie Gritton.It Va dying 50273d0971bSJamie GrittonThis is true if the jail is in the process of shutting down (read-only). 50373d0971bSJamie Gritton.It Va parent 50473d0971bSJamie GrittonThe 50573d0971bSJamie Gritton.Va jid 50673d0971bSJamie Grittonof the parent of this jail, or zero if this is a top-level jail 50773d0971bSJamie Gritton(read-only). 508b96bd95bSIan Lepore.It Va osrelease 509b96bd95bSIan LeporeThe string for the jail's 510b96bd95bSIan Lepore.Va kern.osrelease 511b96bd95bSIan Leporesysctl and uname -r. 512b96bd95bSIan Lepore.It Va osreldate 513b96bd95bSIan LeporeThe number for the jail's 514b96bd95bSIan Lepore.Va kern.osreldate 515b96bd95bSIan Leporeand uname -K. 51673d0971bSJamie Gritton.It Va allow.* 51773d0971bSJamie GrittonSome restrictions of the jail environment may be set on a per-jail 51873d0971bSJamie Grittonbasis. 51973d0971bSJamie GrittonWith the exception of 520e28f9b7dSAllan Jude.Va allow.set_hostname 521e28f9b7dSAllan Judeand 522e28f9b7dSAllan Jude.Va allow.reserved_ports , 52373d0971bSJamie Grittonthese boolean parameters are off by default. 52473d0971bSJamie Gritton.Bl -tag -width indent 52573d0971bSJamie Gritton.It Va allow.set_hostname 52673d0971bSJamie GrittonThe jail's hostname may be changed via 52773d0971bSJamie Gritton.Xr hostname 1 52873d0971bSJamie Grittonor 52973d0971bSJamie Gritton.Xr sethostname 3 . 53073d0971bSJamie Gritton.It Va allow.sysvipc 53173d0971bSJamie GrittonA process within the jail has access to System V IPC primitives. 53252a510acSJamie GrittonThis is deprecated in favor of the per-module parameters (see below). 53352a510acSJamie GrittonWhen this parameter is set, it is equivalent to setting 53452a510acSJamie Gritton.Va sysvmsg , 53552a510acSJamie Gritton.Va sysvsem , 53652a510acSJamie Grittonand 53752a510acSJamie Gritton.Va sysvshm 53852a510acSJamie Grittonall to 53952a510acSJamie Gritton.Dq inherit . 54073d0971bSJamie Gritton.It Va allow.raw_sockets 54106e36338SBenjamin KadukThe jail root is allowed to create raw sockets. 54273d0971bSJamie GrittonSetting this parameter allows utilities like 54373d0971bSJamie Gritton.Xr ping 8 54473d0971bSJamie Grittonand 54573d0971bSJamie Gritton.Xr traceroute 8 54606e36338SBenjamin Kadukto operate inside the jail. 54773d0971bSJamie GrittonIf this is set, the source IP addresses are enforced to comply 54873d0971bSJamie Grittonwith the IP address bound to the jail, regardless of whether or not 54973d0971bSJamie Grittonthe 55073d0971bSJamie Gritton.Dv IP_HDRINCL 55173d0971bSJamie Grittonflag has been set on the socket. 55273d0971bSJamie GrittonSince raw sockets can be used to configure and interact with various 55373d0971bSJamie Grittonnetwork subsystems, extra caution should be used where privileged access 55473d0971bSJamie Grittonto jails is given out to untrusted parties. 55573d0971bSJamie Gritton.It Va allow.chflags 556f19fa944SEd SchoutenNormally, privileged users inside a jail are treated as unprivileged by 55773d0971bSJamie Gritton.Xr chflags 2 . 55873d0971bSJamie GrittonWhen this parameter is set, such users are treated as privileged, and 55973d0971bSJamie Grittonmay manipulate system file flags subject to the usual constraints on 56073d0971bSJamie Gritton.Va kern.securelevel . 56173d0971bSJamie Gritton.It Va allow.mount 56273d0971bSJamie Grittonprivileged users inside the jail will be able to mount and unmount file 56373d0971bSJamie Grittonsystem types marked as jail-friendly. 56473d0971bSJamie GrittonThe 56573d0971bSJamie Gritton.Xr lsvfs 1 56673d0971bSJamie Grittoncommand can be used to find file system types available for mount from 56773d0971bSJamie Grittonwithin a jail. 568435d4667SMartin MatuskaThis permission is effective only if 569435d4667SMartin Matuska.Va enforce_statfs 570435d4667SMartin Matuskais set to a value lower than 2. 571bf3db8aaSMartin Matuska.It Va allow.mount.devfs 572bf3db8aaSMartin Matuskaprivileged users inside the jail will be able to mount and unmount the 573bf3db8aaSMartin Matuskadevfs file system. 574bf3db8aaSMartin MatuskaThis permission is effective only together with 575bf3db8aaSMartin Matuska.Va allow.mount 57606e36338SBenjamin Kadukand only when 577bf3db8aaSMartin Matuska.Va enforce_statfs 578638f3782SMartin Matuskais set to a value lower than 2. 57906e36338SBenjamin KadukThe devfs ruleset should be restricted from the default by using the 580bf3db8aaSMartin Matuska.Va devfs_ruleset 581bf3db8aaSMartin Matuskaoption. 5820e5c6bd4SJamie Gritton.It Va allow.quotas 5830e5c6bd4SJamie GrittonThe jail root may administer quotas on the jail's filesystem(s). 5840e5c6bd4SJamie GrittonThis includes filesystems that the jail may share with other jails or 5850e5c6bd4SJamie Grittonwith non-jailed parts of the system. 586b19d66fdSJamie Gritton.It Va allow.read_msgbuf 587b19d66fdSJamie GrittonJailed users may read the kernel message buffer. 588b19d66fdSJamie GrittonIf the 589b19d66fdSJamie Gritton.Va security.bsd.unprivileged_read_msgbuf 5904520f617SJamie GrittonMIB entry is zero, this will be restricted to the root user. 5910e5c6bd4SJamie Gritton.It Va allow.socket_af 5920e5c6bd4SJamie GrittonSockets within a jail are normally restricted to IPv4, IPv6, local 593edd28b85SDmitry Chagin(UNIX), and route. 594edd28b85SDmitry ChaginThis allows access to other protocol stacks that have not had jail 595edd28b85SDmitry Chaginfunctionality added to them. 596ccd6ac9fSAntoine Brodin.It Va allow.mlock 597ccd6ac9fSAntoine BrodinLocking or unlocking physical pages in memory are normally not available 598ccd6ac9fSAntoine Brodinwithin a jail. 599ccd6ac9fSAntoine BrodinWhen this parameter is set, users may 600ccd6ac9fSAntoine Brodin.Xr mlock 2 601ccd6ac9fSAntoine Brodinor 602ccd6ac9fSAntoine Brodin.Xr munlock 2 603ccd6ac9fSAntoine Brodinmemory subject to 604ccd6ac9fSAntoine Brodin.Va security.bsd.unprivileged_mlock 605ccd6ac9fSAntoine Brodinand resource limits. 606d4b4f3b9SRick Macklem.It Va allow.nfsd 607d4b4f3b9SRick MacklemThe 608c0f94feeSRick Macklem.Xr mountd 8 , 609c0f94feeSRick Macklem.Xr nfsd 8 , 610c0f94feeSRick Macklem.Xr nfsuserd 8 , 611c0f94feeSRick Macklem.Xr gssd 8 612c0f94feeSRick Macklemand 613c0f94feeSRick Macklem.Xr rpc.tlsservd 8 614c0f94feeSRick Macklemdaemons are permitted to run inside a properly configured vnet-enabled jail. 615c0f94feeSRick MacklemThe jail's root must be a file system mount point and 616c0f94feeSRick Macklem.Va enforce_statfs 617c0f94feeSRick Macklemmust not be set to 0, so that 618d4b4f3b9SRick Macklem.Xr mountd 8 619c0f94feeSRick Macklemcan export file systems visible within the jail. 620c0f94feeSRick Macklem.Va enforce_statfs 621c0f94feeSRick Macklemmust be set to 1 if file systems mounted under the 622c0f94feeSRick Macklemjail's file system need to be exported by 623c0f94feeSRick Macklem.Xr mount 8 . 624c0f94feeSRick MacklemFor exporting only the jail's file system, a setting of 2 625c0f94feeSRick Macklemis sufficient. 626c0f94feeSRick MacklemIf the kernel configuration does not include the 627c0f94feeSRick Macklem.Sy NFSD 628c0f94feeSRick Macklemoption, 629c0f94feeSRick Macklem.Pa nfsd.ko 630c0f94feeSRick Macklemmust be loaded outside of the jails. 631c0f94feeSRick MacklemThis is normally done by adding 632c0f94feeSRick Macklem.Dq nfsd 633c0f94feeSRick Macklemto 634c0f94feeSRick Macklem.Va kld_list 635c0f94feeSRick Macklemin the 636c0f94feeSRick Macklem.Xr rc.conf 5 637c0f94feeSRick Macklemfile outside of the jails. 638c0f94feeSRick MacklemSimilarily, if the 639c0f94feeSRick Macklem.Xr gssd 8 640c0f94feeSRick Macklemis to be run in a jail, either the kernel 641c0f94feeSRick Macklem.Sy KGSSAPI 642c0f94feeSRick Macklemoption needs to be specified or 643c0f94feeSRick Macklem.Dq kgssapi 644d4b4f3b9SRick Macklemand 645c0f94feeSRick Macklem.Dq kgssapi_krb5 646c0f94feeSRick Macklemneed to be in 647c0f94feeSRick Macklem.Va kld_list 648c0f94feeSRick Macklemin the 649c0f94feeSRick Macklem.Xr rc.conf 5 650c0f94feeSRick Macklemfile outside of the jails. 6510e5c6bd4SJamie Gritton.It Va allow.reserved_ports 6520e5c6bd4SJamie GrittonThe jail root may bind to ports lower than 1024. 653b3079544SJamie Gritton.It Va allow.unprivileged_proc_debug 654b3079544SJamie GrittonUnprivileged processes in the jail may use debugging facilities. 65505e1e482SMariusz Zaborski.It Va allow.suser 65605e1e482SMariusz ZaborskiThe value of the jail's 65705e1e482SMariusz Zaborski.Va security.bsd.suser_enabled 65805e1e482SMariusz Zaborskisysctl. 65905e1e482SMariusz ZaborskiThe super-user will be disabled automatically if its parent system has it 66005e1e482SMariusz Zaborskidisabled. 66105e1e482SMariusz ZaborskiThe super-user is enabled by default. 662cb48780dSShawn Webb.It Va allow.extattr 663cb48780dSShawn WebbAllow privileged process in the jail to manipulate filesystem extended 664cb48780dSShawn Webbattributes in the system namespace. 665d3bb35d4SMariusz Zaborski.It Va allow.adjtime 666d3bb35d4SMariusz ZaborskiAllow privileged process in the jail to slowly adjusting global operating system 667d3bb35d4SMariusz Zaborskitime. 668d3bb35d4SMariusz ZaborskiFor example through utilities like 669d3bb35d4SMariusz Zaborski.Xr ntpd 8 . 670d3bb35d4SMariusz Zaborski.It Va allow.settime 671d3bb35d4SMariusz ZaborskiAllow privileged process in the jail to set global operating system data 672d3bb35d4SMariusz Zaborskiand time. 673d3bb35d4SMariusz ZaborskiFor example through utilities like 674d3bb35d4SMariusz Zaborski.Xr date 1 . 675d3bb35d4SMariusz ZaborskiThis permission includes also 676d3bb35d4SMariusz Zaborski.Va allow.adjtime . 6770e5c6bd4SJamie Gritton.El 6780e5c6bd4SJamie Gritton.El 6790e5c6bd4SJamie Gritton.Pp 6800e5c6bd4SJamie GrittonKernel modules may add their own parameters, which only exist when the 6810e5c6bd4SJamie Grittonmodule is loaded. 6820e5c6bd4SJamie GrittonThese are typically headed under a parameter named after the module, 6830e5c6bd4SJamie Grittonwith values of 6840e5c6bd4SJamie Gritton.Dq inherit 6850e5c6bd4SJamie Grittonto give the jail full use of the module, 6860e5c6bd4SJamie Gritton.Dq new 6870e5c6bd4SJamie Grittonto encapsulate the jail in some module-specific way, 6880e5c6bd4SJamie Grittonand 6890e5c6bd4SJamie Gritton.Dq disable 6900e5c6bd4SJamie Grittonto make the module unavailable to the jail. 6910e5c6bd4SJamie GrittonThere also may be other parameters to define jail behavior within the module. 6920e5c6bd4SJamie GrittonModule-specific parameters include: 6930e5c6bd4SJamie Gritton.Bl -tag -width indent 694464aad14SJamie Gritton.It Va allow.mount.fdescfs 695464aad14SJamie Grittonprivileged users inside the jail will be able to mount and unmount the 696464aad14SJamie Grittonfdescfs file system. 697464aad14SJamie GrittonThis permission is effective only together with 698464aad14SJamie Gritton.Va allow.mount 699464aad14SJamie Grittonand only when 700464aad14SJamie Gritton.Va enforce_statfs 701464aad14SJamie Grittonis set to a value lower than 2. 7025717aa2dSAlan Somers.It Va allow.mount.fusefs 7035717aa2dSAlan Somersprivileged users inside the jail will be able to mount and unmount 7045717aa2dSAlan Somersfuse-based file systems. 7055717aa2dSAlan SomersThis permission is effective only together with 7065717aa2dSAlan Somers.Va allow.mount 7075717aa2dSAlan Somersand only when 7085717aa2dSAlan Somers.Va enforce_statfs 7095717aa2dSAlan Somersis set to a value lower than 2. 710bf3db8aaSMartin Matuska.It Va allow.mount.nullfs 711bf3db8aaSMartin Matuskaprivileged users inside the jail will be able to mount and unmount the 712bf3db8aaSMartin Matuskanullfs file system. 713bf3db8aaSMartin MatuskaThis permission is effective only together with 714bf3db8aaSMartin Matuska.Va allow.mount 71506e36338SBenjamin Kadukand only when 716bf3db8aaSMartin Matuska.Va enforce_statfs 717bf3db8aaSMartin Matuskais set to a value lower than 2. 71841c0675eSMartin Matuska.It Va allow.mount.procfs 71941c0675eSMartin Matuskaprivileged users inside the jail will be able to mount and unmount the 72041c0675eSMartin Matuskaprocfs file system. 72141c0675eSMartin MatuskaThis permission is effective only together with 72241c0675eSMartin Matuska.Va allow.mount 72306e36338SBenjamin Kadukand only when 72441c0675eSMartin Matuska.Va enforce_statfs 72541c0675eSMartin Matuskais set to a value lower than 2. 726f19e47d6SMarcelo Araujo.It Va allow.mount.linprocfs 727f19e47d6SMarcelo Araujoprivileged users inside the jail will be able to mount and unmount the 728f19e47d6SMarcelo Araujolinprocfs file system. 729f19e47d6SMarcelo AraujoThis permission is effective only together with 730f19e47d6SMarcelo Araujo.Va allow.mount 731f19e47d6SMarcelo Araujoand only when 732f19e47d6SMarcelo Araujo.Va enforce_statfs 733f19e47d6SMarcelo Araujois set to a value lower than 2. 734f19e47d6SMarcelo Araujo.It Va allow.mount.linsysfs 735f19e47d6SMarcelo Araujoprivileged users inside the jail will be able to mount and unmount the 736f19e47d6SMarcelo Araujolinsysfs file system. 737f19e47d6SMarcelo AraujoThis permission is effective only together with 738f19e47d6SMarcelo Araujo.Va allow.mount 739f19e47d6SMarcelo Araujoand only when 740f19e47d6SMarcelo Araujo.Va enforce_statfs 741f19e47d6SMarcelo Araujois set to a value lower than 2. 7422454886eSXin LI.It Va allow.mount.tmpfs 7432454886eSXin LIprivileged users inside the jail will be able to mount and unmount the 7442454886eSXin LItmpfs file system. 7452454886eSXin LIThis permission is effective only together with 7462454886eSXin LI.Va allow.mount 74706e36338SBenjamin Kadukand only when 7482454886eSXin LI.Va enforce_statfs 7492454886eSXin LIis set to a value lower than 2. 750e7af90abSMartin Matuska.It Va allow.mount.zfs 751e7af90abSMartin Matuskaprivileged users inside the jail will be able to mount and unmount the 752e7af90abSMartin MatuskaZFS file system. 753e7af90abSMartin MatuskaThis permission is effective only together with 754e7af90abSMartin Matuska.Va allow.mount 75506e36338SBenjamin Kadukand only when 756e7af90abSMartin Matuska.Va enforce_statfs 757638f3782SMartin Matuskais set to a value lower than 2. 758638f3782SMartin MatuskaSee 7591df198cfSGleb Popov.Xr zfs-jail 8 760e7af90abSMartin Matuskafor information on how to configure the ZFS filesystem to operate from 761e7af90abSMartin Matuskawithin a jail. 762be963beeSMarcelo Araujo.It Va allow.vmm 763be963beeSMarcelo AraujoThe jail may access 764be963beeSMarcelo Araujo.Xr vmm 4 . 765be963beeSMarcelo AraujoThis flag is only available when the 766be963beeSMarcelo Araujo.Xr vmm 4 767be963beeSMarcelo Araujokernel module is loaded. 7685d6cb09dSJamie Gritton.It Va linux 7695d6cb09dSJamie GrittonDetermine how a jail's Linux emulation environment appears. 7705d6cb09dSJamie GrittonA value of 7715d6cb09dSJamie Gritton.Dq inherit 7725d6cb09dSJamie Grittonwill keep the same environment, and 7735d6cb09dSJamie Gritton.Dq new 7745fda0d60SAndriy Gaponwill give the jail its own environment (still originally inherited when 7755d6cb09dSJamie Grittonthe jail is created). 7765d6cb09dSJamie Gritton.It Va linux.osname , linux.osrelease , linux.oss_version 7775d6cb09dSJamie GrittonThe Linux OS name, OS release, and OSS version associated with this jail. 77852a510acSJamie Gritton.It Va sysvmsg 77952a510acSJamie GrittonAllow access to SYSV IPC message primitives. 78052a510acSJamie GrittonIf set to 78152a510acSJamie Gritton.Dq inherit , 78252a510acSJamie Grittonall IPC objects on the system are visible to this jail, whether they 78352a510acSJamie Grittonwere created by the jail itself, the base system, or other jails. 78452a510acSJamie GrittonIf set to 78552a510acSJamie Gritton.Dq new , 78652a510acSJamie Grittonthe jail will have its own key namespace, and can only see the objects 78752a510acSJamie Grittonthat it has created; 78852a510acSJamie Grittonthe system (or parent jail) has access to the jail's objects, but not to 78952a510acSJamie Grittonits keys. 79052a510acSJamie GrittonIf set to 79152a510acSJamie Gritton.Dq disable , 79252a510acSJamie Grittonthe jail cannot perform any sysvmsg-related system calls. 793a8702c83SJamie Gritton.It Va sysvsem, sysvshm 79452a510acSJamie GrittonAllow access to SYSV IPC semaphore and shared memory primitives, in the 79552a510acSJamie Grittonsame manner as 79652a510acSJamie Gritton.Va sysvmsg . 79763875db5SJamie Gritton.It Va zfs.mount_snapshot 798ae1a0648SJamie GrittonWhen set to 1, jailed users may access the contents of ZFS snapshots 799ae1a0648SJamie Grittonunder the filesystem's 80063875db5SJamie Gritton.Pa .zfs 80163875db5SJamie Grittondirectory. 80263875db5SJamie GrittonIf 80363875db5SJamie Gritton.Va allow.mount.zfs 80463875db5SJamie Grittonis set, the snapshots may also be mounted. 8055d6cb09dSJamie Gritton.El 8065d6cb09dSJamie Gritton.Pp 80706e36338SBenjamin KadukThere are pseudo-parameters that are not passed to the kernel, but are 8082671ee73SJamie Grittonused by 8092671ee73SJamie Gritton.Nm 81006e36338SBenjamin Kadukto set up the jail environment, often by running specified commands 8112671ee73SJamie Grittonwhen jails are created or removed. 8122671ee73SJamie GrittonThe 8132671ee73SJamie Gritton.Va exec.* 8142671ee73SJamie Grittoncommand parameters are 8152671ee73SJamie Gritton.Xr sh 1 81606e36338SBenjamin Kadukcommand lines that are run in either the system or jail environment. 8177ec72d48SDru LavigneThey may be given multiple values, which would run the specified 8182671ee73SJamie Grittoncommands in sequence. 819344c81a1SWarren BlockAll commands must succeed (return a zero exit status), or the jail will 82006e36338SBenjamin Kaduknot be created or removed, as appropriate. 8212671ee73SJamie Gritton.Pp 8222671ee73SJamie GrittonThe pseudo-parameters are: 8232671ee73SJamie Gritton.Bl -tag -width indent 82466005c45SRyan Moeller.It Va exec.prepare 82566005c45SRyan MoellerCommand(s) to run in the system environment to prepare a jail for creation. 82666005c45SRyan MoellerThese commands are executed before assigning IP addresses and mounting 82766005c45SRyan Moellerfilesystems, so they may be used to create a new jail filesystem if it does 82866005c45SRyan Moellernot already exist. 8292671ee73SJamie Gritton.It Va exec.prestart 83006e36338SBenjamin KadukCommand(s) to run in the system environment before a jail is created. 831f6c0e63bSAlexander Leidinger.It Va exec.created 832f6c0e63bSAlexander LeidingerCommand(s) to run in the system environment right after a jail has been 833f6c0e63bSAlexander Leidingercreated, but before commands (or services) get executed in the jail. 8342671ee73SJamie Gritton.It Va exec.start 83506e36338SBenjamin KadukCommand(s) to run in the jail environment when a jail is created. 8362671ee73SJamie GrittonA typical command to run is 8372671ee73SJamie Gritton.Dq sh /etc/rc . 8382671ee73SJamie Gritton.It Va command 8392671ee73SJamie GrittonA synonym for 8402671ee73SJamie Gritton.Va exec.start 84106e36338SBenjamin Kadukfor use when specifying a jail directly on the command line. 8422671ee73SJamie GrittonUnlike other parameters whose value is a single string, 8432671ee73SJamie Gritton.Va command 8442671ee73SJamie Grittonuses the remainder of the 8452671ee73SJamie Gritton.Nm 8462671ee73SJamie Grittoncommand line as its own arguments. 8472671ee73SJamie Gritton.It Va exec.poststart 8482671ee73SJamie GrittonCommand(s) to run in the system environment after a jail is created, 8492671ee73SJamie Grittonand after any 8502671ee73SJamie Gritton.Va exec.start 8512671ee73SJamie Grittoncommands have completed. 8522671ee73SJamie Gritton.It Va exec.prestop 8532671ee73SJamie GrittonCommand(s) to run in the system environment before a jail is removed. 8542671ee73SJamie Gritton.It Va exec.stop 85506e36338SBenjamin KadukCommand(s) to run in the jail environment before a jail is removed, 8562671ee73SJamie Grittonand after any 8572671ee73SJamie Gritton.Va exec.prestop 8582671ee73SJamie Grittoncommands have completed. 8592671ee73SJamie GrittonA typical command to run is 8605fda0d60SAndriy Gapon.Dq sh /etc/rc.shutdown jail . 8612671ee73SJamie Gritton.It Va exec.poststop 8622671ee73SJamie GrittonCommand(s) to run in the system environment after a jail is removed. 86366005c45SRyan Moeller.It Va exec.release 86466005c45SRyan MoellerCommand(s) to run in the system environment after all other actions are done. 86566005c45SRyan MoellerThese commands are executed after unmounting filesystems and removing IP 86666005c45SRyan Moelleraddresses, so they may be used to remove a jail filesystem if it is no longer 86766005c45SRyan Moellerneeded. 8682671ee73SJamie Gritton.It Va exec.clean 8692671ee73SJamie GrittonRun commands in a clean environment. 8702671ee73SJamie GrittonThe environment is discarded except for 8712671ee73SJamie Gritton.Ev HOME , SHELL , TERM 8722671ee73SJamie Grittonand 8732671ee73SJamie Gritton.Ev USER . 8742671ee73SJamie Gritton.Ev HOME 8752671ee73SJamie Grittonand 8762671ee73SJamie Gritton.Ev SHELL 8772671ee73SJamie Grittonare set to the target login's default values. 8782671ee73SJamie Gritton.Ev USER 8792671ee73SJamie Grittonis set to the target login. 8802671ee73SJamie Gritton.Ev TERM 8812671ee73SJamie Grittonis imported from the current environment. 8825cf70549SJamie Gritton.Ev PATH 8835cf70549SJamie Grittonis set to "/bin:/usr/bin". 8842671ee73SJamie GrittonThe environment variables from the login class capability database for the 8852671ee73SJamie Grittontarget login are also set. 8865cf70549SJamie GrittonIf a user is specified (as with 8875cf70549SJamie Gritton.Va exec.jail_user ) , 8885cf70549SJamie Grittoncommands are run from that (possibly jailed) user's directory. 8892671ee73SJamie Gritton.It Va exec.jail_user 89006e36338SBenjamin KadukThe user to run commands as, when running in the jail environment. 8912671ee73SJamie GrittonThe default is to run the commands as the current user. 8922671ee73SJamie Gritton.It Va exec.system_jail_user 8932671ee73SJamie GrittonThis boolean option looks for the 8942671ee73SJamie Gritton.Va exec.jail_user 8952671ee73SJamie Grittonin the system 8962671ee73SJamie Gritton.Xr passwd 5 89706e36338SBenjamin Kadukfile, instead of in the jail's file. 8982671ee73SJamie Gritton.It Va exec.system_user 8992671ee73SJamie GrittonThe user to run commands as, when running in the system environment. 9002671ee73SJamie GrittonThe default is to run the commands as the current user. 9012671ee73SJamie Gritton.It Va exec.timeout 9024b829b3eSGavin AtkinsonThe maximum amount of time to wait for a command to complete, in 9034b829b3eSGavin Atkinsonseconds. 9044b829b3eSGavin AtkinsonIf a command is still running after this timeout has passed, 90506e36338SBenjamin Kadukthe jail will not be created or removed, as appropriate. 9062671ee73SJamie Gritton.It Va exec.consolelog 9072671ee73SJamie GrittonA file to direct command output (stdout and stderr) to. 9082671ee73SJamie Gritton.It Va exec.fib 90906e36338SBenjamin KadukThe FIB (routing table) to set when running commands inside the jail. 9102671ee73SJamie Gritton.It Va stop.timeout 91106e36338SBenjamin KadukThe maximum amount of time to wait for a jail's processes to exit 9122671ee73SJamie Grittonafter sending them a 9132671ee73SJamie Gritton.Dv SIGTERM 9142671ee73SJamie Grittonsignal (which happens after the 915344c81a1SWarren Block.Va exec.stop 916344c81a1SWarren Blockcommands have completed). 91706e36338SBenjamin KadukAfter this many seconds have passed, the jail will be removed, which 9182671ee73SJamie Grittonwill kill any remaining processes. 9192671ee73SJamie GrittonIf this is set to zero, no 9202671ee73SJamie Gritton.Dv SIGTERM 92106e36338SBenjamin Kadukis sent and the jail is immediately removed. 9222671ee73SJamie GrittonThe default is 10 seconds. 9232671ee73SJamie Gritton.It Va interface 92406e36338SBenjamin KadukA network interface to add the jail's IP addresses 9252671ee73SJamie Gritton.Va ( ip4.addr 9262671ee73SJamie Grittonand 9272671ee73SJamie Gritton.Va ip6.addr ) 9282671ee73SJamie Grittonto. 9292671ee73SJamie GrittonAn alias for each address will be added to the interface before the 93006e36338SBenjamin Kadukjail is created, and will be removed from the interface after the 93106e36338SBenjamin Kadukjail is removed. 932fbd868c9SHiroki Sato.It Va ip4.addr 93306e36338SBenjamin KadukIn addition to the IP addresses that are passed to the kernel, an 934946ea17fSAllan Judeinterface, netmask and additional parameters (as supported by 935b22b6abdSSteven Hartland.Xr ifconfig 8 Ns ) 936b22b6abdSSteven Hartlandmay also be specified, in the form 937b22b6abdSSteven Hartland.Dq Ar interface Ns | Ns Ar ip-address Ns / Ns Ar netmask param ... . 9382671ee73SJamie GrittonIf an interface is given before the IP address, an alias for the address 9392671ee73SJamie Grittonwill be added to that interface, as it is with the 9402671ee73SJamie Gritton.Va interface 94106e36338SBenjamin Kadukparameter. 94206e36338SBenjamin KadukIf a netmask in either dotted-quad or CIDR form is given 94306e36338SBenjamin Kadukafter an IP address, it will be used when adding the IP alias. 944b22b6abdSSteven HartlandIf additional parameters are specified then they will also be used when 945b22b6abdSSteven Hartlandadding the IP alias. 946fbd868c9SHiroki Sato.It Va ip6.addr 9472671ee73SJamie GrittonIn addition to the IP addresses that are passed to the kernel, 948b22b6abdSSteven Hartlandan interface, prefix and additional parameters (as supported by 949b22b6abdSSteven Hartland.Xr ifconfig 8 Ns ) 950b22b6abdSSteven Hartlandmay also be specified, in the form 951b22b6abdSSteven Hartland.Dq Ar interface Ns | Ns Ar ip-address Ns / Ns Ar prefix param ... . 9522671ee73SJamie Gritton.It Va vnet.interface 953*48c738b0SMark JohnstonA list of network interfaces to give to a vnet-enabled jail after is it created. 954*48c738b0SMark JohnstonThe interfaces will automatically be released when the jail is removed. 955e0dfe185SAlexander Leidinger.It Va zfs.dataset 956e0dfe185SAlexander LeidingerA list of ZFS datasets to be attached to the jail. 957e0dfe185SAlexander LeidingerThis requires 958e0dfe185SAlexander Leidinger.Va allow.mount.zfs 959e0dfe185SAlexander Leidingerto be set. 960e0dfe185SAlexander LeidingerSee 961e0dfe185SAlexander Leidinger.Xr zfs-jail 8 962e0dfe185SAlexander Leidingerfor information on how to configure a ZFS dataset to be operated from 963e0dfe185SAlexander Leidingerwithin a jail. 9642671ee73SJamie Gritton.It Va ip_hostname 9652671ee73SJamie GrittonResolve the 9662671ee73SJamie Gritton.Va host.hostname 9672671ee73SJamie Grittonparameter and add all IP addresses returned by the resolver 9682671ee73SJamie Grittonto the list of addresses 96906e36338SBenjamin Kaduk.Po Va ip4.addr 9702671ee73SJamie Grittonor 97106e36338SBenjamin Kaduk.Va ip6.addr Pc 97206e36338SBenjamin Kadukfor this jail. 9732671ee73SJamie GrittonThis may affect default address selection for outgoing IPv4 connections 97406e36338SBenjamin Kadukfrom jails. 9752671ee73SJamie GrittonThe address first returned by the resolver for each address family 97606e36338SBenjamin Kadukwill be used as the primary address. 9772671ee73SJamie Gritton.It Va mount 9782671ee73SJamie GrittonA filesystem to mount before creating the jail (and to unmount after 9792671ee73SJamie Grittonremoving it), given as a single 9802671ee73SJamie Gritton.Xr fstab 5 9812671ee73SJamie Grittonline. 9822671ee73SJamie Gritton.It Va mount.fstab 9832671ee73SJamie GrittonAn 9842671ee73SJamie Gritton.Xr fstab 5 9852671ee73SJamie Grittonformat file containing filesystems to mount before creating a jail. 9862671ee73SJamie Gritton.It Va mount.devfs 9872671ee73SJamie GrittonMount a 9881a720cbeSAlexander Ziaee.Xr devfs 4 989fbd868c9SHiroki Satofilesystem on the chrooted 990fbd868c9SHiroki Sato.Pa /dev 991fbd868c9SHiroki Satodirectory, and apply the ruleset in the 9920c4d49e9SJamie Gritton.Va devfs_ruleset 9930c4d49e9SJamie Grittonparameter (or a default of ruleset 4: devfsrules_jail) 99406e36338SBenjamin Kadukto restrict the devices visible inside the jail. 995fbd868c9SHiroki Sato.It Va mount.fdescfs 996fbd868c9SHiroki SatoMount a 9971a720cbeSAlexander Ziaee.Xr fdescfs 4 998fbd868c9SHiroki Satofilesystem on the chrooted 999fbd868c9SHiroki Sato.Pa /dev/fd 1000fbd868c9SHiroki Satodirectory. 100107a7869fSJamie Gritton.It Va mount.procfs 100207a7869fSJamie GrittonMount a 10031a720cbeSAlexander Ziaee.Xr procfs 4 100407a7869fSJamie Grittonfilesystem on the chrooted 100507a7869fSJamie Gritton.Pa /proc 100607a7869fSJamie Grittondirectory. 10072671ee73SJamie Gritton.It Va allow.dying 1008ed31b3f4SJamie GrittonThis is deprecated and has no effect. 1009ed31b3f4SJamie GrittonIt used to allow making changes to a 10102671ee73SJamie Gritton.Va dying 10112671ee73SJamie Grittonjail. 1012ed31b3f4SJamie GrittonNow such jails are always replaced when a new jail is created with the same 1013ed31b3f4SJamie Gritton.Va jid 1014ed31b3f4SJamie Grittonor 1015ed31b3f4SJamie Gritton.Va name . 10162671ee73SJamie Gritton.It Va depend 10172671ee73SJamie GrittonSpecify a jail (or jails) that this jail depends on. 1018ab9604e1SJamie GrittonWhen this jail is to be created, any jail(s) it depends on must already exist. 1019ab9604e1SJamie GrittonIf not, they will be created automatically, up to the completion of the last 10202671ee73SJamie Gritton.Va exec.poststart 10212671ee73SJamie Grittoncommand, before any action will taken to create this jail. 10222671ee73SJamie GrittonWhen jails are removed the opposite is true: 1023ab9604e1SJamie Grittonthis jail will be removed, up to the last 10242671ee73SJamie Gritton.Va exec.poststop 1025ab9604e1SJamie Grittoncommand, before any jail(s) it depends on are stopped. 10262671ee73SJamie Gritton.El 10272671ee73SJamie Gritton.Sh EXAMPLES 1028a5ca5c1aSRobert WatsonJails are typically set up using one of two philosophies: either to 1029a5ca5c1aSRobert Watsonconstrain a specific application (possibly running with privilege), or 1030eba9a3d1SRuslan Ermilovto create a 1031eba9a3d1SRuslan Ermilov.Dq "virtual system image" 1032eba9a3d1SRuslan Ermilovrunning a variety of daemons and services. 1033eba9a3d1SRuslan ErmilovIn both cases, a fairly complete file system install of 1034eba9a3d1SRuslan Ermilov.Fx 1035eba9a3d1SRuslan Ermilovis 1036a5ca5c1aSRobert Watsonrequired, so as to provide the necessary command line tools, daemons, 10373e580b38SDaniel Harrislibraries, application configuration files, etc. 1038a5ca5c1aSRobert WatsonHowever, for a virtual server configuration, a fair amount of 103906e36338SBenjamin Kadukadditional work is required so as to replace the 1040eba9a3d1SRuslan Ermilov.Dq boot 1041eba9a3d1SRuslan Ermilovprocess. 10423e580b38SDaniel HarrisThis manual page documents the configuration steps necessary to support 104306e36338SBenjamin Kadukeither of these steps, although the configuration steps may need to be 1044a5ca5c1aSRobert Watsonrefined based on local requirements. 10451a6ec3e8SRuslan Ermilov.Ss "Setting up a Jail Directory Tree" 1046fd891a57SGiorgos KeramidasTo set up a jail directory tree containing an entire 10473551a1c5SRuslan Ermilov.Fx 1048fd891a57SGiorgos Keramidasdistribution, the following 1049fd891a57SGiorgos Keramidas.Xr sh 1 1050fd891a57SGiorgos Keramidascommand script can be used: 1051203be093SMateusz Piotrowski.Bd -literal -offset indent 1052df99b423SPoul-Henning KampD=/here/is/the/jail 1053df99b423SPoul-Henning Kampcd /usr/src 10540f3f5331SBenedict Reuschlingmkdir -p $D 10559a67c2cdSRobert Watsonmake world DESTDIR=$D 1056c0dc3446SPoul-Henning Kampmake distribution DESTDIR=$D 1057df99b423SPoul-Henning Kamp.Ed 1058c579474cSPoul-Henning Kamp.Pp 10593e580b38SDaniel HarrisIn many cases this example would put far more in the jail than needed. 10603e580b38SDaniel HarrisIn the other extreme case a jail might contain only one file: 1061c579474cSPoul-Henning Kampthe executable to be run in the jail. 1062c579474cSPoul-Henning Kamp.Pp 106306e36338SBenjamin KadukWe recommend experimentation, and caution that it is a lot easier to 10643551a1c5SRuslan Ermilovstart with a 10653551a1c5SRuslan Ermilov.Dq fat 10663551a1c5SRuslan Ermilovjail and remove things until it stops working, 10673551a1c5SRuslan Ermilovthan it is to start with a 10683551a1c5SRuslan Ermilov.Dq thin 10693551a1c5SRuslan Ermilovjail and add things until it works. 10701a6ec3e8SRuslan Ermilov.Ss "Setting Up a Jail" 107105181f63SChris CostelloDo what was described in 10721a6ec3e8SRuslan Ermilov.Sx "Setting Up a Jail Directory Tree" 10731a6ec3e8SRuslan Ermilovto build the jail directory tree. 10741a6ec3e8SRuslan ErmilovFor the sake of this example, we will 107505181f63SChris Costelloassume you built it in 10762671ee73SJamie Gritton.Pa /data/jail/testjail , 10772671ee73SJamie Grittonfor a jail named 10782671ee73SJamie Gritton.Dq testjail . 10791a6ec3e8SRuslan ErmilovSubstitute below as needed with your 108005181f63SChris Costelloown directory, IP address, and hostname. 1081a5ca5c1aSRobert Watson.Ss "Setting up the Host Environment" 108206e36338SBenjamin KadukFirst, set up the real system's environment to be 108305181f63SChris Costello.Dq jail-friendly . 108405181f63SChris CostelloFor consistency, we will refer to the parent box as the 10851a6ec3e8SRuslan Ermilov.Dq "host environment" , 108605181f63SChris Costelloand to the jailed virtual machine as the 10871a6ec3e8SRuslan Ermilov.Dq "jail environment" . 108806e36338SBenjamin KadukSince jails are implemented using IP aliases, one of the first things to do 108905181f63SChris Costellois to disable IP services on the host system that listen on all local 10901a6ec3e8SRuslan ErmilovIP addresses for a service. 1091a5ca5c1aSRobert WatsonIf a network service is present in the host environment that binds all 1092a5ca5c1aSRobert Watsonavailable IP addresses rather than specific IP addresses, it may service 1093413628a7SBjoern A. Zeebrequests sent to jail IP addresses if the jail did not bind the port. 10941a6ec3e8SRuslan ErmilovThis means changing 109569bd852dSMike Pritchard.Xr inetd 8 109669bd852dSMike Pritchardto only listen on the 10971a6ec3e8SRuslan Ermilovappropriate IP address, and so forth. 10981a6ec3e8SRuslan ErmilovAdd the following to 109905181f63SChris Costello.Pa /etc/rc.conf 110005181f63SChris Costelloin the host environment: 110105181f63SChris Costello.Bd -literal -offset indent 110205181f63SChris Costellosendmail_enable="NO" 1103f855cc4fSBjoern A. Zeebinetd_flags="-wW -a 192.0.2.23" 11043b8a7d4fSMaxim Konovalovrpcbind_enable="NO" 110505181f63SChris Costello.Ed 110605181f63SChris Costello.Pp 1107f855cc4fSBjoern A. Zeeb.Li 192.0.2.23 11081a6ec3e8SRuslan Ermilovis the native IP address for the host system, in this example. 11091a6ec3e8SRuslan ErmilovDaemons that run out of 1110c2edcb1aSRobert Watson.Xr inetd 8 111106e36338SBenjamin Kadukcan be easily configured to use only the specified host IP address. 11121a6ec3e8SRuslan ErmilovOther daemons 11131a6ec3e8SRuslan Ermilovwill need to be manually configured \(em for some this is possible through 1114c2edcb1aSRobert Watson.Xr rc.conf 5 11153e580b38SDaniel Harrisflags entries; for others it is necessary to modify per-application 111606e36338SBenjamin Kadukconfiguration files, or to recompile the application. 1117a5ca5c1aSRobert WatsonThe following frequently deployed services must have their individual 1118a5ca5c1aSRobert Watsonconfiguration files modified to limit the application to listening 1119a5ca5c1aSRobert Watsonto a specific IP address: 112005181f63SChris Costello.Pp 1121a5ca5c1aSRobert WatsonTo configure 1122a5ca5c1aSRobert Watson.Xr sshd 8 , 1123a5ca5c1aSRobert Watsonit is necessary to modify 1124a5ca5c1aSRobert Watson.Pa /etc/ssh/sshd_config . 1125a5ca5c1aSRobert Watson.Pp 1126a5ca5c1aSRobert WatsonTo configure 1127c2edcb1aSRobert Watson.Xr sendmail 8 , 1128a5ca5c1aSRobert Watsonit is necessary to modify 1129a5ca5c1aSRobert Watson.Pa /etc/mail/sendmail.cf . 1130a5ca5c1aSRobert Watson.Pp 1131a5ca5c1aSRobert WatsonIn addition, a number of services must be recompiled in order to run 1132a5ca5c1aSRobert Watsonthem in the host environment. 1133a5ca5c1aSRobert WatsonThis includes most applications providing services using 1134a5ca5c1aSRobert Watson.Xr rpc 3 , 1135a5ca5c1aSRobert Watsonsuch as 1136a5ca5c1aSRobert Watson.Xr rpcbind 8 , 1137a5ca5c1aSRobert Watson.Xr nfsd 8 , 1138c2edcb1aSRobert Watsonand 1139a5ca5c1aSRobert Watson.Xr mountd 8 . 1140a5ca5c1aSRobert WatsonIn general, applications for which it is not possible to specify which 1141a5ca5c1aSRobert WatsonIP address to bind should not be run in the host environment unless they 1142a5ca5c1aSRobert Watsonshould also service requests sent to jail IP addresses. 1143979d474aSDima DorfmanAttempting to serve 1144c2edcb1aSRobert WatsonNFS from the host environment may also cause confusion, and cannot be 1145c2edcb1aSRobert Watsoneasily reconfigured to use only specific IPs, as some NFS services are 11461a6ec3e8SRuslan Ermilovhosted directly from the kernel. 11473e580b38SDaniel HarrisAny third-party network software running 1148c2edcb1aSRobert Watsonin the host environment should also be checked and configured so that it 114906e36338SBenjamin Kadukdoes not bind all IP addresses, which would result in those services also 1150c2edcb1aSRobert Watsonappearing to be offered by the jail environments. 1151c2edcb1aSRobert Watson.Pp 1152c2edcb1aSRobert WatsonOnce 1153c2edcb1aSRobert Watsonthese daemons have been disabled or fixed in the host environment, it is 1154c2edcb1aSRobert Watsonbest to reboot so that all daemons are in a known state, to reduce the 1155c2edcb1aSRobert Watsonpotential for confusion later (such as finding that when you send mail 1156c2edcb1aSRobert Watsonto a jail, and its sendmail is down, the mail is delivered to the host, 1157eba9a3d1SRuslan Ermilovetc.). 1158eba9a3d1SRuslan Ermilov.Ss "Configuring the Jail" 11593e580b38SDaniel HarrisStart any jail for the first time without configuring the network 11601a6ec3e8SRuslan Ermilovinterface so that you can clean it up a little and set up accounts. 11611a6ec3e8SRuslan ErmilovAs 116206e36338SBenjamin Kadukwith any machine (virtual or not), you will need to set a root password, time 11631a6ec3e8SRuslan Ermilovzone, etc. 1164a5ca5c1aSRobert WatsonSome of these steps apply only if you intend to run a full virtual server 11653e580b38SDaniel Harrisinside the jail; others apply both for constraining a particular application 11663e580b38SDaniel Harrisor for running a virtual server. 116705181f63SChris Costello.Pp 11689395ecb1SRobert WatsonStart a shell in the jail: 116973d0971bSJamie Gritton.Bd -literal -offset indent 1170994e8550SRobert Watsonjail -c path=/data/jail/testjail mount.devfs \\ 1171994e8550SRobert Watson host.hostname=testhostname ip4.addr=192.0.2.100 \\ 1172994e8550SRobert Watson command=/bin/sh 117373d0971bSJamie Gritton.Ed 11741a6ec3e8SRuslan Ermilov.Pp 11753e580b38SDaniel HarrisAssuming no errors, you will end up with a shell prompt within the jail. 11761a6ec3e8SRuslan ErmilovYou can now run 1177951de554SBjoern Heidotting.Xr bsdconfig 8 117805181f63SChris Costelloand do the post-install configuration to set various configuration options, 11791a6ec3e8SRuslan Ermilovor perform these actions manually by editing 11801a6ec3e8SRuslan Ermilov.Pa /etc/rc.conf , 11811a6ec3e8SRuslan Ermilovetc. 118205181f63SChris Costello.Pp 118305181f63SChris Costello.Bl -bullet -offset indent -compact 118405181f63SChris Costello.It 118511af798cSTilman KeskinozConfigure 118611af798cSTilman Keskinoz.Pa /etc/resolv.conf 118706e36338SBenjamin Kadukso that name resolution within the jail will work correctly. 118811af798cSTilman Keskinoz.It 1189d98722bcSRobert WatsonRun 1190d98722bcSRobert Watson.Xr newaliases 1 11911a6ec3e8SRuslan Ermilovto quell 11921a6ec3e8SRuslan Ermilov.Xr sendmail 8 11931a6ec3e8SRuslan Ermilovwarnings. 1194d98722bcSRobert Watson.It 119506e36338SBenjamin KadukSet a root password, probably different from the real host system. 119605181f63SChris Costello.It 119706e36338SBenjamin KadukSet the timezone. 119805181f63SChris Costello.It 119906e36338SBenjamin KadukAdd accounts for users in the jail environment. 120005181f63SChris Costello.It 120106e36338SBenjamin KadukInstall any packages the environment requires. 120205181f63SChris Costello.El 120305181f63SChris Costello.Pp 1204c2edcb1aSRobert WatsonYou may also want to perform any package-specific configuration (web servers, 12051a6ec3e8SRuslan ErmilovSSH servers, etc), patch up 12061a6ec3e8SRuslan Ermilov.Pa /etc/syslog.conf 12071a6ec3e8SRuslan Ermilovso it logs as you would like, etc. 1208a5ca5c1aSRobert WatsonIf you are not using a virtual server, you may wish to modify 1209a5ca5c1aSRobert Watson.Xr syslogd 8 1210a5ca5c1aSRobert Watsonin the host environment to listen on the syslog socket in the jail 1211a5ca5c1aSRobert Watsonenvironment; in this example, the syslog socket would be stored in 12122671ee73SJamie Gritton.Pa /data/jail/testjail/var/run/log . 121305181f63SChris Costello.Pp 121405181f63SChris CostelloExit from the shell, and the jail will be shut down. 12151a6ec3e8SRuslan Ermilov.Ss "Starting the Jail" 121605181f63SChris CostelloYou are now ready to restart the jail and bring up the environment with 12171a6ec3e8SRuslan Ermilovall of its daemons and other programs. 12182671ee73SJamie GrittonCreate an entry for the jail in 12192671ee73SJamie Gritton.Pa /etc/jail.conf : 122005181f63SChris Costello.Bd -literal -offset indent 12212671ee73SJamie Grittontestjail { 12222671ee73SJamie Gritton path = /tmp/jail/testjail; 12232671ee73SJamie Gritton mount.devfs; 12242671ee73SJamie Gritton host.hostname = testhostname; 12252671ee73SJamie Gritton ip4.addr = 192.0.2.100; 1226ffda6790SBrooks Davis interface = em0; 12272671ee73SJamie Gritton exec.start = "/bin/sh /etc/rc"; 12285fda0d60SAndriy Gapon exec.stop = "/bin/sh /etc/rc.shutdown jail"; 12292671ee73SJamie Gritton} 123005181f63SChris Costello.Ed 123105181f63SChris Costello.Pp 12322671ee73SJamie GrittonTo start a virtual server environment, 12332671ee73SJamie Gritton.Pa /etc/rc 12342671ee73SJamie Grittonis run to launch various daemons and services, and 12352671ee73SJamie Gritton.Pa /etc/rc.shutdown 12362671ee73SJamie Grittonis run to shut them down when the jail is removed. 12372671ee73SJamie GrittonIf you are running a single application in the jail, 12382671ee73SJamie Grittonsubstitute the command used to start the application for 12392671ee73SJamie Gritton.Dq /bin/sh /etc/rc ; 12402671ee73SJamie Grittonthere may be some script available to cleanly shut down the application, 12412671ee73SJamie Grittonor it may be sufficient to go without a stop command, and have 12422671ee73SJamie Gritton.Nm 12432671ee73SJamie Grittonsend 12442671ee73SJamie Gritton.Dv SIGTERM 12452671ee73SJamie Grittonto the application. 12462671ee73SJamie Gritton.Pp 12472671ee73SJamie GrittonStart the jail by running: 12482671ee73SJamie Gritton.Bd -literal -offset indent 12492671ee73SJamie Grittonjail -c testjail 12502671ee73SJamie Gritton.Ed 12512671ee73SJamie Gritton.Pp 12522671ee73SJamie GrittonA few warnings may be produced; however, it should all work properly. 1253f2e366a1SSheldon HearnYou should be able to see 125405181f63SChris Costello.Xr inetd 8 , 125505181f63SChris Costello.Xr syslogd 8 , 125605181f63SChris Costelloand other processes running within the jail using 125705181f63SChris Costello.Xr ps 1 , 125805181f63SChris Costellowith the 12591a6ec3e8SRuslan Ermilov.Ql J 12601a6ec3e8SRuslan Ermilovflag appearing beside jailed processes. 126106e36338SBenjamin KadukTo see an active list of jails, use 126206e36338SBenjamin Kaduk.Xr jls 8 . 126306e36338SBenjamin KadukIf 126406e36338SBenjamin Kaduk.Xr sshd 8 126506e36338SBenjamin Kadukis enabled in the jail environment, you should be able to 126606e36338SBenjamin Kaduk.Xr ssh 1 12671a6ec3e8SRuslan Ermilovto the hostname or IP address of the jailed environment, and log 126869bd852dSMike Pritchardin using the accounts you created previously. 126923fe4fa2SChristian Brueffer.Pp 127023fe4fa2SChristian BruefferIt is possible to have jails started at boot time. 127123fe4fa2SChristian BruefferPlease refer to the 127223fe4fa2SChristian Brueffer.Dq jail_* 127323fe4fa2SChristian Brueffervariables in 127423fe4fa2SChristian Brueffer.Xr rc.conf 5 127523fe4fa2SChristian Bruefferfor more information. 12761a6ec3e8SRuslan Ermilov.Ss "Managing the Jail" 127705181f63SChris CostelloNormal machine shutdown commands, such as 127805181f63SChris Costello.Xr halt 8 , 127905181f63SChris Costello.Xr reboot 8 , 128005181f63SChris Costelloand 128105181f63SChris Costello.Xr shutdown 8 , 12821a6ec3e8SRuslan Ermilovcannot be used successfully within the jail. 12832671ee73SJamie GrittonTo kill all processes from within a jail, you may use one of the 12842671ee73SJamie Grittonfollowing commands, depending on what you want to accomplish: 12851a6ec3e8SRuslan Ermilov.Bd -literal -offset indent 12861a6ec3e8SRuslan Ermilovkill -TERM -1 12871a6ec3e8SRuslan Ermilovkill -KILL -1 12881a6ec3e8SRuslan Ermilov.Ed 128905181f63SChris Costello.Pp 129005181f63SChris CostelloThis will send the 12911a6ec3e8SRuslan Ermilov.Dv SIGTERM 129205181f63SChris Costelloor 12931a6ec3e8SRuslan Ermilov.Dv SIGKILL 129406e36338SBenjamin Kaduksignals to all processes in the jail \(em be careful not to run this from 12952671ee73SJamie Grittonthe host environment! 12962671ee73SJamie GrittonOnce all of the jail's processes have died, unless the jail was created 12972671ee73SJamie Grittonwith the 12982671ee73SJamie Gritton.Va persist 12992671ee73SJamie Grittonparameter, the jail will be removed. 13001a6ec3e8SRuslan ErmilovDepending on 130105181f63SChris Costellothe intended use of the jail, you may also want to run 130205181f63SChris Costello.Pa /etc/rc.shutdown 13031a6ec3e8SRuslan Ermilovfrom within the jail. 13042671ee73SJamie Gritton.Pp 1305203be093SMateusz PiotrowskiTo shut down the jail from the outside, simply remove it with: 1306203be093SMateusz Piotrowski.Bd -literal -offset indent 1307203be093SMateusz Piotrowskijail -r 1308203be093SMateusz Piotrowski.Ed 1309203be093SMateusz Piotrowski.Pp 13102671ee73SJamie Grittonwhich will run any commands specified by 13112671ee73SJamie Gritton.Va exec.stop , 13122671ee73SJamie Grittonand then send 13132671ee73SJamie Gritton.Dv SIGTERM 13142671ee73SJamie Grittonand eventually 13152671ee73SJamie Gritton.Dv SIGKILL 13162671ee73SJamie Grittonto any remaining jailed processes. 131705181f63SChris Costello.Pp 13181a6ec3e8SRuslan ErmilovThe 13191a6ec3e8SRuslan Ermilov.Pa /proc/ Ns Ar pid Ns Pa /status 132073d0971bSJamie Grittonfile contains, as its last field, the name of the jail in which the 132105181f63SChris Costelloprocess runs, or 13221a6ec3e8SRuslan Ermilov.Dq Li - 13231a6ec3e8SRuslan Ermilovto indicate that the process is not running within a jail. 13241a6ec3e8SRuslan ErmilovThe 132505181f63SChris Costello.Xr ps 1 132605181f63SChris Costellocommand also shows a 13271a6ec3e8SRuslan Ermilov.Ql J 13281a6ec3e8SRuslan Ermilovflag for processes in a jail. 13292856a282SPawel Jakub Dawidek.Pp 13302856a282SPawel Jakub DawidekYou can also list/kill processes based on their jail ID. 13319d73fabdSRuslan ErmilovTo show processes and their jail ID, use the following command: 13322856a282SPawel Jakub Dawidek.Pp 13339d73fabdSRuslan Ermilov.Dl "ps ax -o pid,jid,args" 13342856a282SPawel Jakub Dawidek.Pp 13352856a282SPawel Jakub DawidekTo show and then kill processes in jail number 3 use the following commands: 13362856a282SPawel Jakub Dawidek.Bd -literal -offset indent 13372856a282SPawel Jakub Dawidekpgrep -lfj 3 13382856a282SPawel Jakub Dawidekpkill -j 3 13392856a282SPawel Jakub Dawidek.Ed 13409d73fabdSRuslan Ermilovor: 13412856a282SPawel Jakub Dawidek.Pp 13429d73fabdSRuslan Ermilov.Dl "killall -j 3" 13430bd0dfaaSBjoern A. Zeeb.Ss "Jails and File Systems" 13440bd0dfaaSBjoern A. ZeebIt is not possible to 13450bd0dfaaSBjoern A. Zeeb.Xr mount 8 13460bd0dfaaSBjoern A. Zeebor 134712aec2f2SBjoern A. Zeeb.Xr umount 8 13480bd0dfaaSBjoern A. Zeebany file system inside a jail unless the file system is marked 1349435d4667SMartin Matuskajail-friendly, the jail's 135073d0971bSJamie Gritton.Va allow.mount 135106e36338SBenjamin Kadukparameter is set, and the jail's 1352435d4667SMartin Matuska.Va enforce_statfs 1353435d4667SMartin Matuskaparameter is lower than 2. 13540bd0dfaaSBjoern A. Zeeb.Pp 13550bd0dfaaSBjoern A. ZeebMultiple jails sharing the same file system can influence each other. 135606e36338SBenjamin KadukFor example, a user in one jail can fill the file system, 13570bd0dfaaSBjoern A. Zeebleaving no space for processes in the other jail. 13580bd0dfaaSBjoern A. ZeebTrying to use 13590bd0dfaaSBjoern A. Zeeb.Xr quota 1 136006e36338SBenjamin Kadukto prevent this will not work either, as the file system quotas 13610bd0dfaaSBjoern A. Zeebare not aware of jails but only look at the user and group IDs. 136206e36338SBenjamin KadukThis means the same user ID in two jails share a single file 13630bd0dfaaSBjoern A. Zeebsystem quota. 13640fe7ed00SJoseph KoshyOne would need to use one file system per jail to make this work. 13651a6ec3e8SRuslan Ermilov.Ss "Sysctl MIB Entries" 136673d0971bSJamie GrittonThe read-only entry 136717d10fccSMaxim Konovalov.Va security.jail.jailed 1368bc84aa4bSRuslan Ermilovcan be used to determine if a process is running inside a jail (value 136917d10fccSMaxim Konovalovis one) or not (value is zero). 137017d10fccSMaxim Konovalov.Pp 137173d0971bSJamie GrittonThe variable 1372cfd6acbbSElvin Aslanov.Va security.jail.jail_max_af_ips 137306e36338SBenjamin Kadukdetermines how may address per address family a jail may have. 137473d0971bSJamie GrittonThe default is 255. 1375f7bb7136SMatteo Riondato.Pp 137676ca6f88SJamie GrittonSome MIB variables have per-jail settings. 137706e36338SBenjamin KadukChanges to these variables by a jailed process do not affect the host 1378d1b10a62SKen Smithenvironment, only the jail environment. 137976ca6f88SJamie GrittonThese variables are 138076ca6f88SJamie Gritton.Va kern.securelevel , 138105e1e482SMariusz Zaborski.Va security.bsd.suser_enabled , 138276ca6f88SJamie Gritton.Va kern.hostname , 138376ca6f88SJamie Gritton.Va kern.domainname , 138476ca6f88SJamie Gritton.Va kern.hostid , 1385d1b10a62SKen Smithand 138676ca6f88SJamie Gritton.Va kern.hostuuid . 138773d0971bSJamie Gritton.Ss "Hierarchical Jails" 138873d0971bSJamie GrittonBy setting a jail's 1389b97457e2SJamie Gritton.Va children.max 139073d0971bSJamie Grittonparameter, processes within a jail may be able to create jails of their own. 139173d0971bSJamie GrittonThese child jails are kept in a hierarchy, with jails only able to see and/or 139273d0971bSJamie Grittonmodify the jails they created (or those jails' children). 139373d0971bSJamie GrittonEach jail has a read-only 139473d0971bSJamie Gritton.Va parent 139573d0971bSJamie Grittonparameter, containing the 139673d0971bSJamie Gritton.Va jid 139773d0971bSJamie Grittonof the jail that created it; a 139873d0971bSJamie Gritton.Va jid 139973d0971bSJamie Grittonof 0 indicates the jail is a child of the current jail (or is a top-level 140073d0971bSJamie Grittonjail if the current process isn't jailed). 140173d0971bSJamie Gritton.Pp 140273d0971bSJamie GrittonJailed processes are not allowed to confer greater permissions than they 140306e36338SBenjamin Kadukthemselves are given, e.g., if a jail is created with 140473d0971bSJamie Gritton.Va allow.nomount , 140573d0971bSJamie Grittonit is not able to create a jail with 140673d0971bSJamie Gritton.Va allow.mount 140773d0971bSJamie Grittonset. 140873d0971bSJamie GrittonSimilarly, such restrictions as 140973d0971bSJamie Gritton.Va ip4.addr 141073d0971bSJamie Grittonand 141173d0971bSJamie Gritton.Va securelevel 141273d0971bSJamie Grittonmay not be bypassed in child jails. 141373d0971bSJamie Gritton.Pp 141473d0971bSJamie GrittonA child jail may in turn create its own child jails if its own 1415b97457e2SJamie Gritton.Va children.max 1416b97457e2SJamie Grittonparameter is set (remember it is zero by default). 141773d0971bSJamie GrittonThese jails are visible to and can be modified by their parent and all 141873d0971bSJamie Grittonancestors. 141973d0971bSJamie Gritton.Pp 142073d0971bSJamie GrittonJail names reflect this hierarchy, with a full name being an MIB-type string 142173d0971bSJamie Grittonseparated by dots. 142273d0971bSJamie GrittonFor example, if a base system process creates a jail 142373d0971bSJamie Gritton.Dq foo , 142473d0971bSJamie Grittonand a process under that jail creates another jail 142573d0971bSJamie Gritton.Dq bar , 142673d0971bSJamie Grittonthen the second jail will be seen as 142773d0971bSJamie Gritton.Dq foo.bar 142873d0971bSJamie Grittonin the base system (though it is only seen as 142973d0971bSJamie Gritton.Dq bar 143073d0971bSJamie Grittonto any processes inside jail 143173d0971bSJamie Gritton.Dq foo ) . 143273d0971bSJamie GrittonJids on the other hand exist in a single space, and each jail must have a 143373d0971bSJamie Grittonunique jid. 143473d0971bSJamie Gritton.Pp 143573d0971bSJamie GrittonLike the names, a child jail's 143673d0971bSJamie Gritton.Va path 14372671ee73SJamie Grittonappears relative to its creator's own 143873d0971bSJamie Gritton.Va path . 143973d0971bSJamie GrittonThis is by virtue of the child jail being created in the chrooted 144073d0971bSJamie Grittonenvironment of the first jail. 144175c13541SPoul-Henning Kamp.Sh SEE ALSO 1442d3bb35d4SMariusz Zaborski.Xr date 1 , 1443ebf5d9bcSMike Barcroft.Xr killall 1 , 1444f3a8d2f9SPawel Jakub Dawidek.Xr lsvfs 1 , 1445d98722bcSRobert Watson.Xr newaliases 1 , 14462856a282SPawel Jakub Dawidek.Xr pgrep 1 , 14472856a282SPawel Jakub Dawidek.Xr pkill 1 , 1448d98722bcSRobert Watson.Xr ps 1 , 14490bd0dfaaSBjoern A. Zeeb.Xr quota 1 , 1450d3bb35d4SMariusz Zaborski.Xr adjtime 2 , 1451d3bb35d4SMariusz Zaborski.Xr clock_settime 2 , 145273d0971bSJamie Gritton.Xr jail_set 2 , 14536e1fc011SGraham Percival.Xr ntp_adjtime 2 , 14541a720cbeSAlexander Ziaee.Xr devfs 4 , 14551a720cbeSAlexander Ziaee.Xr fdescfs 4 , 14561a720cbeSAlexander Ziaee.Xr linprocfs 4 , 14571a720cbeSAlexander Ziaee.Xr linsysfs 4 , 14581a720cbeSAlexander Ziaee.Xr procfs 4 , 1459be963beeSMarcelo Araujo.Xr vmm 4 , 14602671ee73SJamie Gritton.Xr jail.conf 5 , 1461d98722bcSRobert Watson.Xr rc.conf 5 , 1462d98722bcSRobert Watson.Xr sysctl.conf 5 , 1463951de554SBjoern Heidotting.Xr bsdconfig 8 , 14642671ee73SJamie Gritton.Xr chroot 8 , 1465d82dae3eSRobert Watson.Xr devfs 8 , 1466d98722bcSRobert Watson.Xr halt 8 , 1467914f6e62SJoel Dahl.Xr ifconfig 8 , 1468d98722bcSRobert Watson.Xr inetd 8 , 1469ebf5d9bcSMike Barcroft.Xr jexec 8 , 1470ebf5d9bcSMike Barcroft.Xr jls 8 , 147191f9dc84SCraig Rodrigues.Xr mount 8 , 1472c0f94feeSRick Macklem.Xr mountd 8 , 1473c0f94feeSRick Macklem.Xr nfsd 8 , 1474d3bb35d4SMariusz Zaborski.Xr ntpd 8 , 1475d98722bcSRobert Watson.Xr reboot 8 , 1476e287e9b1SRuslan Ermilov.Xr rpcbind 8 , 1477d98722bcSRobert Watson.Xr sendmail 8 , 1478d98722bcSRobert Watson.Xr shutdown 8 , 1479d98722bcSRobert Watson.Xr sysctl 8 , 1480d65e5ff8SMaxim Konovalov.Xr syslogd 8 , 1481cb48780dSShawn Webb.Xr umount 8 , 1482e0dfe185SAlexander Leidinger.Xr zfs-jail 8 , 1483cb48780dSShawn Webb.Xr extattr 9 148475c13541SPoul-Henning Kamp.Sh HISTORY 148575c13541SPoul-Henning KampThe 14864b526751SDima Dorfman.Nm 1487490d5836SPhilippe Charnierutility appeared in 148875c13541SPoul-Henning Kamp.Fx 4.0 . 148973d0971bSJamie GrittonHierarchical/extensible jails were introduced in 149073d0971bSJamie Gritton.Fx 8.0 . 149191b24c18SJamie GrittonThe configuration file was introduced in 1492858b023aSJamie Gritton.Fx 9.1 . 14935e4614feSJeroen Ruigrok van der Werven.Sh AUTHORS 14941a6ec3e8SRuslan Ermilov.An -nosplit 149569bd852dSMike PritchardThe jail feature was written by 149669bd852dSMike Pritchard.An Poul-Henning Kamp 149769bd852dSMike Pritchardfor R&D Associates 1498b5c508fbSRuslan Ermilovwho contributed it to 1499b5c508fbSRuslan Ermilov.Fx . 1500d98722bcSRobert Watson.Pp 15011a6ec3e8SRuslan Ermilov.An Robert Watson 15021a6ec3e8SRuslan Ermilovwrote the extended documentation, found a few bugs, added 150309aa405fSRobert Watsona few new features, and cleaned up the userland jail environment. 1504413628a7SBjoern A. Zeeb.Pp 1505413628a7SBjoern A. Zeeb.An Bjoern A. Zeeb 1506413628a7SBjoern A. Zeebadded multi-IP jail support for IPv4 and IPv6 based on a patch 1507413628a7SBjoern A. Zeeboriginally done by 1508413628a7SBjoern A. Zeeb.An Pawel Jakub Dawidek 1509413628a7SBjoern A. Zeebfor IPv4. 151073d0971bSJamie Gritton.Pp 151173d0971bSJamie Gritton.An James Gritton 15122671ee73SJamie Grittonadded the extensible jail parameters, hierarchical jails, 15132671ee73SJamie Grittonand the configuration file. 1514c2edcb1aSRobert Watson.Sh BUGS 15152671ee73SJamie GrittonIt might be a good idea to add an 15161a6ec3e8SRuslan Ermilovaddress alias flag such that daemons listening on all IPs 15171a6ec3e8SRuslan Ermilov.Pq Dv INADDR_ANY 1518c2edcb1aSRobert Watsonwill not bind on that address, which would facilitate building a safe 1519c2edcb1aSRobert Watsonhost environment such that host daemons do not impose on services offered 15201a6ec3e8SRuslan Ermilovfrom within jails. 15213e580b38SDaniel HarrisCurrently, the simplest answer is to minimize services 152269bd852dSMike Pritchardoffered on the host, possibly limiting it to services offered from 152369bd852dSMike Pritchard.Xr inetd 8 1524c2edcb1aSRobert Watsonwhich is easily configurable. 15251f897ce1SGlen Barber.Sh NOTES 15261f897ce1SGlen BarberGreat care should be taken when managing directories visible within the jail. 15271f897ce1SGlen BarberFor example, if a jailed process has its current working directory set to a 15281f897ce1SGlen Barberdirectory that is moved out of the jail's chroot, then the process may gain 15291f897ce1SGlen Barberaccess to the file space outside of the jail. 15301f897ce1SGlen BarberIt is recommended that directories always be copied, rather than moved, out 15311f897ce1SGlen Barberof a jail. 15326cbae38fSDag-Erling Smørgrav.Pp 15336cbae38fSDag-Erling SmørgravIn addition, there are several ways in which an unprivileged user 15346cbae38fSDag-Erling Smørgravoutside the jail can cooperate with a privileged user inside the jail 15356cbae38fSDag-Erling Smørgravand thereby obtain elevated privileges in the host environment. 15366cbae38fSDag-Erling SmørgravMost of these attacks can be mitigated by ensuring that the jail root 15376cbae38fSDag-Erling Smørgravis not accessible to unprivileged users in the host environment. 15386cbae38fSDag-Erling SmørgravRegardless, as a general rule, untrusted users with privileged access 15396cbae38fSDag-Erling Smørgravto a jail should not be given access to the host environment. 1540