]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: Don't follow /etc/resolv.conf symlinks
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 24 Apr 2023 09:54:50 +0000 (11:54 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 24 Apr 2023 16:14:12 +0000 (18:14 +0200)
When we're checking if /etc/resolv.conf exists so we can bind mount
on top of it, we care about whether the symlink itself exists if
/etc/resolv.conf exists and not the file it points to, so add
CHASE_NOFOLLOW to make sure we check existence of the symlink and
not the file it points to.

src/nspawn/nspawn.c

index 6477cc43fa9b98417702aa1b9b17b7c3ebe8db3f..9e5b7772ac27264c7e6213f96f6d86b3ad7a29a7 100644 (file)
@@ -2159,7 +2159,7 @@ static int setup_resolv_conf(const char *dest) {
                 _cleanup_free_ char *resolved = NULL;
                 int found;
 
-                found = chase(where, dest, CHASE_NONEXISTENT, &resolved, NULL);
+                found = chase(where, dest, CHASE_NONEXISTENT|CHASE_NOFOLLOW, &resolved, NULL);
                 if (found < 0) {
                         log_warning_errno(found, "Failed to resolve /etc/resolv.conf path in container, ignoring: %m");
                         return 0;