contain the basic device nodes required for a functioning sandbox (e.g. `/dev/null`)
and no actual devices.
-`--proc DST`
-: Mounts `/proc` from the host at `DST` in the sandbox.
-
`--dir DST`
: Creates a directory and all missing parent directories at `DST` in the sandbox.
All directories are created with mode 755 unless the path ends with `/tmp` or
--symlink usr/lib64 /lib64 \
--symlink usr/sbin /sbin \
--dev /dev \
- --proc /proc \
+ --bind /proc /proc \
--tmpfs /tmp \
--become-root \
id
module = stack.enter_context(resource_path(sys.modules[__package__ or __name__]))
cmdline: list[PathString] = [
- "--proc", "/proc",
+ "--bind", "/proc", "/proc",
# We mounted a subdirectory of TMPDIR to /var/tmp so we unset TMPDIR so that /tmp or /var/tmp are
# used instead.
"--unsetenv", "TMPDIR",
return [
"--tmpfs", root / "run",
"--tmpfs", root / "tmp",
- "--proc", root / "proc",
+ "--bind", "/proc", root / "proc",
"--dev", root / "dev",
# Nudge gpg to create its sockets in /run by making sure /run/user/0 exists.
"--dir", root / "run/user/0",
mount_rbind(src, dst, attrs=MOUNT_ATTR_RDONLY if self.readonly else 0)
-class ProcOperation(FSOperation):
- def execute(self, oldroot: str, newroot: str) -> None:
- dst = chase(newroot, self.dst)
- with umask(~0o755):
- os.makedirs(dst, exist_ok=True)
-
- mount_rbind(joinpath(oldroot, "proc"), dst)
-
-
class DevOperation(FSOperation):
def __init__(self, ttyname: str, dst: str) -> None:
self.ttyname = ttyname
--version Show package version
--tmpfs DST Mount a new tmpfs on DST
--dev DST Mount dev on DST
- --proc DST Mount procfs on DST
--dir DST Create a new directory at DST
--bind SRC DST Bind mount the host path SRC to DST
--bind-try SRC DST Bind mount the host path SRC to DST if it exists
fsops.append(TmpfsOperation(os.path.abspath(argv.pop())))
elif arg == "--dev":
fsops.append(DevOperation(ttyname, os.path.abspath(argv.pop())))
- elif arg == "--proc":
- fsops.append(ProcOperation(os.path.abspath(argv.pop())))
elif arg == "--dir":
fsops.append(DirOperation(os.path.abspath(argv.pop())))
elif arg in ("--bind", "--ro-bind", "--bind-try", "--ro-bind-try"):