rootless-containers / slirp4netns

User-mode networking for unprivileged network namespaces
GNU General Public License v2.0
715 stars 82 forks source link

Add support for escaping resolv.conf symlinks #318

Closed n1hility closed 11 months ago

n1hility commented 11 months ago

Previously if resolv.conf was symlinked to a location other than /etc, or /run, a warning message would be printed and DNS would be non-functional.

Instead, attempt to bind an equivalent resolv.conf link target path in the namespace structure, so that symlink continues to function, and DNS remains operational.

This fixes usage in WSL environments which symlinks /etc/resolv.conf under a shared location under /mnt. Although I suspect this usage pattern is fairly common in other environments.

Alternatively, instead of mirroring the target path, this could have utilized the newer open_tree/move_mount syscalls, to bind mount on top of the /etc/resolv.conf symlink. However, this would have limited the support to 5.2 kernels and later, so just cloning the target seemed the way to go.

Note: this PR also includes some commits to fix CI

n1hility commented 11 months ago

PTAL @AkihiroSuda @giuseppe

n1hility commented 11 months ago

@AkihiroSuda you're welcome! Thanks for including this in your 1.2.1 release plans! It will be great to get this one out to users.

AkihiroSuda commented 11 months ago

Thank you, released v1.2.1 https://github.com/rootless-containers/slirp4netns/releases/tag/v1.2.1

KiruyaMomochi commented 7 months ago

Thank you for this PR! It's great to see support for escaping resolv.conf symlinks. However, I've encountered some issues in more complex environments like NixOS, where symlinks can have multiple layers and even parent folders can be symlinked. Please see #333 for more information.