1 .\" Copyright (c) 2012 James Gritton
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .Nd configuration file for
37 configuration file consists of one or more jail definitions statements,
38 and parameter or variable statements within those jail definitions.
39 A jail definition statement looks something like a C compound statement.
40 A parameter statement looks like a C assignment,
41 including a terminating semicolon.
43 The general syntax of a jail definition is:
44 .Bd -literal -offset indent
52 Each jail is required to have a
54 at the front of its definition.
57 to specify a jail on the command line and report the jail status,
58 and is also passed to the kernel when creating the jail.
60 A jail is defined by a set of named parameters, specified inside the
64 .Em for a list of jail parameters
65 passed to the kernel, as well as internal parameters used when creating and
68 A typical parameter has a name and a value.
69 Some parameters are boolean and may be specified with values of
73 or as valueless shortcuts, with a
75 prefix indicating a false value.
76 For example, these are equivalent:
77 .Bd -literal -offset indent
78 allow.mount = "false";
82 Other parameters may have more than one value.
83 A comma-separated list of values may be set in a single statement,
84 or an existing parameter list may be appended to using
86 .Bd -literal -offset indent
87 ip4.addr = 10.1.1.1, 10.1.1.2, 10.1.1.3;
96 parameter is implicitly set to the name in the jail definition.
98 Parameter values, including jail names, can be single tokens or quoted
100 A token is any sequence of characters that aren't considered special in
101 the syntax of the configuration file (such as a semicolon or
103 If a value contains anything more than letters, numbers, dots, dashes
104 and underscores, it is advisable to put quote marks around that value.
105 Either single or double quotes may be used.
107 Special characters may be quoted by preceding them with a backslash.
108 Common C-style backslash character codes are also supported, including
109 control characters and octal or hex ASCII codes.
110 A backslash at the end of a line will ignore the subsequent newline and
111 continue the string at the start of the next line.
113 A string may use shell-style variable substitution.
114 A parameter or variable name preceded by a dollar sign, and possibly
115 enclosed in braces, will be replaced with the value of that parameter or
117 For example, a jail's path may be defined in terms of its name or
119 .Bd -literal -offset indent
120 path = "/var/jail/$name";
122 path = "/var/jail/${host.hostname}";
125 Variable substitution occurs in unquoted tokens or in double-quoted
126 strings, but not in single-quote strings.
128 A variable is defined in the same way a parameter is, except that the
129 variable name is preceded with a dollar sign:
130 .Bd -literal -offset indent
131 $parentdir = "/var/jail";
132 path = "$parentdir/$name";
135 The difference between parameters and variables is that variables are
136 only used for substitution, while parameters are used both for
137 substitution and for passing to the kernel.
139 A jail definition with a name of
141 is used to define wildcard parameters.
142 Every defined jail will contain both the parameters from its own
143 definition statement, as well as any parameters in a wildcard
146 Variable substitution is done on a per-jail basis, even when that
147 substitution is for a parameter defined in a wildcard section.
148 This is useful for wildcard parameters based on e.g. a jail's name.
150 Later definitions in the configuration file supersede earlier ones, so a
151 wildcard section placed before (above) a jail definition defines
152 parameters that could be changed on a per-jail basis.
153 Or a wildcard section placed after (below) all jails would contain
154 parameters that always apply to every jail.
155 Multiple wildcard statements are allowed, and wildcard parameters may
156 also be specified outside of a jail definition statement.
158 If hierarchical jails are defined, a partial-matching wildcard
159 definition may be specified.
160 For example, a definition with a name of
162 would apply to jails with names like
167 The configuration file may contain comments in the common C, C++, and
169 .Bd -literal -offset indent
170 /* This is a C style comment.
171 * It may span multiple lines.
174 // This is a C++ style comment.
176 # This is a shell style comment.
179 Comments are legal wherever whitespace is allowed, i.e. anywhere except
180 in the middle of a string or a token.
183 # Typical static defaults:
184 # Use the rc scripts to start and stop jails. Mount jail's /dev.
185 exec.start = "/bin/sh /etc/rc";
186 exec.stop = "/bin/sh /etc/rc.shutdown jail";
190 # Dynamic wildcard parameter:
191 # Base the path off the jail name.
192 path = "/var/jail/$name";
196 host.hostname = "foo.com";
197 ip4.addr = 10.1.1.1, 10.1.1.2, 10.1.1.3;
200 # This jail overrides the defaults defined above.
206 persist; // Required because there are no processes
225 The jail feature was written by
226 .An Poul-Henning Kamp
228 who contributed it to
232 added the extensible jail parameters and configuration file.