zfs-agent
ZFS dataset management for unprivileged users via a Unix domain socket.
A host-side agent runs with ZFS privileges and executes validated zfs create requests on behalf of clients that lack ZFS tools or privileges – typically containers. Used in ftm-lakehouse.
Linux only (peer authentication relies on SO_PEERCRED), Python 3.10+, no
dependencies.
Install
pip install zfs-agent
Usage
Run the agent on the host (as a user that may run zfs create, typically root):
zfs-agent --socket /run/zfs.sock --pool tank/data --owner 1000:1000 --allowed-uid 1000
--poolrestricts requests to datasets below this path (env:ZFS_POOL)--ownerchowns new dataset mountpoints to thisuid:gid(env:ZFS_OWNER)--allowed-uidonly accepts connections from this UID, verified viaSO_PEERCRED; defaults to the agent's own UID (env:ZFS_ALLOWED_UID)--log-levelsets the agent's log verbosity, defaultINFO(env:ZFS_LOG_LEVEL). Only the CLI configures logging; imported as a library, the package logs throughloggingwithout attaching handlers.
Clients may only set ZFS properties from a built-in allowlist of tuning
knobs (compression, recordsize, atime, quota, …). Set
ZFS_EXTRA_PROPS on the agent to add more, comma separated:
ZFS_EXTRA_PROPS=canmount,readonly zfs-agent --socket /run/zfs.sock --pool tank/data
The effective allowlist is logged at startup.
Create datasets from the client side (e.g. inside a container that mounts the socket):
from zfs_agent.client import zfs_create_socket
zfs_create_socket("/run/zfs.sock", "tank/data/my_dataset", compression="zstd")
Or set ZFS_SOCKET=/run/zfs.sock in the environment and let the dispatcher choose between socket and local zfs create:
from zfs_agent import zfs_create
zfs_create("tank/data/my_dataset", compression="zstd")
Security
- The socket is created mode
0600, owned by the allowed UID. - The peer's UID is verified via
SO_PEERCREDbefore the request is read. - Dataset names are validated (no path traversal, restricted characters) and must live under the configured pool.
- ZFS properties are checked against an allowlist. Properties such as
mountpoint,sharenfsorsetuidwould otherwise let a client steer what the privileged side touches. - Requests are size capped and time limited, and a malformed one is answered with an error rather than taking the agent down.
- The only supported action is
create.
Tests
make test # unit tests
make test-docker # integration test (privileged container, ZFS on the host)
License
AGPLv3+
Metadata
Release files for zfs-agent 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| zfs_agent-0.0.1.tar.gz | 22.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zfs_agent-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.4 kB
Release files / zfs_agent-0.0.1.tar.gz
| Download URL | zfs_agent-0.0.1.tar.gz |
|---|---|
| Size | 22.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b68e3ece30d8bc41d894706b2d564accfb5b94be21c016accc9d1fc1bd977d71
|
|
BLAKE2b-256 checksum How to use checksums |
0a983d2248d92b992b0f822da815178a80f151c290d82f485cb505677d2106dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.4 Linux/7.0.0-28-generic
|
Release files / zfs_agent-0.0.1-py3-none-any.whl
| Download URL | zfs_agent-0.0.1-py3-none-any.whl |
|---|---|
| Size | 25.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
195fa645250dda296461ba014db0bd83e20faa59382ad318ce350e20ebdc98f8
|
|
BLAKE2b-256 checksum How to use checksums |
012b952150c9ef2d55621242968148dd1a7076081bc40f919bdcc52695fb8333
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.4 Linux/7.0.0-28-generic
|