From 7f7a817c68544ce98da22b2bc3ed793624800c8a Mon Sep 17 00:00:00 2001 From: Helmut Grohne <helmut@subdivi.de> Date: Thu, 27 Mar 2025 08:06:21 +0100 Subject: examples/chroottar.py: expand matching of device files --- examples/chroottar.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3