aboutsummaryrefslogtreecommitdiffstats
path: root/jprov/jailconf.py
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2026-02-16 12:59:14 +0200
committerJan Tuomi <jan@jantuomi.fi>2026-02-16 12:59:14 +0200
commit5f46fde558c467414fa151ad962caaf7f07628fa (patch)
tree247d6fd45ddbc811fb71d2009fbbd2042e158791 /jprov/jailconf.py
Initial commit
Diffstat (limited to 'jprov/jailconf.py')
-rw-r--r--jprov/jailconf.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/jprov/jailconf.py b/jprov/jailconf.py
new file mode 100644
index 0000000..0478cbd
--- /dev/null
+++ b/jprov/jailconf.py
@@ -0,0 +1,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