Skip to content

Commit

Permalink
Fix slirp4netns not working if /etc/resolv.conf is a symlink
Browse files Browse the repository at this point in the history
bwrap will silently follow symlinks when it tries to mount on top
of it. To workaround this check if `/etc/resolv.conf` is a symlink
and mount the modified file on top of where symlink points to.
  • Loading branch information
igo95862 committed Nov 30, 2024
1 parent 97f1fb1 commit 9777f9c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/bubblejail/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,9 +907,17 @@ def iter_bwrap_options(self) -> ServiceGeneratorType:
dns_servers = settings.dns_servers.copy()
dns_servers.append("10.0.2.3")

# Systemd-resolved makes /etc/resolv.conf a symlink
# to /run/systemd/resolve/stub-resolv.conf.
# Same do some DHCP clients like NetworkManager.
resolv_conf_path = Path("/etc/resolv.conf")
actual_resolv_path = resolv_conf_path.resolve()
if resolv_conf_path != actual_resolv_path:
resolv_conf_path = actual_resolv_path

yield FileTransfer(
b"\n".join(f"nameserver {x}".encode() for x in dns_servers),
"/etc/resolv.conf",
resolv_conf_path,
)

async def post_init_hook(self, pid: int) -> None:
Expand Down

0 comments on commit 9777f9c

Please sign in to comment.