]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: fix condition for mounting resolv.conf (#4622)
authorChristian Hesse <mail@eworm.de>
Wed, 9 Nov 2016 03:01:26 +0000 (04:01 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 9 Nov 2016 03:01:26 +0000 (22:01 -0500)
The file /usr/lib/systemd/resolv.conf can be stale, it does not tell us
whether or not systemd-resolved is running or not.
So check for /run/systemd/resolve/resolv.conf as well, which is created
at runtime and hence is a better indication.

src/nspawn/nspawn.c

index c8b18bcb88c565ea5ee099c4912cac0e8bfd9e11..9b9ae909c93954fbfb6252712d53becf9e121847 100644 (file)
@@ -1309,7 +1309,8 @@ static int setup_resolv_conf(const char *dest) {
         /* Fix resolv.conf, if possible */
         where = prefix_roota(dest, "/etc/resolv.conf");
 
-        if (access("/usr/lib/systemd/resolv.conf", F_OK) >= 0) {
+        if (access("/run/systemd/resolve/resolv.conf", F_OK) >= 0 &&
+                        access("/usr/lib/systemd/resolv.conf", F_OK) >= 0) {
                 /* resolved is enabled on the host. In this, case bind mount its static resolv.conf file into the
                  * container, so that the container can use the host's resolver. Given that network namespacing is
                  * disabled it's only natural of the container also uses the host's resolver. It also has the big