Repository navigation
Bind the resolver directory so DNS works in the sandbox - #15
Merged
Merged
Conversation
Closes #1. Sharing the network namespace is not enough to resolve names. /etc is bound read-only, but on systemd-resolved and NetworkManager systems /etc/resolv.conf is a symlink into /run, and the sandbox replaces /run with an empty tmpfs. The symlink dangles, the agent sees no nameserver at all, and the symptom reads as "the sandbox has no network" rather than anything to do with DNS. Reported on Ubuntu 24.04 and independently hit on Fedora; both reporters worked around it with the same manual bind. Follow the symlink and bind the directory it points at, read-only, when networking is shared. Following the link rather than hardcoding a path keeps this working across resolver implementations, and a plain file in /etc needs nothing extra because /etc is already bound. --no-net adds nothing, since there is no resolver to reach. Verified against a simulated systemd-resolved host: before, the agent got "cat: /etc/resolv.conf: No such file or directory"; after, it reads the nameserver. Tests cover both the mount argument and the behaviour, and both fail without the fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1.
Sharing the network namespace is not enough to resolve names. /etc is bound read-only, but on systemd-resolved and NetworkManager systems /etc/resolv.conf is a symlink into /run, and the sandbox replaces /run with an empty tmpfs. The symlink dangles and the agent sees no nameserver, so it looks like the sandbox has no network rather than no DNS.
Reported on Ubuntu 24.04, independently hit on Fedora. Both reporters used the same manual bind.
The fix follows the symlink and binds the directory it points at, read-only, when networking is shared. That works for any resolver that symlinks out of /etc. A plain file in /etc needs nothing extra, and --no-net adds nothing.
This machine has a regular /etc/resolv.conf, so I verified against a simulated systemd-resolved host. Before, the agent got "cat: /etc/resolv.conf: No such file or directory". After, it reads the nameserver.
Tests cover the mount argument and the behaviour. Both fail without the wrapper change. The argv tests skip where /etc/resolv.conf does not symlink outside /etc; CI runs Ubuntu, so they fire there.