Skip to main content

py-jail

A native Python wrapper for FreeBSD jails using libc.

Usage

jail_set

>>> import jail
>>> jiov = jail.Jiov(dict(persist=None, jid=23, path="/rescue"))
>>> jail.dll.jail_set(jiov.pointer, len(jiov), 1)
23

jail_remove

>>> import jail
>>> jiov = jail.Jiov(dict(persist=None, jid=23, path="/rescue"))
>>> jail.dll.jail_remove(23)
-1
>>> jail.dll.jail_set(jiov.pointer, len(jiov), 1)
23
>>> jail.dll.jail_set(jiov.pointer, len(jiov), 1)
-1
>>> jiov.errmsg.value
b'jail 23 already exists'
>>> jail.dll.jail_remove(23)
0
>>> jail.dll.jail_set(jiov.pointer, len(jiov), 1)
23

Parameters

Networking

Non-VNET jails accept ip.addr and ip6.addr params. Those can be defined from Python ipaddress.IPv4Address and ipaddress.IPv6Address.

ifconfig bridge create inet 192.168.1.42/24 inet6 add 2001:db8:10C::42/64
import ipaddress
import jail

jiov = jail.Jiov({
	"persist": None,
	"jid": 23,
	"path": "/rescue",
	"ip4.addr": ipaddress.IPv4Address("192.168.1.42")
	"ip6.addr": ipaddress.IPv6Address("2001:db8:10C::42")
})

jail.dll.jail_set(jiov.pointer, len(jiov), 1)

Development

Unit Tests

Unit tests may run on FreeBSD or HardenedBSD.

Static Code Analysis

The project enforces PEP-8 code style and MyPy strong typing via flake8, that is required to pass before merging any changes. Together with Bandit checks for common security issues the static code analysis can be ran on Linux and BSD code execution.

make install-dev
make check

Releases

We try to manually keep a Changelog, following the style on changelog.md. New releases are tagged according to Semver, released on PyPi, and published as port.

To get a port published, we need to create a Bugzilla Issue in the Ports category

Release files for jail 0.0.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jail 0.0.14
File Size Uploaded
jail-0.0.14.tar.gz 7.1 kB Details

Release files / jail-0.0.14.tar.gz

Download URL jail-0.0.14.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1db2bee0ece866b62ccec5658e0d96cc31826e77ea57cab17f6e1b62ec88f6e1
BLAKE2b-256 checksum
How to use checksums
c9d9c1ba16c16d07fdf8b28c9af2d0a572e7b9bf21090e96fd30dd1226861422
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

Release history Release notifications | RSS feed

This release

0.0.14 This release

1 release file

0.0.13

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page