nspawn: resolv.conf might not be created initially (#4799)
authorFranck Bui <fbui@suse.com>
Wed, 7 Dec 2016 20:36:39 +0000 (21:36 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 7 Dec 2016 20:36:39 +0000 (21:36 +0100)
This might happen that resolv.conf is missing in a minimal rootfs and in this
case the following warning is emitted:

 Failed to mount n/a on /mnt/etc/resolv.conf (MS_BIND ""): No such file or directory

This patch fixes this case.

src/nspawn/nspawn.c

index ddd6a64..cb09392 100644 (file)
@@ -1299,6 +1299,8 @@ static int setup_resolv_conf(const char *dest) {
                  * advantage that the container will be able to follow the host's DNS server configuration changes
                  * transparently. */
 
+                (void) touch(where);
+
                 r = mount_verbose(LOG_WARNING, "/usr/lib/systemd/resolv.conf", where, NULL, MS_BIND, NULL);
                 if (r >= 0)
                         return mount_verbose(LOG_ERR, NULL, where, NULL,