|
4 | 4 | Each child is confined via Landlock (filesystem + network), seccomp |
5 | 5 | (syscall blocklist + allowlist), and a seccomp user-notification |
6 | 6 | supervisor for resource limits, /proc virtualization, and network |
7 | | -enforcement. No root or cgroups required. |
| 7 | +enforcement. No root required. |
8 | 8 |
|
9 | 9 | With the default ``policy.strict=True``, confinement failures (Landlock |
10 | 10 | unavailable, seccomp installation failure) abort the child process. |
@@ -129,11 +129,11 @@ class SandboxContext: |
129 | 129 | """Fork-based sandbox context. |
130 | 130 |
|
131 | 131 | Forks a child process and applies confinement (Landlock, seccomp, |
132 | | - cgroup v2) according to the given Policy. |
| 132 | + seccomp) according to the given Policy. |
133 | 133 |
|
134 | 134 | The child confinement sequence: |
135 | 135 | 1. setpgid(0, 0) — new process group |
136 | | - 2. Add self to cgroup — resource limits apply immediately |
| 136 | + 2. Apply resource limits — RLIMIT_CPU, seccomp notif |
137 | 137 | 3. chroot(path) if policy.chroot — optional path illusion |
138 | 138 | 4. confine(writable, readable) — Landlock (irreversible) |
139 | 139 | 5. install notif filter + send fd — seccomp user notification (optional) |
@@ -325,7 +325,7 @@ def __enter__(self) -> "SandboxContext": |
325 | 325 | # User namespace is only needed for privileged mode (UID 0 mapping) |
326 | 326 | needs_userns = self._policy.privileged |
327 | 327 | if needs_userns: |
328 | | - from ._userns import unshare_user_cgroup, setup_userns_in_parent, userns_available # noqa: F811 |
| 328 | + from ._userns import unshare_user, setup_userns_in_parent, userns_available # noqa: F811 |
329 | 329 |
|
330 | 330 | # Sync pipes for user namespace setup: |
331 | 331 | # child_to_parent: child signals "I've unshared" |
@@ -374,12 +374,12 @@ def __enter__(self) -> "SandboxContext": |
374 | 374 | try: |
375 | 375 | os.setpgid(0, 0) |
376 | 376 |
|
377 | | - # 1. User namespace for cgroup delegation (if needed) |
| 377 | + # 1. User namespace for privileged mode (if needed) |
378 | 378 | if needs_userns and userns_c2p_w >= 0: |
379 | 379 | os.close(userns_c2p_r) |
380 | 380 | os.close(userns_p2c_w) |
381 | 381 | try: |
382 | | - unshare_user_cgroup() |
| 382 | + unshare_user() |
383 | 383 | os.write(userns_c2p_w, b"1") # Tell parent: unshared |
384 | 384 | os.close(userns_c2p_w) |
385 | 385 | os.read(userns_p2c_r, 1) # Wait: maps written |
|
0 commit comments