summaryrefslogtreecommitdiff
path: root/examples/chroottar.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/chroottar.py')
-rwxr-xr-xexamples/chroottar.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/chroottar.py b/examples/chroottar.py
index 3c38a97..cf0f87e 100755
--- a/examples/chroottar.py
+++ b/examples/chroottar.py
@@ -9,6 +9,7 @@ a user and mount namespace.
import argparse
import os
import pathlib
+import re
import socket
import sys
import tempfile
@@ -74,14 +75,15 @@ def main() -> None:
os.setregid(0, 0)
os.setgroups([])
for tmem in tarf:
- if tmem.name.removeprefix("./").startswith("dev/"):
+ name = re.sub(r"^/*(\.{1,2}/+)*", "", tmem.name)
+ if name.startswith("dev/"):
continue
tarf.extract(tmem, numeric_owner=True)
linuxnamespaces.bind_mount(".", "/mnt", recursive=True)
os.chdir("/mnt")
linuxnamespaces.bind_mount("/proc", "proc", recursive=True)
linuxnamespaces.bind_mount("/sys", "sys", recursive=True)
- linuxnamespaces.populate_dev("/", ".", pidns=False, tun=False)
+ linuxnamespaces.populate_dev("/", ".", pts="host", tun=False)
linuxnamespaces.pivot_root(".", ".")
linuxnamespaces.umount(".", linuxnamespaces.UmountFlags.DETACH)
if args.command: