diff options
author | Helmut Grohne <helmut@subdivi.de> | 2025-03-27 08:06:21 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2025-03-27 08:06:21 +0100 |
commit | 7f7a817c68544ce98da22b2bc3ed793624800c8a (patch) | |
tree | f0fe7ae3c3a2ae102959dd5695f1b1b36e63a591 /examples | |
parent | 1b995e8a1dc35f429beec7921f9d21480af5ee24 (diff) | |
download | python-linuxnamespaces-7f7a817c68544ce98da22b2bc3ed793624800c8a.tar.gz |
examples/chroottar.py: expand matching of device files
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/chroottar.py | 4 |
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) |