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 November 13, 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 parent 507The 508.Va jid 509of the parent of this jail, or zero if this is a top-level jail 510(read-only). 511.It Va osrelease 512The string for the jail's 513.Va kern.osrelease 514sysctl and uname -r. 515.It Va osreldate 516The number for the jail's 517.Va kern.osreldate 518and uname -K. 519.It Va meta , Va env 520An arbitrary string associated with the jail. 521Its maximum buffer size is controlled by the global 522.Va security.jail.meta_maxbufsize 523sysctl, which can only be adjusted by the non-jailed root user. 524While the 525.Va meta 526is hidden from the jail, the 527.Va env 528is readable through the 529.Va security.jail.env 530sysctl. 531.Pp 532Each buffer can be treated as a set of key=value\\n strings. 533In order to add or replace a specific key the 534.Va meta.keyname=value 535or 536.Va env.keyname=value 537parameter notations must be used. 538While 539.Va meta.keyname= 540or 541.Va env.keyname= 542reset the value to an empty string, the 543.Va meta.keyname 544or 545.Va env.keyname 546notations, without the equal sign, remove the given key. 547Respectively, the same 548.Va meta.keyname 549or 550.Va env.keyname 551notations are used to query a specific key while reading jail parameters 552using such commands as 553.Xr jls 8 . 554Multiple keys can be queried or modified with a single command. 555.It Va allow.* 556Some restrictions of the jail environment may be set on a per-jail 557basis. 558With the exception of 559.Va allow.set_hostname 560and 561.Va allow.reserved_ports , 562these boolean parameters are off by default. 563.Bl -tag -width indent 564.It Va allow.set_hostname 565The jail's hostname may be changed via 566.Xr hostname 1 567or 568.Xr sethostname 3 . 569.It Va allow.sysvipc 570A process within the jail has access to System V IPC primitives. 571This is deprecated in favor of the per-module parameters (see below). 572When this parameter is set, it is equivalent to setting 573.Va sysvmsg , 574.Va sysvsem , 575and 576.Va sysvshm 577all to 578.Dq inherit . 579.It Va allow.raw_sockets 580The jail root is allowed to create raw sockets. 581Setting this parameter allows utilities like 582.Xr ping 8 583and 584.Xr traceroute 8 585to operate inside the jail. 586If this is set, the source IP addresses are enforced to comply 587with the IP address bound to the jail, regardless of whether or not 588the 589.Dv IP_HDRINCL 590flag has been set on the socket. 591Since raw sockets can be used to configure and interact with various 592network subsystems, extra caution should be used where privileged access 593to jails is given out to untrusted parties. 594.It Va allow.chflags 595Normally, privileged users inside a jail are treated as unprivileged by 596.Xr chflags 2 . 597When this parameter is set, such users are treated as privileged, and 598may manipulate system file flags subject to the usual constraints on 599.Va kern.securelevel . 600.It Va allow.mount 601privileged users inside the jail will be able to mount and unmount file 602system types marked as jail-friendly. 603The 604.Xr lsvfs 1 605command can be used to find file system types available for mount from 606within a jail. 607This permission is effective only if 608.Va enforce_statfs 609is set to a value lower than 2. 610.It Va allow.mount.devfs 611privileged users inside the jail will be able to mount and unmount the 612devfs file system. 613This permission is effective only together with 614.Va allow.mount 615and only when 616.Va enforce_statfs 617is set to a value lower than 2. 618The devfs ruleset should be restricted from the default by using the 619.Va devfs_ruleset 620option. 621.It Va allow.quotas 622The jail root may administer quotas on the jail's filesystem(s). 623This includes filesystems that the jail may share with other jails or 624with non-jailed parts of the system. 625.It Va allow.read_msgbuf 626Jailed users may read the kernel message buffer. 627If the 628.Va security.bsd.unprivileged_read_msgbuf 629MIB entry is zero, this will be restricted to the root user. 630.It Va allow.socket_af 631Sockets within a jail are normally restricted to IPv4, IPv6, local 632(UNIX), and route. 633This allows access to other protocol stacks that have not had jail 634functionality added to them. 635.It Va allow.mlock 636Locking or unlocking physical pages in memory are normally not available 637within a jail. 638When this parameter is set, users may 639.Xr mlock 2 640or 641.Xr munlock 2 642memory subject to 643.Va security.bsd.unprivileged_mlock 644and resource limits. 645.It Va allow.nfsd 646The 647.Xr mountd 8 , 648.Xr nfsd 8 , 649.Xr nfsuserd 8 , 650.Xr gssd 8 651and 652.Xr rpc.tlsservd 8 653daemons are permitted to run inside a properly configured vnet-enabled jail. 654The jail's root must be a file system mount point and 655.Va enforce_statfs 656must not be set to 0, so that 657.Xr mountd 8 658can export file systems visible within the jail. 659.Va enforce_statfs 660must be set to 1 if file systems mounted under the 661jail's file system need to be exported by 662.Xr mount 8 . 663For exporting only the jail's file system, a setting of 2 664is sufficient. 665If the kernel configuration does not include the 666.Sy NFSD 667option, 668.Pa nfsd.ko 669must be loaded outside of the jails. 670This is normally done by adding 671.Dq nfsd 672to 673.Va kld_list 674in the 675.Xr rc.conf 5 676file outside of the jails. 677Similarily, if the 678.Xr gssd 8 679is to be run in a jail, either the kernel 680.Sy KGSSAPI 681option needs to be specified or 682.Dq kgssapi 683and 684.Dq kgssapi_krb5 685need to be in 686.Va kld_list 687in the 688.Xr rc.conf 5 689file outside of the jails. 690.It Va allow.reserved_ports 691The jail root may bind to ports lower than 1024. 692.It Va allow.unprivileged_parent_tampering 693Unprivileged processes in the jail's parent may tamper with processes of the 694same UID in the jail. 695This includes the ability to signal, debug, and 696.Xr cpuset 1 697processes that belong to the jail. 698.It Va allow.unprivileged_proc_debug 699Unprivileged processes in the jail may use debugging facilities. 700.It Va allow.suser 701The value of the jail's 702.Va security.bsd.suser_enabled 703sysctl. 704The super-user will be disabled automatically if its parent system has it 705disabled. 706The super-user is enabled by default. 707.It Va allow.extattr 708Allow privileged processes in the jail to manipulate filesystem extended 709attributes in the system namespace. 710.It Va allow.adjtime 711Allow privileged processes in the jail to slowly adjusting global operating 712system time. 713For example through utilities like 714.Xr ntpd 8 . 715.It Va allow.settime 716Allow privileged processes in the jail to set global operating system data 717and time. 718For example through utilities like 719.Xr date 1 . 720This permission includes also 721.Va allow.adjtime . 722.It Va allow.routing 723Allow privileged process in the non-VNET jail to modify the system routing 724table. 725.It Va allow.setaudit 726Allow privileged processes in the jail to set 727.Xr audit 4 728session state using 729.Xr setaudit 2 730and related system calls. 731This is useful, for example, for allowing a jailed 732.Xr sshd 8 733to set the audit user ID for an authenticated session. 734However, it gives jailed processes the ability to modify or disable audit 735session state, so should be configured with care. 736.El 737.El 738.Pp 739Kernel modules may add their own parameters, which only exist when the 740module is loaded. 741These are typically headed under a parameter named after the module, 742with values of 743.Dq inherit 744to give the jail full use of the module, 745.Dq new 746to encapsulate the jail in some module-specific way, 747and 748.Dq disable 749to make the module unavailable to the jail. 750There also may be other parameters to define jail behavior within the module. 751Module-specific parameters include: 752.Bl -tag -width indent 753.It Va allow.mount.fdescfs 754privileged users inside the jail will be able to mount and unmount the 755fdescfs file system. 756This permission is effective only together with 757.Va allow.mount 758and only when 759.Va enforce_statfs 760is set to a value lower than 2. 761.It Va allow.mount.fusefs 762privileged users inside the jail will be able to mount and unmount 763fuse-based file systems. 764This permission is effective only together with 765.Va allow.mount 766and only when 767.Va enforce_statfs 768is set to a value lower than 2. 769.It Va allow.mount.nullfs 770privileged users inside the jail will be able to mount and unmount the 771nullfs file system. 772This permission is effective only together with 773.Va allow.mount 774and only when 775.Va enforce_statfs 776is set to a value lower than 2. 777.It Va allow.mount.procfs 778privileged users inside the jail will be able to mount and unmount the 779procfs file system. 780This permission is effective only together with 781.Va allow.mount 782and only when 783.Va enforce_statfs 784is set to a value lower than 2. 785.It Va allow.mount.linprocfs 786privileged users inside the jail will be able to mount and unmount the 787linprocfs file system. 788This permission is effective only together with 789.Va allow.mount 790and only when 791.Va enforce_statfs 792is set to a value lower than 2. 793.It Va allow.mount.linsysfs 794privileged users inside the jail will be able to mount and unmount the 795linsysfs file system. 796This permission is effective only together with 797.Va allow.mount 798and only when 799.Va enforce_statfs 800is set to a value lower than 2. 801.It Va allow.mount.tmpfs 802privileged users inside the jail will be able to mount and unmount the 803tmpfs file system. 804This permission is effective only together with 805.Va allow.mount 806and only when 807.Va enforce_statfs 808is set to a value lower than 2. 809.It Va allow.mount.zfs 810privileged users inside the jail will be able to mount and unmount the 811ZFS file system. 812This permission is effective only together with 813.Va allow.mount 814and only when 815.Va enforce_statfs 816is set to a value lower than 2. 817See 818.Xr zfs-jail 8 819for information on how to configure the ZFS filesystem to operate from 820within a jail. 821.It Va allow.vmm 822The jail may access 823.Xr vmm 4 . 824This flag is only available when the 825.Xr vmm 4 826kernel module is loaded. 827.It Va linux 828Determine how a jail's Linux emulation environment appears. 829A value of 830.Dq inherit 831will keep the same environment, and 832.Dq new 833will give the jail its own environment (still originally inherited when 834the jail is created). 835.It Va linux.osname , linux.osrelease , linux.oss_version 836The Linux OS name, OS release, and OSS version associated with this jail. 837.It Va sysvmsg 838Allow access to SYSV IPC message primitives. 839If set to 840.Dq inherit , 841all IPC objects on the system are visible to this jail, whether they 842were created by the jail itself, the base system, or other jails. 843If set to 844.Dq new , 845the jail will have its own key namespace, and can only see the objects 846that it has created; 847the system (or parent jail) has access to the jail's objects, but not to 848its keys. 849If set to 850.Dq disable , 851the jail cannot perform any sysvmsg-related system calls. 852.It Va sysvsem, sysvshm 853Allow access to SYSV IPC semaphore and shared memory primitives, in the 854same manner as 855.Va sysvmsg . 856.It Va zfs.mount_snapshot 857When set to 1, jailed users may access the contents of ZFS snapshots 858under the filesystem's 859.Pa .zfs 860directory. 861If 862.Va allow.mount.zfs 863is set, the snapshots may also be mounted. 864.El 865.Pp 866There are pseudo-parameters that are not passed to the kernel, but are 867used by 868.Nm 869to set up the jail environment, often by running specified commands 870when jails are created or removed. 871The 872.Va exec.* 873command parameters are 874.Xr sh 1 875command lines that are run in either the system or jail environment. 876They may be given multiple values, which would run the specified 877commands in sequence. 878All commands must succeed (return a zero exit status), or the jail will 879not be created or removed, as appropriate. 880.Pp 881The following variables are added to the environment: 882.Bl -tag -width indent -offset indent 883.It Ev JID 884The 885.Va jid , 886or jail identifier. 887.It Ev JNAME 888The 889.Va name 890of the jail. 891.It Ev JPATH 892The 893.Va path 894of the jail. 895.El 896.Pp 897The pseudo-parameters are: 898.Bl -tag -width indent 899.It Va exec.prepare 900Command(s) to run in the system environment to prepare a jail for creation. 901These commands are executed before assigning IP addresses and mounting 902filesystems, so they may be used to create a new jail filesystem if it does 903not already exist. 904.It Va exec.prestart 905Command(s) to run in the system environment before a jail is created. 906.It Va exec.created 907Command(s) to run in the system environment right after a jail has been 908created, but before commands (or services) get executed in the jail. 909.It Va exec.start 910Command(s) to run in the jail environment when a jail is created. 911A typical command to run is 912.Dq sh /etc/rc . 913.It Va command 914A synonym for 915.Va exec.start 916for use when specifying a jail directly on the command line. 917Unlike other parameters whose value is a single string, 918.Va command 919uses the remainder of the 920.Nm 921command line as its own arguments. 922.It Va exec.poststart 923Command(s) to run in the system environment after a jail is created, 924and after any 925.Va exec.start 926commands have completed. 927.It Va exec.prestop 928Command(s) to run in the system environment before a jail is removed. 929.It Va exec.stop 930Command(s) to run in the jail environment before a jail is removed, 931and after any 932.Va exec.prestop 933commands have completed. 934A typical command to run is 935.Dq sh /etc/rc.shutdown jail . 936.It Va exec.poststop 937Command(s) to run in the system environment after a jail is removed. 938.It Va exec.release 939Command(s) to run in the system environment after all other actions are done. 940These commands are executed after unmounting filesystems and removing IP 941addresses, so they may be used to remove a jail filesystem if it is no longer 942needed. 943.It Va exec.clean 944Run commands in a clean environment. 945The environment is discarded except for 946.Ev HOME , SHELL , TERM 947and 948.Ev USER . 949.Ev HOME 950and 951.Ev SHELL 952are set to the target login's default values. 953.Ev USER 954is set to the target login. 955.Ev TERM 956is imported from the current environment. 957.Ev PATH 958is set to "/bin:/usr/bin". 959The environment variables from the login class capability database for the 960target login are also set. 961.Ev JID , 962.Ev JNAME , 963and 964.Ev JPATH 965are not set. 966If a user is specified (as with 967.Va exec.jail_user ) , 968commands are run from that (possibly jailed) user's directory. 969.It Va exec.jail_user 970The user to run commands as, when running in the jail environment. 971The default is to run the commands as the current user. 972.It Va exec.system_jail_user 973This boolean option looks for the 974.Va exec.jail_user 975in the system 976.Xr passwd 5 977file, instead of in the jail's file. 978.It Va exec.system_user 979The user to run commands as, when running in the system environment. 980The default is to run the commands as the current user. 981.It Va exec.timeout 982The maximum amount of time to wait for a command to complete, in 983seconds. 984If a command is still running after this timeout has passed, 985the jail will not be created or removed, as appropriate. 986.It Va exec.consolelog 987A file to direct command output (stdout and stderr) to. 988.It Va exec.fib 989The FIB (routing table) to set when running commands inside the jail. 990.It Va stop.timeout 991The maximum amount of time to wait for a jail's processes to exit 992after sending them a 993.Dv SIGTERM 994signal (which happens after the 995.Va exec.stop 996commands have completed). 997After this many seconds have passed, the jail will be removed, which 998will kill any remaining processes. 999If this is set to zero, no 1000.Dv SIGTERM 1001is sent and the jail is immediately removed. 1002The default is 10 seconds. 1003.It Va interface 1004A network interface to add the jail's IP addresses 1005.Va ( ip4.addr 1006and 1007.Va ip6.addr ) 1008to. 1009An alias for each address will be added to the interface before the 1010jail is created, and will be removed from the interface after the 1011jail is removed. 1012.It Va ip4.addr 1013In addition to the IP addresses that are passed to the kernel, an 1014interface, netmask and additional parameters (as supported by 1015.Xr ifconfig 8 ) 1016may also be specified, in the form 1017.Dq Ar interface Ns | Ns Ar ip-address Ns / Ns Ar netmask param ... . 1018If an interface is given before the IP address, an alias for the address 1019will be added to that interface, as it is with the 1020.Va interface 1021parameter. 1022If a netmask in either dotted-quad or CIDR form is given 1023after an IP address, it will be used when adding the IP alias. 1024If additional parameters are specified then they will also be used when 1025adding the IP alias. 1026.It Va ip6.addr 1027In addition to the IP addresses that are passed to the kernel, 1028an interface, prefix and additional parameters (as supported by 1029.Xr ifconfig 8 ) 1030may also be specified, in the form 1031.Dq Ar interface Ns | Ns Ar ip-address Ns / Ns Ar prefix param ... . 1032.It Va vnet.interface 1033A comma separated list of network interfaces to give to a vnet-enabled jail 1034after is it created. 1035The interfaces will automatically be released when the jail is removed. 1036.It Va zfs.dataset 1037A list of ZFS datasets to be attached to the jail. 1038This requires 1039.Va allow.mount.zfs 1040to be set. 1041See 1042.Xr zfs-jail 8 1043for information on how to configure a ZFS dataset to be operated from 1044within a jail. 1045.It Va ip_hostname 1046Resolve the 1047.Va host.hostname 1048parameter and add all IP addresses returned by the resolver 1049to the list of addresses 1050.Po Va ip4.addr 1051or 1052.Va ip6.addr Pc 1053for this jail. 1054This may affect default address selection for outgoing IPv4 connections 1055from jails. 1056The address first returned by the resolver for each address family 1057will be used as the primary address. 1058.It Va mount 1059A filesystem to mount before creating the jail (and to unmount after 1060removing it), given as a single 1061.Xr fstab 5 1062line. 1063.It Va mount.fstab 1064An 1065.Xr fstab 5 1066format file containing filesystems to mount before creating a jail. 1067.It Va mount.devfs 1068Mount a 1069.Xr devfs 4 1070filesystem on the chrooted 1071.Pa /dev 1072directory, and apply the ruleset in the 1073.Va devfs_ruleset 1074parameter (or a default of ruleset 4: devfsrules_jail) 1075to restrict the devices visible inside the jail. 1076.It Va mount.fdescfs 1077Mount a 1078.Xr fdescfs 4 1079filesystem on the chrooted 1080.Pa /dev/fd 1081directory. 1082.It Va mount.procfs 1083Mount a 1084.Xr procfs 4 1085filesystem on the chrooted 1086.Pa /proc 1087directory. 1088.It Va allow.dying 1089This is deprecated and has no effect. 1090It used to allow making changes to a 1091.Va dying 1092jail. 1093Now such jails are always replaced when a new jail is created with the same 1094.Va jid 1095or 1096.Va name . 1097.It Va depend 1098Specify a jail (or jails) that this jail depends on. 1099When this jail is to be created, any jail(s) it depends on must already exist. 1100If not, they will be created automatically, up to the completion of the last 1101.Va exec.poststart 1102command, before any action will taken to create this jail. 1103When jails are removed the opposite is true: 1104this jail will be removed, up to the last 1105.Va exec.poststop 1106command, before any jail(s) it depends on are stopped. 1107.El 1108.Sh EXAMPLES 1109Jails are typically set up using one of two philosophies: either to 1110constrain a specific application (possibly running with privilege), or 1111to create a 1112.Dq "virtual system image" 1113running a variety of daemons and services. 1114In both cases, a fairly complete file system install of 1115.Fx 1116is 1117required, so as to provide the necessary command line tools, daemons, 1118libraries, application configuration files, etc. 1119However, for a virtual server configuration, a fair amount of 1120additional work is required so as to replace the 1121.Dq boot 1122process. 1123This manual page documents the configuration steps necessary to support 1124either of these steps, although the configuration steps may need to be 1125refined based on local requirements. 1126.Ss Setting up a Jail Directory Tree From Source 1127To set up a jail directory tree containing an entire 1128.Fx 1129distribution, the following 1130.Xr sh 1 1131command script can be used: 1132.Bd -literal -offset indent 1133D=/here/is/the/jail 1134cd /usr/src 1135mkdir -p $D 1136make world DESTDIR=$D 1137make distribution DESTDIR=$D 1138.Ed 1139.Ss Setting up a Jail Directory Tree from Distribution Files 1140To set up a jail directory tree containing an entire 1141.Fx 1142distribution, the following 1143.Xr sh 1 1144command script can be used: 1145.Bd -literal -offset indent 1146D=/here/is/the/jail 1147mkdir -p $D 1148tar -xf /usr/freebsd-dist/base.txz -C $D --unlink 1149.Ed 1150.Ss Setting up a Jail Directory Tree from System Packages 1151To set up a jail directory tree containing an selectable 1152.Fx 1153distribution with the packages tech preview, 1154the following command can be used: 1155.Pp 1156.Dl bsdinstall jail /here/is/the/jail 1157.Pp 1158In many cases these examples would put far more in the jail than needed. 1159In the other extreme case a jail might contain only one file: 1160the executable to be run in the jail. 1161.Pp 1162We recommend experimentation, and caution that it is a lot easier to 1163start with a 1164.Dq fat 1165jail and remove things until it stops working, 1166than it is to start with a 1167.Dq thin 1168jail and add things until it works. 1169.Ss "Setting Up a Jail" 1170Do what was described in 1171.Sx "Setting Up a Jail Directory Tree" 1172to build the jail directory tree. 1173For the sake of this example, we will 1174assume you built it in 1175.Pa /data/jail/testjail , 1176for a jail named 1177.Dq testjail . 1178Substitute below as needed with your 1179own directory, IP address, and hostname. 1180.Ss "Setting up the Host Environment" 1181First, set up the real system's environment to be 1182.Dq jail-friendly . 1183For consistency, we will refer to the parent box as the 1184.Dq "host environment" , 1185and to the jailed virtual machine as the 1186.Dq "jail environment" . 1187Since jails are implemented using IP aliases, one of the first things to do 1188is to disable IP services on the host system that listen on all local 1189IP addresses for a service. 1190If a network service is present in the host environment that binds all 1191available IP addresses rather than specific IP addresses, it may service 1192requests sent to jail IP addresses if the jail did not bind the port. 1193This means changing 1194.Xr inetd 8 1195to only listen on the 1196appropriate IP address, and so forth. 1197Add the following to 1198.Pa /etc/rc.conf 1199in the host environment: 1200.Bd -literal -offset indent 1201sendmail_enable="NO" 1202inetd_flags="-wW -a 192.0.2.23" 1203rpcbind_enable="NO" 1204.Ed 1205.Pp 1206.Li 192.0.2.23 1207is the native IP address for the host system, in this example. 1208Daemons that run out of 1209.Xr inetd 8 1210can be easily configured to use only the specified host IP address. 1211Other daemons 1212will need to be manually configured \(em for some this is possible through 1213.Xr rc.conf 5 1214flags entries; for others it is necessary to modify per-application 1215configuration files, or to recompile the application. 1216The following frequently deployed services must have their individual 1217configuration files modified to limit the application to listening 1218to a specific IP address: 1219.Pp 1220To configure 1221.Xr sshd 8 , 1222it is necessary to modify 1223.Pa /etc/ssh/sshd_config . 1224.Pp 1225To configure 1226.Xr sendmail 8 , 1227it is necessary to modify 1228.Pa /etc/mail/sendmail.cf . 1229.Pp 1230In addition, a number of services must be recompiled in order to run 1231them in the host environment. 1232This includes most applications providing services using 1233.Xr rpc 3 , 1234such as 1235.Xr rpcbind 8 , 1236.Xr nfsd 8 , 1237and 1238.Xr mountd 8 . 1239In general, applications for which it is not possible to specify which 1240IP address to bind should not be run in the host environment unless they 1241should also service requests sent to jail IP addresses. 1242Attempting to serve 1243NFS from the host environment may also cause confusion, and cannot be 1244easily reconfigured to use only specific IPs, as some NFS services are 1245hosted directly from the kernel. 1246Any third-party network software running 1247in the host environment should also be checked and configured so that it 1248does not bind all IP addresses, which would result in those services also 1249appearing to be offered by the jail environments. 1250.Pp 1251Once 1252these daemons have been disabled or fixed in the host environment, it is 1253best to reboot so that all daemons are in a known state, to reduce the 1254potential for confusion later (such as finding that when you send mail 1255to a jail, and its sendmail is down, the mail is delivered to the host, 1256etc.). 1257.Ss "Configuring the Jail" 1258Start any jail for the first time without configuring the network 1259interface so that you can clean it up a little and set up accounts. 1260As 1261with any machine (virtual or not), you will need to set a root password, time 1262zone, etc. 1263Some of these steps apply only if you intend to run a full virtual server 1264inside the jail; others apply both for constraining a particular application 1265or for running a virtual server. 1266.Pp 1267Start a shell in the jail: 1268.Bd -literal -offset indent 1269jail -c path=/data/jail/testjail mount.devfs \\ 1270 host.hostname=testhostname ip4.addr=192.0.2.100 \\ 1271 command=/bin/sh 1272.Ed 1273.Pp 1274Assuming no errors, you will end up with a shell prompt within the jail. 1275You can now run 1276.Xr bsdconfig 8 1277and do the post-install configuration to set various configuration options, 1278or perform these actions manually by editing 1279.Pa /etc/rc.conf , 1280etc. 1281.Pp 1282.Bl -bullet -offset indent -compact 1283.It 1284Configure 1285.Pa /etc/resolv.conf 1286so that name resolution within the jail will work correctly. 1287.It 1288Run 1289.Xr newaliases 1 1290to quell 1291.Xr sendmail 8 1292warnings. 1293.It 1294Set a root password, probably different from the real host system. 1295.It 1296Set the timezone. 1297.It 1298Add accounts for users in the jail environment. 1299.It 1300Install any packages the environment requires. 1301.El 1302.Pp 1303You may also want to perform any package-specific configuration (web servers, 1304SSH servers, etc), patch up 1305.Pa /etc/syslog.conf 1306so it logs as you would like, etc. 1307If you are not using a virtual server, you may wish to modify 1308.Xr syslogd 8 1309in the host environment to listen on the syslog socket in the jail 1310environment; in this example, the syslog socket would be stored in 1311.Pa /data/jail/testjail/var/run/log . 1312.Pp 1313Exit from the shell, and the jail will be shut down. 1314.Ss "Starting the Jail" 1315You are now ready to restart the jail and bring up the environment with 1316all of its daemons and other programs. 1317Create an entry for the jail in 1318.Pa /etc/jail.conf : 1319.Bd -literal -offset indent 1320testjail { 1321 path = /tmp/jail/testjail; 1322 mount.devfs; 1323 host.hostname = testhostname; 1324 ip4.addr = 192.0.2.100; 1325 interface = em0; 1326 exec.start = "/bin/sh /etc/rc"; 1327 exec.stop = "/bin/sh /etc/rc.shutdown jail"; 1328} 1329.Ed 1330.Pp 1331To start a virtual server environment, 1332.Pa /etc/rc 1333is run to launch various daemons and services, and 1334.Pa /etc/rc.shutdown 1335is run to shut them down when the jail is removed. 1336If you are running a single application in the jail, 1337substitute the command used to start the application for 1338.Dq /bin/sh /etc/rc ; 1339there may be some script available to cleanly shut down the application, 1340or it may be sufficient to go without a stop command, and have 1341.Nm 1342send 1343.Dv SIGTERM 1344to the application. 1345.Pp 1346Start the jail by running: 1347.Bd -literal -offset indent 1348jail -c testjail 1349.Ed 1350.Pp 1351A few warnings may be produced; however, it should all work properly. 1352You should be able to see 1353.Xr inetd 8 , 1354.Xr syslogd 8 , 1355and other processes running within the jail using 1356.Xr ps 1 , 1357with the 1358.Ql J 1359flag appearing beside jailed processes. 1360To see an active list of jails, use 1361.Xr jls 8 . 1362If 1363.Xr sshd 8 1364is enabled in the jail environment, you should be able to 1365.Xr ssh 1 1366to the hostname or IP address of the jailed environment, and log 1367in using the accounts you created previously. 1368.Pp 1369It is possible to have jails started at boot time. 1370Please refer to the 1371.Dq jail_* 1372variables in 1373.Xr rc.conf 5 1374for more information. 1375.Ss "Managing the Jail" 1376Normal machine shutdown commands, such as 1377.Xr halt 8 , 1378.Xr reboot 8 , 1379and 1380.Xr shutdown 8 , 1381cannot be used successfully within the jail. 1382To kill all processes from within a jail, you may use one of the 1383following commands, depending on what you want to accomplish: 1384.Bd -literal -offset indent 1385kill -TERM -1 1386kill -KILL -1 1387.Ed 1388.Pp 1389This will send the 1390.Dv SIGTERM 1391or 1392.Dv SIGKILL 1393signals to all processes in the jail \(em be careful not to run this from 1394the host environment! 1395Once all of the jail's processes have died, unless the jail was created 1396with the 1397.Va persist 1398parameter, the jail will be removed. 1399Depending on 1400the intended use of the jail, you may also want to run 1401.Pa /etc/rc.shutdown 1402from within the jail. 1403.Pp 1404To shut down the jail from the outside, simply remove it with: 1405.Bd -literal -offset indent 1406jail -r 1407.Ed 1408.Pp 1409which will run any commands specified by 1410.Va exec.stop , 1411and then send 1412.Dv SIGTERM 1413and eventually 1414.Dv SIGKILL 1415to any remaining jailed processes. 1416.Pp 1417The 1418.Pa /proc/ Ns Ar pid Ns Pa /status 1419file contains, as its last field, the name of the jail in which the 1420process runs, or 1421.Dq Li - 1422to indicate that the process is not running within a jail. 1423The 1424.Xr ps 1 1425command also shows a 1426.Ql J 1427flag for processes in a jail. 1428.Pp 1429You can also list/kill processes based on their jail ID. 1430To show processes and their jail ID, use the following command: 1431.Pp 1432.Dl "ps ax -o pid,jid,args" 1433.Pp 1434To show and then kill processes in jail number 3 use the following commands: 1435.Bd -literal -offset indent 1436pgrep -lfj 3 1437pkill -j 3 1438.Ed 1439or: 1440.Pp 1441.Dl "killall -j 3" 1442.Ss "Jails and File Systems" 1443It is not possible to 1444.Xr mount 8 1445or 1446.Xr umount 8 1447any file system inside a jail unless the file system is marked 1448jail-friendly, the jail's 1449.Va allow.mount 1450parameter is set, and the jail's 1451.Va enforce_statfs 1452parameter is lower than 2. 1453.Pp 1454Multiple jails sharing the same file system can influence each other. 1455For example, a user in one jail can fill the file system, 1456leaving no space for processes in the other jail. 1457Trying to use 1458.Xr quota 1 1459to prevent this will not work either, as the file system quotas 1460are not aware of jails but only look at the user and group IDs. 1461This means the same user ID in two jails share a single file 1462system quota. 1463One would need to use one file system per jail to make this work. 1464.Ss "Sysctl MIB Entries" 1465The read-only entry 1466.Va security.jail.jailed 1467can be used to determine if a process is running inside a jail (value 1468is one) or not (value is zero). 1469.Pp 1470The variable 1471.Va security.jail.jail_max_af_ips 1472determines how may address per address family a jail may have. 1473The default is 255. 1474.Pp 1475Some MIB variables have per-jail settings. 1476Changes to these variables by a jailed process do not affect the host 1477environment, only the jail environment. 1478These variables are 1479.Va kern.securelevel , 1480.Va security.bsd.suser_enabled , 1481.Va kern.hostname , 1482.Va kern.domainname , 1483.Va kern.hostid , 1484and 1485.Va kern.hostuuid . 1486.Ss "Hierarchical Jails" 1487By setting a jail's 1488.Va children.max 1489parameter, processes within a jail may be able to create jails of their own. 1490These child jails are kept in a hierarchy, with jails only able to see and/or 1491modify the jails they created (or those jails' children). 1492Each jail has a read-only 1493.Va parent 1494parameter, containing the 1495.Va jid 1496of the jail that created it; a 1497.Va jid 1498of 0 indicates the jail is a child of the current jail (or is a top-level 1499jail if the current process isn't jailed). 1500.Pp 1501Jailed processes are not allowed to confer greater permissions than they 1502themselves are given, e.g., if a jail is created with 1503.Va allow.nomount , 1504it is not able to create a jail with 1505.Va allow.mount 1506set. 1507Similarly, such restrictions as 1508.Va ip4.addr 1509and 1510.Va securelevel 1511may not be bypassed in child jails. 1512.Pp 1513A child jail may in turn create its own child jails if its own 1514.Va children.max 1515parameter is set (remember it is zero by default). 1516These jails are visible to and can be modified by their parent and all 1517ancestors. 1518.Pp 1519Jail names reflect this hierarchy, with a full name being an MIB-type string 1520separated by dots. 1521For example, if a base system process creates a jail 1522.Dq foo , 1523and a process under that jail creates another jail 1524.Dq bar , 1525then the second jail will be seen as 1526.Dq foo.bar 1527in the base system (though it is only seen as 1528.Dq bar 1529to any processes inside jail 1530.Dq foo ) . 1531Jids on the other hand exist in a single space, and each jail must have a 1532unique jid. 1533.Pp 1534Like the names, a child jail's 1535.Va path 1536appears relative to its creator's own 1537.Va path . 1538This is by virtue of the child jail being created in the chrooted 1539environment of the first jail. 1540.Sh SEE ALSO 1541.Xr date 1 , 1542.Xr killall 1 , 1543.Xr lsvfs 1 , 1544.Xr newaliases 1 , 1545.Xr pgrep 1 , 1546.Xr pkill 1 , 1547.Xr ps 1 , 1548.Xr quota 1 , 1549.Xr adjtime 2 , 1550.Xr clock_settime 2 , 1551.Xr jail_set 2 , 1552.Xr ntp_adjtime 2 , 1553.Xr devfs 4 , 1554.Xr fdescfs 4 , 1555.Xr linprocfs 4 , 1556.Xr linsysfs 4 , 1557.Xr procfs 4 , 1558.Xr vmm 4 , 1559.Xr jail.conf 5 , 1560.Xr rc.conf 5 , 1561.Xr sysctl.conf 5 , 1562.Xr bsdconfig 8 , 1563.Xr chroot 8 , 1564.Xr devfs 8 , 1565.Xr halt 8 , 1566.Xr ifconfig 8 , 1567.Xr inetd 8 , 1568.Xr jexec 8 , 1569.Xr jls 8 , 1570.Xr mount 8 , 1571.Xr mountd 8 , 1572.Xr nfsd 8 , 1573.Xr ntpd 8 , 1574.Xr reboot 8 , 1575.Xr rpcbind 8 , 1576.Xr sendmail 8 , 1577.Xr shutdown 8 , 1578.Xr sysctl 8 , 1579.Xr syslogd 8 , 1580.Xr umount 8 , 1581.Xr zfs-jail 8 , 1582.Xr extattr 9 1583.Sh HISTORY 1584The 1585.Nm 1586utility appeared in 1587.Fx 4.0 . 1588Hierarchical/extensible jails were introduced in 1589.Fx 8.0 . 1590The configuration file was introduced in 1591.Fx 9.1 . 1592.Sh AUTHORS 1593.An -nosplit 1594The jail feature was written by 1595.An Poul-Henning Kamp 1596for R&D Associates 1597who contributed it to 1598.Fx . 1599.Pp 1600.An Robert Watson 1601wrote the extended documentation, found a few bugs, added 1602a few new features, and cleaned up the userland jail environment. 1603.Pp 1604.An Bjoern A. Zeeb 1605added multi-IP jail support for IPv4 and IPv6 based on a patch 1606originally done by 1607.An Pawel Jakub Dawidek 1608for IPv4. 1609.Pp 1610.An James Gritton 1611added the extensible jail parameters, hierarchical jails, 1612and the configuration file. 1613.Sh BUGS 1614It might be a good idea to add an 1615address alias flag such that daemons listening on all IPs 1616.Pq Dv INADDR_ANY 1617will not bind on that address, which would facilitate building a safe 1618host environment such that host daemons do not impose on services offered 1619from within jails. 1620Currently, the simplest answer is to minimize services 1621offered on the host, possibly limiting it to services offered from 1622.Xr inetd 8 1623which is easily configurable. 1624.Sh NOTES 1625Great care should be taken when managing directories visible within the jail. 1626For example, if a jailed process has its current working directory set to a 1627directory that is moved out of the jail's chroot, then the process may gain 1628access to the file space outside of the jail. 1629It is recommended that directories always be copied, rather than moved, out 1630of a jail. 1631.Pp 1632In addition, there are several ways in which an unprivileged user 1633outside the jail can cooperate with a privileged user inside the jail 1634and thereby obtain elevated privileges in the host environment. 1635Most of these attacks can be mitigated by ensuring that the jail root 1636is not accessible to unprivileged users in the host environment. 1637Regardless, as a general rule, untrusted users with privileged access 1638to a jail should not be given access to the host environment. 1639