1.\" 2.\" SPDX-License-Identifier: BSD-2-Clause 3.\" 4.\" Copyright (c) 2000, 2003 Robert N. M. Watson 5.\" Copyright (c) 2008-2012 James Gritton 6.\" All rights reserved. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" SUCH DAMAGE. 28.\" 29.Dd December 4, 2025 30.Dt JAIL 8 31.Os 32.Sh NAME 33.Nm jail 34.Nd "manage system jails" 35.Sh SYNOPSIS 36.Ss From Configuration File 37.Nm 38.Op Fl cm 39.Op Fl Cdqv 40.Op Fl f Ar conf_file 41.Op Fl p Ar limit 42.Op Ar jail 43.Nm 44.Op Fl r 45.Op Fl Cqv 46.Op Fl f Ar conf_file 47.Op Fl p Ar limit 48.Op Cm * | Ar jail ... 49.Ss Without Configuration File 50.Nm 51.Op Fl cm 52.Op Fl dhilqv 53.Op Fl J Ar jid_file 54.Op Fl u Ar username 55.Op Fl U Ar username 56.Ar param Ns = Ns Ar value ... 57.Op Cm command Ns = Ns Ar command ... 58.Nm 59.Op Fl rR 60.Op Fl qv 61.Op Cm * | Ar jail ... 62.Ss Show Parameters 63.Nm 64.Op Fl f Ar conf_file 65.Fl e 66.Ar separator 67.Ss Backward Compatibility 68.Nm 69.Op Fl dhilqv 70.Op Fl J Ar jid_file 71.Op Fl u Ar username 72.Op Fl U Ar username 73.Op Fl n Ar jailname 74.Op Fl s Ar securelevel 75.Ar path hostname ip Ns Op Cm \&, Ns Ar ... 76.Ar command ... 77.Sh DESCRIPTION 78The 79.Nm 80utility creates new jails, or modifies or removes existing jails. 81It can also print a list of configured jails and their parameters. 82A jail 83.Pq or Dq prison 84is specified via parameters on the command line, or in the 85.Xr jail.conf 5 86file. 87.Pp 88At least one of the options 89.Fl c , 90.Fl e , 91.Fl m 92or 93.Fl r 94must be specified. 95These options are used alone or in combination to describe the operation to 96perform: 97.Bl -tag -width indent 98.It Fl c 99Create a new jail. 100The jail 101.Va jid 102and 103.Va name 104parameters (if specified on the command line) 105must not refer to an existing jail. 106.It Fl e Ar separator 107Exhibit a list of all configured non-wildcard jails and their parameters. 108No jail creation, modification or removal performed if this option is used. 109The 110.Ar separator 111string is used to separate parameters. 112Use 113.Xr jls 8 114utility to list running jails. 115.It Fl m 116Modify an existing jail. 117One of the 118.Va jid 119or 120.Va name 121parameters must exist and refer to an existing jail. 122Some parameters may not be changed on a running jail. 123.It Fl r 124Remove the 125.Ar jail 126specified by jid or name. 127All jailed processes are killed, and all jails that are 128children of this jail are also 129removed. 130.It Fl rc 131Restart an existing jail. 132The jail is first removed and then re-created, as if 133.Dq Nm Fl r 134and 135.Dq Nm Fl c 136were run in succession. 137.It Fl cm 138Create a jail if it does not exist, or modify the jail if it does exist. 139.It Fl mr 140Modify an existing jail. 141The jail may be restarted if necessary to modify parameters than could 142not otherwise be changed. 143.It Fl cmr 144Create a jail if it doesn't exist, or modify (and possibly restart) the 145jail if it does exist. 146.El 147.Pp 148Other available options are: 149.Bl -tag -width indent 150.It Fl C 151Clean up after an already-removed jail, running commands and operations 152that are typically run following jail removal. 153.It Fl f Ar conf_file 154Use configuration file 155.Ar conf_file 156instead of the default 157.Pa /etc/jail.conf . 158.It Fl h 159Resolve the 160.Va host.hostname 161parameter (or 162.Va hostname ) 163and add all IP addresses returned by the resolver 164to the list of addresses for this jail. 165This is equivalent to the 166.Va ip_hostname 167parameter. 168.It Fl i 169Output (only) the jail identifier of the newly created jail(s). 170This implies the 171.Fl q 172option. 173.It Fl J Ar jid_file 174Write a 175.Ar jid_file 176file, containing the parameters used to start the jail. 177.It Fl l 178Run commands in a clean environment. 179This is deprecated and is equivalent to the exec.clean parameter. 180.It Fl n Ar jailname 181Set the jail's name. 182This is deprecated and is equivalent to the 183.Va name 184parameter. 185.It Fl p Ar limit 186Limit the number of commands from 187.Va exec.* 188that can run simultaneously. 189.It Fl q 190Suppress the message printed whenever a jail is created, modified or removed. 191Only error messages will be printed. 192.It Fl R 193A variation of the 194.Fl r 195option that removes an existing jail without using the configuration file. 196No removal-related parameters for this jail will be used \(em the jail will 197simply be removed. 198.It Fl s Ar securelevel 199Set the 200.Va kern.securelevel 201MIB entry to the specified value inside the newly created jail. 202This is deprecated and is equivalent to the 203.Va securelevel 204parameter. 205.It Fl u Ar username 206The user name from host environment as whom jailed commands should run. 207This is deprecated and is equivalent to the 208.Va exec.jail_user 209and 210.Va exec.system_jail_user 211parameters. 212.It Fl U Ar username 213The user name from the jailed environment as whom jailed commands should run. 214This is deprecated and is equivalent to the 215.Va exec.jail_user 216parameter. 217.It Fl v 218Print a message on every operation, such as running commands and 219mounting filesystems. 220.It Fl d 221This is deprecated and is equivalent to the 222.Va allow.dying 223parameter, which is also deprecated. 224It used to allow making changes to a 225.Va dying 226jail. 227Now such jails are always replaced when a new jail is created with the same 228.Va jid 229or 230.Va name . 231.El 232.Pp 233If no arguments are given after the options, the operation (except 234remove) will be performed on all jails specified in the 235.Xr jail.conf 5 236file. 237A single argument of a jail name will operate only on the specified jail. 238The 239.Fl r 240and 241.Fl R 242options can also remove running jails that aren't in the 243.Xr jail.conf 5 244file, specified by name or jid. 245.Pp 246An argument of 247.Dq * 248is a wildcard that will operate on all jails, regardless of whether 249they appear in 250.Xr jail.conf 5 ; 251this is the surest way for 252.Fl r 253to remove all jails. 254If hierarchical jails exist, a partial-matching wildcard definition may 255be specified. 256For example, an argument of 257.Dq foo.* 258would apply to jails with names like 259.Dq foo.bar 260and 261.Dq foo.bar.baz . 262.Pp 263A jail may also be specified via parameters directly on the command line in 264.Dq name=value 265form, ignoring the contents of 266.Xr jail.conf 5 . 267For backward compatibility, the command line may also have four fixed 268parameters, without names: 269.Ar path , 270.Ar hostname , 271.Ar ip , 272and 273.Ar command . 274.Ss Jail Parameters 275Parameters in the 276.Xr jail.conf 5 277file, or on the command line, are generally of the form 278.Dq name=value . 279Some parameters are boolean, and do not have a value but are set by the 280name alone with or without a 281.Dq no 282prefix, e.g. 283.Va persist 284or 285.Va nopersist . 286They can also be given the values 287.Dq true 288and 289.Dq false . 290Other parameters may have more than one value, specified as a 291comma-separated list, or with 292.Dq += 293in the configuration file (see 294.Xr jail.conf 5 295for details). 296List-based parameters may also be specified multiple times on the command 297line, i.e., 298.Dq name=value1,value2 299and 300.Dq name=value1 name=value2 301are equivalent for such parameters. 302.Pp 303The 304.Nm 305utility recognizes two classes of parameters. 306There are the true jail 307parameters that are passed to the kernel when the jail is created, 308which can be seen with 309.Xr jls 8 , 310and can (usually) be changed with 311.Dq Nm Fl m . 312Then there are pseudo-parameters that are only used by 313.Nm 314itself. 315.Pp 316Jails have a set of core parameters, and kernel modules can add their own 317jail parameters. 318The current set of available parameters can be retrieved via 319.Dq Nm sysctl Fl d Va security.jail.param . 320Any parameters not set will be given default values, often based on the 321current environment. 322The core parameters are: 323.Bl -tag -width indent 324.It Va jid 325The jail identifier. 326This will be assigned automatically to a new jail (or can be explicitly 327set), and can be used to identify the jail for later modification, or 328for such commands as 329.Xr jls 8 330or 331.Xr jexec 8 . 332.It Va name 333The jail name. 334This is an arbitrary string that identifies a jail (except it may not 335contain a 336.Sq \&. ) . 337Like the 338.Va jid , 339it can be passed to later 340.Nm 341commands, or to 342.Xr jls 8 343or 344.Xr jexec 8 . 345If no 346.Va name 347is supplied, a default is assumed that is the same as the 348.Va jid . 349The 350.Va name 351parameter is implied by the 352.Xr jail.conf 5 353file format, and need not be explicitly set when using the configuration 354file. 355.It Va path 356The directory which is to be the root of the jail. 357Any commands run inside the jail, either by 358.Nm 359or from 360.Xr jexec 8 , 361are run from this directory. 362.It Va ip4.addr 363A list of IPv4 addresses assigned to the jail. 364If this is set, the jail is restricted to using only these addresses. 365Any attempts to use other addresses fail, and attempts to use wildcard 366addresses silently use the jailed address instead. 367For IPv4 the first address given will be used as the source address 368when source address selection on unbound sockets cannot find a better 369match. 370It is only possible to start multiple jails with the same IP address 371if none of the jails has more than this single overlapping IP address 372assigned to itself. 373.It Va ip4.saddrsel 374A boolean option to change the formerly mentioned behaviour and disable 375IPv4 source address selection for the jail in favour of the primary 376IPv4 address of the jail. 377Source address selection is enabled by default for all jails and the 378.Va ip4.nosaddrsel 379setting of a parent jail is not inherited for any child jails. 380.It Va ip4 381Control the availability of IPv4 addresses. 382Possible values are 383.Dq inherit 384to allow unrestricted access to all system addresses, 385.Dq new 386to restrict addresses via 387.Va ip4.addr , 388and 389.Dq disable 390to stop the jail from using IPv4 entirely. 391Setting the 392.Va ip4.addr 393parameter implies a value of 394.Dq new . 395.It Va ip6.addr , Va ip6.saddrsel , Va ip6 396A set of IPv6 options for the jail, the counterparts to 397.Va ip4.addr , 398.Va ip4.saddrsel 399and 400.Va ip4 401above. 402.It Va vnet 403Create the jail with its own virtual network stack, 404with its own network interfaces, addresses, routing table, etc. 405The kernel must have been compiled with the 406.Sy VIMAGE option 407for this to be available. 408Possible values are 409.Dq inherit 410to use the system network stack, possibly with restricted IP addresses, 411and 412.Dq new 413to create a new network stack. 414.It Va host.hostname 415The hostname of the jail. 416Other similar parameters are 417.Va host.domainname , 418.Va host.hostuuid 419and 420.Va host.hostid . 421.It Va host 422Set the origin of hostname and related information. 423Possible values are 424.Dq inherit 425to use the system information and 426.Dq new 427for the jail to use the information from the above fields. 428Setting any of the above fields implies a value of 429.Dq new . 430.It Va securelevel 431The value of the jail's 432.Va kern.securelevel 433sysctl. 434A jail never has a lower securelevel than its parent system, but by 435setting this parameter it may have a higher one. 436If the system securelevel is changed, any jail securelevels will be at 437least as secure. 438.It Va devfs_ruleset 439The number of the devfs ruleset that is enforced for mounting devfs in 440this jail. 441A value of zero (default) means no ruleset is enforced. 442Descendant jails inherit the parent jail's devfs ruleset enforcement. 443Mounting devfs inside a jail is possible only if the 444.Va allow.mount 445and 446.Va allow.mount.devfs 447permissions are effective and 448.Va enforce_statfs 449is set to a value lower than 2. 450Devfs rules and rulesets cannot be viewed or modified from inside a jail. 451.Pp 452NOTE: It is important that only appropriate device nodes in devfs be 453exposed to a jail; access to disk devices in the jail may permit processes 454in the jail to bypass the jail sandboxing by modifying files outside of 455the jail. 456See 457.Xr devfs 8 458for information on how to use devfs rules to limit access to entries 459in the per-jail devfs. 460A simple devfs ruleset for jails is available as ruleset #4 in 461.Pa /etc/defaults/devfs.rules . 462.It Va children.max 463The number of child jails allowed to be created by this jail (or by 464other jails under this jail). 465This limit is zero by default, indicating the jail is not allowed to 466create child jails. 467See the 468.Sx "Hierarchical Jails" 469section for more information. 470.It Va children.cur 471The number of descendants of this jail, including its own child jails 472and any jails created under them. 473.It Va enforce_statfs 474This determines what information processes in a jail are able to get 475about mount points. 476It affects the behaviour of the following syscalls: 477.Xr statfs 2 , 478.Xr fstatfs 2 , 479.Xr getfsstat 2 , 480and 481.Xr fhstatfs 2 482(as well as similar compatibility syscalls). 483When set to 0, all mount points are available without any restrictions. 484When set to 1, only mount points below the jail's chroot directory are 485visible. 486In addition to that, the path to the jail's chroot directory is removed 487from the front of their pathnames. 488When set to 2 (default), above syscalls can operate only on a mount-point 489where the jail's chroot directory is located. 490.It Va persist 491Setting this boolean parameter allows a jail to exist without any 492processes. 493Normally, a command is run as part of jail creation, and then the jail 494is destroyed as its last process exits. 495A new jail must have either the 496.Va persist 497parameter or 498.Va exec.start 499or 500.Va command 501pseudo-parameter set. 502.It Va cpuset.id 503The ID of the cpuset associated with this jail (read-only). 504.It Va dying 505This is true if the jail is in the process of shutting down (read-only). 506.It Va mac.label 507The 508.Xr mac 3 509label associated with this jail. 510Note that a 511.Dq jail 512entry in 513.Xr mac.conf 5 514may need to be configured in order to retrieve the MAC label. 515.It Va parent 516The 517.Va jid 518of the parent of this jail, or zero if this is a top-level jail 519(read-only). 520.It Va osrelease 521The string for the jail's 522.Va kern.osrelease 523sysctl and uname -r. 524.It Va osreldate 525The number for the jail's 526.Va kern.osreldate 527and uname -K. 528.It Va meta , Va env 529An arbitrary string associated with the jail. 530Its maximum buffer size is controlled by the global 531.Va security.jail.meta_maxbufsize 532sysctl, which can only be adjusted by the non-jailed root user. 533While the 534.Va meta 535is hidden from the jail, the 536.Va env 537is readable through the 538.Va security.jail.env 539sysctl. 540.Pp 541Each buffer can be treated as a set of key=value\\n strings. 542In order to add or replace a specific key the 543.Va meta.keyname=value 544or 545.Va env.keyname=value 546parameter notations must be used. 547While 548.Va meta.keyname= 549or 550.Va env.keyname= 551reset the value to an empty string, the 552.Va meta.keyname 553or 554.Va env.keyname 555notations, without the equal sign, remove the given key. 556Respectively, the same 557.Va meta.keyname 558or 559.Va env.keyname 560notations are used to query a specific key while reading jail parameters 561using such commands as 562.Xr jls 8 . 563Multiple keys can be queried or modified with a single command. 564.It Va allow.* 565Some restrictions of the jail environment may be set on a per-jail 566basis. 567With the exception of 568.Va allow.set_hostname 569and 570.Va allow.reserved_ports , 571these boolean parameters are off by default. 572.Bl -tag -width indent 573.It Va allow.set_hostname 574The jail's hostname may be changed via 575.Xr hostname 1 576or 577.Xr sethostname 3 . 578.It Va allow.sysvipc 579A process within the jail has access to System V IPC primitives. 580This is deprecated in favor of the per-module parameters (see below). 581When this parameter is set, it is equivalent to setting 582.Va sysvmsg , 583.Va sysvsem , 584and 585.Va sysvshm 586all to 587.Dq inherit . 588.It Va allow.raw_sockets 589The jail root is allowed to create raw sockets. 590Setting this parameter allows utilities like 591.Xr ping 8 592and 593.Xr traceroute 8 594to operate inside the jail. 595If this is set, the source IP addresses are enforced to comply 596with the IP address bound to the jail, regardless of whether or not 597the 598.Dv IP_HDRINCL 599flag has been set on the socket. 600Since raw sockets can be used to configure and interact with various 601network subsystems, extra caution should be used where privileged access 602to jails is given out to untrusted parties. 603.It Va allow.chflags 604Normally, privileged users inside a jail are treated as unprivileged by 605.Xr chflags 2 . 606When this parameter is set, such users are treated as privileged, and 607may manipulate system file flags subject to the usual constraints on 608.Va kern.securelevel . 609.It Va allow.mount 610privileged users inside the jail will be able to mount and unmount file 611system types marked as jail-friendly. 612The 613.Xr lsvfs 1 614command can be used to find file system types available for mount from 615within a jail. 616This permission is effective only if 617.Va enforce_statfs 618is set to a value lower than 2. 619.It Va allow.mount.devfs 620privileged users inside the jail will be able to mount and unmount the 621devfs file system. 622This permission is effective only together with 623.Va allow.mount 624and only when 625.Va enforce_statfs 626is set to a value lower than 2. 627The devfs ruleset should be restricted from the default by using the 628.Va devfs_ruleset 629option. 630.It Va allow.quotas 631The jail root may administer quotas on the jail's filesystem(s). 632This includes filesystems that the jail may share with other jails or 633with non-jailed parts of the system. 634.It Va allow.read_msgbuf 635Jailed users may read the kernel message buffer. 636If the 637.Va security.bsd.unprivileged_read_msgbuf 638MIB entry is zero, this will be restricted to the root user. 639.It Va allow.socket_af 640Sockets within a jail are normally restricted to IPv4, IPv6, local 641(UNIX), and route. 642This allows access to other protocol stacks that have not had jail 643functionality added to them. 644.It Va allow.mlock 645Locking or unlocking physical pages in memory are normally not available 646within a jail. 647When this parameter is set, users may 648.Xr mlock 2 649or 650.Xr munlock 2 651memory subject to 652.Va security.bsd.unprivileged_mlock 653and resource limits. 654.It Va allow.nfsd 655The 656.Xr mountd 8 , 657.Xr nfsd 8 , 658.Xr nfsuserd 8 , 659.Xr gssd 8 660and 661.Xr rpc.tlsservd 8 662daemons are permitted to run inside a properly configured vnet-enabled jail. 663The jail's root must be a file system mount point and 664.Va enforce_statfs 665must not be set to 0, so that 666.Xr mountd 8 667can export file systems visible within the jail. 668.Va enforce_statfs 669must be set to 1 if file systems mounted under the 670jail's file system need to be exported by 671.Xr mount 8 . 672For exporting only the jail's file system, a setting of 2 673is sufficient. 674If the kernel configuration does not include the 675.Sy NFSD 676option, 677.Pa nfsd.ko 678must be loaded outside of the jails. 679This is normally done by adding 680.Dq nfsd 681to 682.Va kld_list 683in the 684.Xr rc.conf 5 685file outside of the jails. 686Similarily, if the 687.Xr gssd 8 688is to be run in a jail, either the kernel 689.Sy KGSSAPI 690option needs to be specified or 691.Dq kgssapi 692and 693.Dq kgssapi_krb5 694need to be in 695.Va kld_list 696in the 697.Xr rc.conf 5 698file outside of the jails. 699.It Va allow.reserved_ports 700The jail root may bind to ports lower than 1024. 701.It Va allow.unprivileged_parent_tampering 702Unprivileged processes in the jail's parent may tamper with processes of the 703same UID in the jail. 704This includes the ability to signal, debug, and 705.Xr cpuset 1 706processes that belong to the jail. 707.It Va allow.unprivileged_proc_debug 708Unprivileged processes in the jail may use debugging facilities. 709.It Va allow.suser 710The value of the jail's 711.Va security.bsd.suser_enabled 712sysctl. 713The super-user will be disabled automatically if its parent system has it 714disabled. 715The super-user is enabled by default. 716.It Va allow.extattr 717Allow privileged processes in the jail to manipulate filesystem extended 718attributes in the system namespace. 719.It Va allow.adjtime 720Allow privileged processes in the jail to slowly adjusting global operating 721system time. 722For example through utilities like 723.Xr ntpd 8 . 724.It Va allow.settime 725Allow privileged processes in the jail to set global operating system data 726and time. 727For example through utilities like 728.Xr date 1 . 729This permission includes also 730.Va allow.adjtime . 731.It Va allow.routing 732Allow privileged process in the non-VNET jail to modify the system routing 733table. 734.It Va allow.setaudit 735Allow privileged processes in the jail to set 736.Xr audit 4 737session state using 738.Xr setaudit 2 739and related system calls. 740This is useful, for example, for allowing a jailed 741.Xr sshd 8 742to set the audit user ID for an authenticated session. 743However, it gives jailed processes the ability to modify or disable audit 744session state, so should be configured with care. 745.El 746.El 747.Pp 748Kernel modules may add their own parameters, which only exist when the 749module is loaded. 750These are typically headed under a parameter named after the module, 751with values of 752.Dq inherit 753to give the jail full use of the module, 754.Dq new 755to encapsulate the jail in some module-specific way, 756and 757.Dq disable 758to make the module unavailable to the jail. 759There also may be other parameters to define jail behavior within the module. 760Module-specific parameters include: 761.Bl -tag -width indent 762.It Va allow.mount.fdescfs 763privileged users inside the jail will be able to mount and unmount the 764fdescfs file system. 765This permission is effective only together with 766.Va allow.mount 767and only when 768.Va enforce_statfs 769is set to a value lower than 2. 770.It Va allow.mount.fusefs 771privileged users inside the jail will be able to mount and unmount 772fuse-based file systems. 773This permission is effective only together with 774.Va allow.mount 775and only when 776.Va enforce_statfs 777is set to a value lower than 2. 778.It Va allow.mount.nullfs 779privileged users inside the jail will be able to mount and unmount the 780nullfs file system. 781This permission is effective only together with 782.Va allow.mount 783and only when 784.Va enforce_statfs 785is set to a value lower than 2. 786.It Va allow.mount.procfs 787privileged users inside the jail will be able to mount and unmount the 788procfs file system. 789This permission is effective only together with 790.Va allow.mount 791and only when 792.Va enforce_statfs 793is set to a value lower than 2. 794.It Va allow.mount.linprocfs 795privileged users inside the jail will be able to mount and unmount the 796linprocfs file system. 797This permission is effective only together with 798.Va allow.mount 799and only when 800.Va enforce_statfs 801is set to a value lower than 2. 802.It Va allow.mount.linsysfs 803privileged users inside the jail will be able to mount and unmount the 804linsysfs file system. 805This permission is effective only together with 806.Va allow.mount 807and only when 808.Va enforce_statfs 809is set to a value lower than 2. 810.It Va allow.mount.tmpfs 811privileged users inside the jail will be able to mount and unmount the 812tmpfs file system. 813This permission is effective only together with 814.Va allow.mount 815and only when 816.Va enforce_statfs 817is set to a value lower than 2. 818.It Va allow.mount.zfs 819privileged users inside the jail will be able to mount and unmount the 820ZFS file system. 821This permission is effective only together with 822.Va allow.mount 823and only when 824.Va enforce_statfs 825is set to a value lower than 2. 826See 827.Xr zfs-jail 8 828for information on how to configure the ZFS filesystem to operate from 829within a jail. 830.It Va allow.vmm 831The jail may access 832.Xr vmm 4 . 833This flag is only available when the 834.Xr vmm 4 835kernel module is loaded. 836.It Va allow.vmm_ppt 837The jail may configure PCI passtrough devices for use by 838.Xr vmm 4 839virtual machine guests. 840This allows privileged users inside the jail to manipulate physical devices 841claimed by the 842.Dv ppt 843driver, and thus must not be configured in untrusted jails. 844This flag is only available when the 845.Xr vmm 4 846kernel module is loaded. 847.It Va linux 848Determine how a jail's Linux emulation environment appears. 849A value of 850.Dq inherit 851will keep the same environment, and 852.Dq new 853will give the jail its own environment (still originally inherited when 854the jail is created). 855.It Va linux.osname , linux.osrelease , linux.oss_version 856The Linux OS name, OS release, and OSS version associated with this jail. 857.It Va sysvmsg 858Allow access to SYSV IPC message primitives. 859If set to 860.Dq inherit , 861all IPC objects on the system are visible to this jail, whether they 862were created by the jail itself, the base system, or other jails. 863If set to 864.Dq new , 865the jail will have its own key namespace, and can only see the objects 866that it has created; 867the system (or parent jail) has access to the jail's objects, but not to 868its keys. 869If set to 870.Dq disable , 871the jail cannot perform any sysvmsg-related system calls. 872.It Va sysvsem, sysvshm 873Allow access to SYSV IPC semaphore and shared memory primitives, in the 874same manner as 875.Va sysvmsg . 876.It Va zfs.mount_snapshot 877When set to 1, jailed users may access the contents of ZFS snapshots 878under the filesystem's 879.Pa .zfs 880directory. 881If 882.Va allow.mount.zfs 883is set, the snapshots may also be mounted. 884.El 885.Pp 886There are pseudo-parameters that are not passed to the kernel, but are 887used by 888.Nm 889to set up the jail environment, often by running specified commands 890when jails are created or removed. 891The 892.Va exec.* 893command parameters are 894.Xr sh 1 895command lines that are run in either the system or jail environment. 896They may be given multiple values, which would run the specified 897commands in sequence. 898All commands must succeed (return a zero exit status), or the jail will 899not be created or removed, as appropriate. 900.Pp 901The following variables are added to the environment: 902.Bl -tag -width indent -offset indent 903.It Ev JID 904The 905.Va jid , 906or jail identifier. 907.It Ev JNAME 908The 909.Va name 910of the jail. 911.It Ev JPATH 912The 913.Va path 914of the jail. 915.El 916.Pp 917The pseudo-parameters are: 918.Bl -tag -width indent 919.It Va exec.prepare 920Command(s) to run in the system environment to prepare a jail for creation. 921These commands are executed before assigning IP addresses and mounting 922filesystems, so they may be used to create a new jail filesystem if it does 923not already exist. 924.It Va exec.prestart 925Command(s) to run in the system environment before a jail is created. 926.It Va exec.created 927Command(s) to run in the system environment right after a jail has been 928created, but before commands (or services) get executed in the jail. 929.It Va exec.start 930Command(s) to run in the jail environment when a jail is created. 931A typical command to run is 932.Dq sh /etc/rc . 933.It Va command 934A synonym for 935.Va exec.start 936for use when specifying a jail directly on the command line. 937Unlike other parameters whose value is a single string, 938.Va command 939uses the remainder of the 940.Nm 941command line as its own arguments. 942.It Va exec.poststart 943Command(s) to run in the system environment after a jail is created, 944and after any 945.Va exec.start 946commands have completed. 947.It Va exec.prestop 948Command(s) to run in the system environment before a jail is removed. 949.It Va exec.stop 950Command(s) to run in the jail environment before a jail is removed, 951and after any 952.Va exec.prestop 953commands have completed. 954A typical command to run is 955.Dq sh /etc/rc.shutdown jail . 956.It Va exec.poststop 957Command(s) to run in the system environment after a jail is removed. 958.It Va exec.release 959Command(s) to run in the system environment after all other actions are done. 960These commands are executed after unmounting filesystems and removing IP 961addresses, so they may be used to remove a jail filesystem if it is no longer 962needed. 963.It Va exec.clean 964Run commands in a clean environment. 965The environment is discarded except for 966.Ev HOME , SHELL , TERM 967and 968.Ev USER . 969.Ev HOME 970and 971.Ev SHELL 972are set to the target login's default values. 973.Ev USER 974is set to the target login. 975.Ev TERM 976is imported from the current environment. 977.Ev PATH 978is set to "/bin:/usr/bin". 979The environment variables from the login class capability database for the 980target login are also set. 981.Ev JID , 982.Ev JNAME , 983and 984.Ev JPATH 985are not set. 986If a user is specified (as with 987.Va exec.jail_user ) , 988commands are run from that (possibly jailed) user's directory. 989.It Va exec.jail_user 990The user to run commands as, when running in the jail environment. 991The default is to run the commands as the current user. 992.It Va exec.system_jail_user 993This boolean option looks for the 994.Va exec.jail_user 995in the system 996.Xr passwd 5 997file, instead of in the jail's file. 998.It Va exec.system_user 999The user to run commands as, when running in the system environment. 1000The default is to run the commands as the current user. 1001.It Va exec.timeout 1002The maximum amount of time to wait for a command to complete, in 1003seconds. 1004If a command is still running after this timeout has passed, 1005the jail will not be created or removed, as appropriate. 1006.It Va exec.consolelog 1007A file to direct command output (stdout and stderr) to. 1008.It Va exec.fib 1009The FIB (routing table) to set when running commands inside the jail. 1010.It Va stop.timeout 1011The maximum amount of time to wait for a jail's processes to exit 1012after sending them a 1013.Dv SIGTERM 1014signal (which happens after the 1015.Va exec.stop 1016commands have completed). 1017After this many seconds have passed, the jail will be removed, which 1018will kill any remaining processes. 1019If this is set to zero, no 1020.Dv SIGTERM 1021is sent and the jail is immediately removed. 1022The default is 10 seconds. 1023.It Va interface 1024A network interface to add the jail's IP addresses 1025.Va ( ip4.addr 1026and 1027.Va ip6.addr ) 1028to. 1029An alias for each address will be added to the interface before the 1030jail is created, and will be removed from the interface after the 1031jail is removed. 1032.It Va ip4.addr 1033In addition to the IP addresses that are passed to the kernel, an 1034interface, netmask and additional parameters (as supported by 1035.Xr ifconfig 8 ) 1036may also be specified, in the form 1037.Dq Ar interface Ns | Ns Ar ip-address Ns / Ns Ar netmask param ... . 1038If an interface is given before the IP address, an alias for the address 1039will be added to that interface, as it is with the 1040.Va interface 1041parameter. 1042If a netmask in either dotted-quad or CIDR form is given 1043after an IP address, it will be used when adding the IP alias. 1044If additional parameters are specified then they will also be used when 1045adding the IP alias. 1046.It Va ip6.addr 1047In addition to the IP addresses that are passed to the kernel, 1048an interface, prefix and additional parameters (as supported by 1049.Xr ifconfig 8 ) 1050may also be specified, in the form 1051.Dq Ar interface Ns | Ns Ar ip-address Ns / Ns Ar prefix param ... . 1052.It Va vnet.interface 1053A comma separated list of network interfaces to give to a vnet-enabled jail 1054after is it created. 1055The interfaces will automatically be released when the jail is removed. 1056.It Va zfs.dataset 1057A list of ZFS datasets to be attached to the jail. 1058This requires 1059.Va allow.mount.zfs 1060to be set. 1061See 1062.Xr zfs-jail 8 1063for information on how to configure a ZFS dataset to be operated from 1064within a jail. 1065.It Va ip_hostname 1066Resolve the 1067.Va host.hostname 1068parameter and add all IP addresses returned by the resolver 1069to the list of addresses 1070.Po Va ip4.addr 1071or 1072.Va ip6.addr Pc 1073for this jail. 1074This may affect default address selection for outgoing IPv4 connections 1075from jails. 1076The address first returned by the resolver for each address family 1077will be used as the primary address. 1078.It Va mount 1079A filesystem to mount before creating the jail (and to unmount after 1080removing it), given as a single 1081.Xr fstab 5 1082line. 1083.It Va mount.fstab 1084An 1085.Xr fstab 5 1086format file containing filesystems to mount before creating a jail. 1087.It Va mount.devfs 1088Mount a 1089.Xr devfs 4 1090filesystem on the chrooted 1091.Pa /dev 1092directory, and apply the ruleset in the 1093.Va devfs_ruleset 1094parameter (or a default of ruleset 4: devfsrules_jail) 1095to restrict the devices visible inside the jail. 1096.It Va mount.fdescfs 1097Mount a 1098.Xr fdescfs 4 1099filesystem on the chrooted 1100.Pa /dev/fd 1101directory. 1102.It Va mount.procfs 1103Mount a 1104.Xr procfs 4 1105filesystem on the chrooted 1106.Pa /proc 1107directory. 1108.It Va allow.dying 1109This is deprecated and has no effect. 1110It used to allow making changes to a 1111.Va dying 1112jail. 1113Now such jails are always replaced when a new jail is created with the same 1114.Va jid 1115or 1116.Va name . 1117.It Va depend 1118Specify a jail (or jails) that this jail depends on. 1119When this jail is to be created, any jail(s) it depends on must already exist. 1120If not, they will be created automatically, up to the completion of the last 1121.Va exec.poststart 1122command, before any action will taken to create this jail. 1123When jails are removed the opposite is true: 1124this jail will be removed, up to the last 1125.Va exec.poststop 1126command, before any jail(s) it depends on are stopped. 1127.El 1128.Sh EXAMPLES 1129Jails are typically set up using one of two philosophies: either to 1130constrain a specific application (possibly running with privilege), or 1131to create a 1132.Dq "virtual system image" 1133running a variety of daemons and services. 1134In both cases, a fairly complete file system install of 1135.Fx 1136is 1137required, so as to provide the necessary command line tools, daemons, 1138libraries, application configuration files, etc. 1139However, for a virtual server configuration, a fair amount of 1140additional work is required so as to replace the 1141.Dq boot 1142process. 1143This manual page documents the configuration steps necessary to support 1144either of these steps, although the configuration steps may need to be 1145refined based on local requirements. 1146.Ss Setting up a Jail Directory Tree From Source 1147To set up a jail directory tree containing an entire 1148.Fx 1149distribution, the following 1150.Xr sh 1 1151command script can be used: 1152.Bd -literal -offset indent 1153D=/here/is/the/jail 1154cd /usr/src 1155mkdir -p $D 1156make world DESTDIR=$D 1157make distribution DESTDIR=$D 1158.Ed 1159.Ss Setting up a Jail Directory Tree from Distribution Files 1160To set up a jail directory tree containing an entire 1161.Fx 1162distribution, the following 1163.Xr sh 1 1164command script can be used: 1165.Bd -literal -offset indent 1166D=/here/is/the/jail 1167mkdir -p $D 1168tar -xf /usr/freebsd-dist/base.txz -C $D --unlink 1169.Ed 1170.Ss Setting up a Jail Directory Tree from System Packages 1171To set up a jail directory tree containing an selectable 1172.Fx 1173distribution with the packages tech preview, 1174the following command can be used: 1175.Pp 1176.Dl bsdinstall jail /here/is/the/jail 1177.Pp 1178In many cases these examples would put far more in the jail than needed. 1179In the other extreme case a jail might contain only one file: 1180the executable to be run in the jail. 1181.Pp 1182We recommend experimentation, and caution that it is a lot easier to 1183start with a 1184.Dq fat 1185jail and remove things until it stops working, 1186than it is to start with a 1187.Dq thin 1188jail and add things until it works. 1189.Ss "Setting Up a Jail" 1190Do what was described in 1191.Sx "Setting Up a Jail Directory Tree" 1192to build the jail directory tree. 1193For the sake of this example, we will 1194assume you built it in 1195.Pa /data/jail/testjail , 1196for a jail named 1197.Dq testjail . 1198Substitute below as needed with your 1199own directory, IP address, and hostname. 1200.Ss "Setting up the Host Environment" 1201First, set up the real system's environment to be 1202.Dq jail-friendly . 1203For consistency, we will refer to the parent box as the 1204.Dq "host environment" , 1205and to the jailed virtual machine as the 1206.Dq "jail environment" . 1207Since jails are implemented using IP aliases, one of the first things to do 1208is to disable IP services on the host system that listen on all local 1209IP addresses for a service. 1210If a network service is present in the host environment that binds all 1211available IP addresses rather than specific IP addresses, it may service 1212requests sent to jail IP addresses if the jail did not bind the port. 1213This means changing 1214.Xr inetd 8 1215to only listen on the 1216appropriate IP address, and so forth. 1217Add the following to 1218.Pa /etc/rc.conf 1219in the host environment: 1220.Bd -literal -offset indent 1221sendmail_enable="NO" 1222inetd_flags="-wW -a 192.0.2.23" 1223rpcbind_enable="NO" 1224.Ed 1225.Pp 1226.Li 192.0.2.23 1227is the native IP address for the host system, in this example. 1228Daemons that run out of 1229.Xr inetd 8 1230can be easily configured to use only the specified host IP address. 1231Other daemons 1232will need to be manually configured \(em for some this is possible through 1233.Xr rc.conf 5 1234flags entries; for others it is necessary to modify per-application 1235configuration files, or to recompile the application. 1236The following frequently deployed services must have their individual 1237configuration files modified to limit the application to listening 1238to a specific IP address: 1239.Pp 1240To configure 1241.Xr sshd 8 , 1242it is necessary to modify 1243.Pa /etc/ssh/sshd_config . 1244.Pp 1245To configure 1246.Xr sendmail 8 , 1247it is necessary to modify 1248.Pa /etc/mail/sendmail.cf . 1249.Pp 1250In addition, a number of services must be recompiled in order to run 1251them in the host environment. 1252This includes most applications providing services using 1253.Xr rpc 3 , 1254such as 1255.Xr rpcbind 8 , 1256.Xr nfsd 8 , 1257and 1258.Xr mountd 8 . 1259In general, applications for which it is not possible to specify which 1260IP address to bind should not be run in the host environment unless they 1261should also service requests sent to jail IP addresses. 1262Attempting to serve 1263NFS from the host environment may also cause confusion, and cannot be 1264easily reconfigured to use only specific IPs, as some NFS services are 1265hosted directly from the kernel. 1266Any third-party network software running 1267in the host environment should also be checked and configured so that it 1268does not bind all IP addresses, which would result in those services also 1269appearing to be offered by the jail environments. 1270.Pp 1271Once 1272these daemons have been disabled or fixed in the host environment, it is 1273best to reboot so that all daemons are in a known state, to reduce the 1274potential for confusion later (such as finding that when you send mail 1275to a jail, and its sendmail is down, the mail is delivered to the host, 1276etc.). 1277.Ss "Configuring the Jail" 1278Start any jail for the first time without configuring the network 1279interface so that you can clean it up a little and set up accounts. 1280As 1281with any machine (virtual or not), you will need to set a root password, time 1282zone, etc. 1283Some of these steps apply only if you intend to run a full virtual server 1284inside the jail; others apply both for constraining a particular application 1285or for running a virtual server. 1286.Pp 1287Start a shell in the jail: 1288.Bd -literal -offset indent 1289jail -c path=/data/jail/testjail mount.devfs \\ 1290 host.hostname=testhostname ip4.addr=192.0.2.100 \\ 1291 command=/bin/sh 1292.Ed 1293.Pp 1294Assuming no errors, you will end up with a shell prompt within the jail. 1295You can now run 1296.Xr bsdconfig 8 1297and do the post-install configuration to set various configuration options, 1298or perform these actions manually by editing 1299.Pa /etc/rc.conf , 1300etc. 1301.Pp 1302.Bl -bullet -offset indent -compact 1303.It 1304Configure 1305.Pa /etc/resolv.conf 1306so that name resolution within the jail will work correctly. 1307.It 1308Run 1309.Xr newaliases 1 1310to quell 1311.Xr sendmail 8 1312warnings. 1313.It 1314Set a root password, probably different from the real host system. 1315.It 1316Set the timezone. 1317.It 1318Add accounts for users in the jail environment. 1319.It 1320Install any packages the environment requires. 1321.El 1322.Pp 1323You may also want to perform any package-specific configuration (web servers, 1324SSH servers, etc), patch up 1325.Pa /etc/syslog.conf 1326so it logs as you would like, etc. 1327If you are not using a virtual server, you may wish to modify 1328.Xr syslogd 8 1329in the host environment to listen on the syslog socket in the jail 1330environment; in this example, the syslog socket would be stored in 1331.Pa /data/jail/testjail/var/run/log . 1332.Pp 1333Exit from the shell, and the jail will be shut down. 1334.Ss "Starting the Jail" 1335You are now ready to restart the jail and bring up the environment with 1336all of its daemons and other programs. 1337Create an entry for the jail in 1338.Pa /etc/jail.conf : 1339.Bd -literal -offset indent 1340testjail { 1341 path = /tmp/jail/testjail; 1342 mount.devfs; 1343 host.hostname = testhostname; 1344 ip4.addr = 192.0.2.100; 1345 interface = em0; 1346 exec.start = "/bin/sh /etc/rc"; 1347 exec.stop = "/bin/sh /etc/rc.shutdown jail"; 1348} 1349.Ed 1350.Pp 1351To start a virtual server environment, 1352.Pa /etc/rc 1353is run to launch various daemons and services, and 1354.Pa /etc/rc.shutdown 1355is run to shut them down when the jail is removed. 1356If you are running a single application in the jail, 1357substitute the command used to start the application for 1358.Dq /bin/sh /etc/rc ; 1359there may be some script available to cleanly shut down the application, 1360or it may be sufficient to go without a stop command, and have 1361.Nm 1362send 1363.Dv SIGTERM 1364to the application. 1365.Pp 1366Start the jail by running: 1367.Bd -literal -offset indent 1368jail -c testjail 1369.Ed 1370.Pp 1371A few warnings may be produced; however, it should all work properly. 1372You should be able to see 1373.Xr inetd 8 , 1374.Xr syslogd 8 , 1375and other processes running within the jail using 1376.Xr ps 1 , 1377with the 1378.Ql J 1379flag appearing beside jailed processes. 1380To see an active list of jails, use 1381.Xr jls 8 . 1382If 1383.Xr sshd 8 1384is enabled in the jail environment, you should be able to 1385.Xr ssh 1 1386to the hostname or IP address of the jailed environment, and log 1387in using the accounts you created previously. 1388.Pp 1389It is possible to have jails started at boot time. 1390Please refer to the 1391.Dq jail_* 1392variables in 1393.Xr rc.conf 5 1394for more information. 1395.Ss "Managing the Jail" 1396Normal machine shutdown commands, such as 1397.Xr halt 8 , 1398.Xr reboot 8 , 1399and 1400.Xr shutdown 8 , 1401cannot be used successfully within the jail. 1402To kill all processes from within a jail, you may use one of the 1403following commands, depending on what you want to accomplish: 1404.Bd -literal -offset indent 1405kill -TERM -1 1406kill -KILL -1 1407.Ed 1408.Pp 1409This will send the 1410.Dv SIGTERM 1411or 1412.Dv SIGKILL 1413signals to all processes in the jail \(em be careful not to run this from 1414the host environment! 1415Once all of the jail's processes have died, unless the jail was created 1416with the 1417.Va persist 1418parameter, the jail will be removed. 1419Depending on 1420the intended use of the jail, you may also want to run 1421.Pa /etc/rc.shutdown 1422from within the jail. 1423.Pp 1424To shut down the jail from the outside, simply remove it with: 1425.Bd -literal -offset indent 1426jail -r 1427.Ed 1428.Pp 1429which will run any commands specified by 1430.Va exec.stop , 1431and then send 1432.Dv SIGTERM 1433and eventually 1434.Dv SIGKILL 1435to any remaining jailed processes. 1436.Pp 1437The 1438.Pa /proc/ Ns Ar pid Ns Pa /status 1439file contains, as its last field, the name of the jail in which the 1440process runs, or 1441.Dq Li - 1442to indicate that the process is not running within a jail. 1443The 1444.Xr ps 1 1445command also shows a 1446.Ql J 1447flag for processes in a jail. 1448.Pp 1449You can also list/kill processes based on their jail ID. 1450To show processes and their jail ID, use the following command: 1451.Pp 1452.Dl "ps ax -o pid,jid,args" 1453.Pp 1454To show and then kill processes in jail number 3 use the following commands: 1455.Bd -literal -offset indent 1456pgrep -lfj 3 1457pkill -j 3 1458.Ed 1459or: 1460.Pp 1461.Dl "killall -j 3" 1462.Ss "Jails and File Systems" 1463It is not possible to 1464.Xr mount 8 1465or 1466.Xr umount 8 1467any file system inside a jail unless the file system is marked 1468jail-friendly, the jail's 1469.Va allow.mount 1470parameter is set, and the jail's 1471.Va enforce_statfs 1472parameter is lower than 2. 1473.Pp 1474Multiple jails sharing the same file system can influence each other. 1475For example, a user in one jail can fill the file system, 1476leaving no space for processes in the other jail. 1477Trying to use 1478.Xr quota 1 1479to prevent this will not work either, as the file system quotas 1480are not aware of jails but only look at the user and group IDs. 1481This means the same user ID in two jails share a single file 1482system quota. 1483One would need to use one file system per jail to make this work. 1484.Ss "Sysctl MIB Entries" 1485The read-only entry 1486.Va security.jail.jailed 1487can be used to determine if a process is running inside a jail (value 1488is one) or not (value is zero). 1489.Pp 1490The variable 1491.Va security.jail.jail_max_af_ips 1492determines how may address per address family a jail may have. 1493The default is 255. 1494.Pp 1495Some MIB variables have per-jail settings. 1496Changes to these variables by a jailed process do not affect the host 1497environment, only the jail environment. 1498These variables are 1499.Va kern.securelevel , 1500.Va security.bsd.suser_enabled , 1501.Va kern.hostname , 1502.Va kern.domainname , 1503.Va kern.hostid , 1504and 1505.Va kern.hostuuid . 1506.Ss "Hierarchical Jails" 1507By setting a jail's 1508.Va children.max 1509parameter, processes within a jail may be able to create jails of their own. 1510These child jails are kept in a hierarchy, with jails only able to see and/or 1511modify the jails they created (or those jails' children). 1512Each jail has a read-only 1513.Va parent 1514parameter, containing the 1515.Va jid 1516of the jail that created it; a 1517.Va jid 1518of 0 indicates the jail is a child of the current jail (or is a top-level 1519jail if the current process isn't jailed). 1520.Pp 1521Jailed processes are not allowed to confer greater permissions than they 1522themselves are given, e.g., if a jail is created with 1523.Va allow.nomount , 1524it is not able to create a jail with 1525.Va allow.mount 1526set. 1527Similarly, such restrictions as 1528.Va ip4.addr 1529and 1530.Va securelevel 1531may not be bypassed in child jails. 1532.Pp 1533A child jail may in turn create its own child jails if its own 1534.Va children.max 1535parameter is set (remember it is zero by default). 1536These jails are visible to and can be modified by their parent and all 1537ancestors. 1538.Pp 1539Jail names reflect this hierarchy, with a full name being an MIB-type string 1540separated by dots. 1541For example, if a base system process creates a jail 1542.Dq foo , 1543and a process under that jail creates another jail 1544.Dq bar , 1545then the second jail will be seen as 1546.Dq foo.bar 1547in the base system (though it is only seen as 1548.Dq bar 1549to any processes inside jail 1550.Dq foo ) . 1551Jids on the other hand exist in a single space, and each jail must have a 1552unique jid. 1553.Pp 1554Like the names, a child jail's 1555.Va path 1556appears relative to its creator's own 1557.Va path . 1558This is by virtue of the child jail being created in the chrooted 1559environment of the first jail. 1560.Sh SEE ALSO 1561.Xr date 1 , 1562.Xr killall 1 , 1563.Xr lsvfs 1 , 1564.Xr newaliases 1 , 1565.Xr pgrep 1 , 1566.Xr pkill 1 , 1567.Xr ps 1 , 1568.Xr quota 1 , 1569.Xr adjtime 2 , 1570.Xr clock_settime 2 , 1571.Xr jail_set 2 , 1572.Xr ntp_adjtime 2 , 1573.Xr mac 3 , 1574.Xr devfs 4 , 1575.Xr fdescfs 4 , 1576.Xr linprocfs 4 , 1577.Xr linsysfs 4 , 1578.Xr procfs 4 , 1579.Xr vmm 4 , 1580.Xr jail.conf 5 , 1581.Xr mac.conf 5 , 1582.Xr rc.conf 5 , 1583.Xr sysctl.conf 5 , 1584.Xr bsdconfig 8 , 1585.Xr chroot 8 , 1586.Xr devfs 8 , 1587.Xr halt 8 , 1588.Xr ifconfig 8 , 1589.Xr inetd 8 , 1590.Xr jexec 8 , 1591.Xr jls 8 , 1592.Xr mount 8 , 1593.Xr mountd 8 , 1594.Xr nfsd 8 , 1595.Xr ntpd 8 , 1596.Xr reboot 8 , 1597.Xr rpcbind 8 , 1598.Xr sendmail 8 , 1599.Xr shutdown 8 , 1600.Xr sysctl 8 , 1601.Xr syslogd 8 , 1602.Xr umount 8 , 1603.Xr zfs-jail 8 , 1604.Xr extattr 9 1605.Sh HISTORY 1606The 1607.Nm 1608utility appeared in 1609.Fx 4.0 . 1610Hierarchical/extensible jails were introduced in 1611.Fx 8.0 . 1612The configuration file was introduced in 1613.Fx 9.1 . 1614.Sh AUTHORS 1615.An -nosplit 1616The jail feature was written by 1617.An Poul-Henning Kamp 1618for R&D Associates 1619who contributed it to 1620.Fx . 1621.Pp 1622.An Robert Watson 1623wrote the extended documentation, found a few bugs, added 1624a few new features, and cleaned up the userland jail environment. 1625.Pp 1626.An Bjoern A. Zeeb 1627added multi-IP jail support for IPv4 and IPv6 based on a patch 1628originally done by 1629.An Pawel Jakub Dawidek 1630for IPv4. 1631.Pp 1632.An James Gritton 1633added the extensible jail parameters, hierarchical jails, 1634and the configuration file. 1635.Sh BUGS 1636It might be a good idea to add an 1637address alias flag such that daemons listening on all IPs 1638.Pq Dv INADDR_ANY 1639will not bind on that address, which would facilitate building a safe 1640host environment such that host daemons do not impose on services offered 1641from within jails. 1642Currently, the simplest answer is to minimize services 1643offered on the host, possibly limiting it to services offered from 1644.Xr inetd 8 1645which is easily configurable. 1646.Sh NOTES 1647Great care should be taken when managing directories visible within the jail. 1648For example, if a jailed process has its current working directory set to a 1649directory that is moved out of the jail's chroot, then the process may gain 1650access to the file space outside of the jail. 1651It is recommended that directories always be copied, rather than moved, out 1652of a jail. 1653.Pp 1654In addition, there are several ways in which an unprivileged user 1655outside the jail can cooperate with a privileged user inside the jail 1656and thereby obtain elevated privileges in the host environment. 1657Most of these attacks can be mitigated by ensuring that the jail root 1658is not accessible to unprivileged users in the host environment. 1659Regardless, as a general rule, untrusted users with privileged access 1660to a jail should not be given access to the host environment. 1661