summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2025-03-27 08:06:21 +0100
committerHelmut Grohne <helmut@subdivi.de>2025-03-27 08:06:21 +0100
commit7f7a817c68544ce98da22b2bc3ed793624800c8a (patch)
treef0fe7ae3c3a2ae102959dd5695f1b1b36e63a591
parent1b995e8a1dc35f429beec7921f9d21480af5ee24 (diff)
downloadpython-linuxnamespaces-7f7a817c68544ce98da22b2bc3ed793624800c8a.tar.gz
examples/chroottar.py: expand matching of device files
-rwxr-xr-xexamples/chroottar.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/examples/chroottar.py b/examples/chroottar.py
index 3c38a97..42c09ef 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,7 +75,8 @@ 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)