bedrocklinux / bedrocklinux-userland

This tracks development for the things such as scripts and (defaults for) config files for Bedrock Linux
https://bedrocklinux.org
GNU General Public License v2.0
611 stars 66 forks source link

Hijack on ubuntu breaks DNS making `brl fetch` appear to fail #131

Open nikvdp opened 5 years ago

nikvdp commented 5 years ago

bedrock-linux-0.7.6-x86_64.sh --hijack on a fresh Ubuntu 18.04 (bionic) install breaks DNS causing brl fetch to fail.

Steps to reproduce:

nift4 commented 5 years ago

@nikvdp What is your bedrock.conf?

paradigm commented 5 years ago

I can reproduce the issue. As a temporary work around, as root, edit /bedrock/share/resolvconf/00bedrock. It should initially look like

#!/bin/sh
#
# resolvconf requires /etc/resolv.conf to be a symlink to
# /etc/resolvconf/run/resolv.conf, but it does not create this symlink itself.
# Provided /etc/resolv.conf does not exist - no other subsystem is controlling
# the file - create it to fullfill resolvconf's requirements.
#
if ! [ -e /etc/resolv.conf ] &&
    ! [ -h /etc/resolv.conf ]; then
    ln -s /etc/resolvconf/run/resolv.conf /etc/resolv.conf
fi

Clear out everything but the top line so it looks like:

#!/bin/sh

then save the file and reboot, after which DNS should work as expected.

I plan to push a proper fix with the next Bedrock update which should overwrite the work around such that you do not need to remember to revert it later, just brl update.


Different distros/inits/networking stacks/etc handle /etc/resolv.conf differently. Many become upset if they see a resolv.conf file from another system, such as if you reboot between different init systems via Bedrock. Bedrock's strategy to avoid conflicts here is to just delete /etc/resolv.conf with the expectation that the desired init re-creates it.

resolvconf (no .) is a /etc/resolv.conf management system which creates a resolv.conf file in a location other than /etc/resolv.conf and which assumes /etc/resolv.conf is a symlink to this location. It does not create this symlink on its own, which means when Bedrock removes /etc/resolv.conf nothing recreates or redirects it and DNS fails to work.

To make Bedrock work with resolvconf systems, I wrote a resolvconf hook to create the symlink if it is missing. With Ubuntu 18.04 (and derivative distros such as Pop!_OS), Ubuntu keeps resolvconf around but uses another system (I think systemd) to manage resolv.conf. The Bedrock resolvconf hook creates a symlink that conflicts with this other system. This is what you've run into, and why clearing out the hook is an adequate work around.

This hook is needed for some systems, and so that work-around is not a viable general long term solution. My plan here is to make the corresponding hook smarter about when it creates the symlink and where the symlink points. I expect to have a fix out with the next Bedrock update, but it may be a couple weeks or so before I can get the update out as I have a very large back log of things that need to make it into the update and it's taking me time to work through them.