Skip to content

Commit

Permalink
fix #856
Browse files Browse the repository at this point in the history
  • Loading branch information
JSCU-CNI committed Sep 19, 2024
1 parent c5bf1ed commit e58fa0f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions dissect/target/filesystems/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,20 @@ def __init__(self, path: Path, *args, **kwargs):

# append and mount every layer
for dest, layer in layers:
if layer.is_file() and dest in ["/etc/hosts", "/etc/hostname", "/etc/resolv.conf"]:

# we could have collected a layer reference that actually does not exist on the host
if not layer.exists():
log.warning("Can not mount layer %s for container %s as it does not exist on the host", layer, path.name)
continue

# mount points can be files
if layer.is_file():
layer_fs = VirtualFilesystem()
layer_fs.map_file_fh("/etc/" + layer.name, layer.open("rb"))
layer_fs.map_file_fh(str(layer), layer.open("rb"))
dest = dest.split("/")[0]

# regular overlay2 layers are directories
# mount points can be directories too
else:
layer_fs = DirectoryFilesystem(layer)

Expand Down

0 comments on commit e58fa0f

Please sign in to comment.