]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: suppress warning when /etc/resolv.conf is a valid symlink 291/head
authorLennart Poettering <lennart@poettering.net>
Thu, 18 Jun 2015 17:42:59 +0000 (19:42 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 18 Jun 2015 17:45:18 +0000 (19:45 +0200)
In such a case let's suppress the warning (downgrade to LOG_DEBUG),
under the assumption that the user has no config file to update in its
place, but a symlink that points to something like resolved's
automatically managed resolve.conf file.

While we are at it, also stop complaining if we cannot write /etc/resolv.conf
due to a read-only disk, given that there's little we could do about it.

src/nspawn/nspawn.c

index d1154de08a1d6867d22e864d30f8fd951f79e8a4..4cf2d14ae2c095664a58c299d4c8782e786088d3 100644 (file)
@@ -1538,7 +1538,16 @@ static int setup_resolv_conf(const char *dest) {
 
         r = copy_file("/etc/resolv.conf", where, O_TRUNC|O_NOFOLLOW, 0644, 0);
         if (r < 0) {
-                log_warning_errno(r, "Failed to copy /etc/resolv.conf to %s: %m", where);
+                /* If the file already exists as symlink, let's
+                 * suppress the warning, under the assumption that
+                 * resolved or something similar runs inside and the
+                 * symlink points there.
+                 *
+                 * If the disk image is read-only, there's also no
+                 * point in complaining.
+                 */
+                log_full_errno(IN_SET(r, -ELOOP, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
+                               "Failed to copy /etc/resolv.conf to %s: %m", where);
                 return 0;
         }