1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
"""Generate jail.conf.d entries."""
from __future__ import annotations
from .config import JailConfig, MainConfig
def render_jail_conf(
main: MainConfig,
jail: JailConfig,
*,
jailname: str | None = None,
root: str | None = None,
) -> str:
"""Render jail.conf content for the jail."""
name = jailname or jail.name
if not root:
raise ValueError("root path is required to render jail.conf")
lines = [
f"{name} {{",
f" host.hostname = \"{name}\";",
f" path = \"{root}\";",
" mount.devfs;",
" exec.clean;",
" exec.start = \"/bin/sh /etc/rc\";",
" exec.stop = \"/bin/sh /etc/rc.shutdown jail\";",
"}",
]
base = "\n".join(lines)
if jail.extra_jail_conf:
base += "\n" + jail.extra_jail_conf.rstrip() + "\n"
return base
|