The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/distrobuilder/pull/344
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 9200330b17dd49dd2a1f47814d6329825478963d Mon Sep 17 00:00:00 2001 From: Thomas Hipp <thomas.h...@canonical.com> Date: Wed, 17 Jun 2020 08:31:49 +0200 Subject: [PATCH] chroot: Resolve parent directory symlinks Signed-off-by: Thomas Hipp <thomas.h...@canonical.com> --- shared/chroot.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/shared/chroot.go b/shared/chroot.go index f196d59..7ba07eb 100644 --- a/shared/chroot.go +++ b/shared/chroot.go @@ -89,8 +89,31 @@ func moveMounts(mounts []ChrootMount) error { target = newTarget } + // If the target's parent directory is a symlink, we need to resolve that as well. + targetDir := filepath.Dir(target) + for { + // Get information on current target + fi, err := os.Lstat(targetDir) + if err != nil { + break + } + + // If not a symlink, we're done + if fi.Mode()&os.ModeSymlink == 0 { + break + } + + // If a symlink, resolve it + newTarget, err := os.Readlink(targetDir) + if err != nil { + break + } + + targetDir = newTarget + } + // Create parent paths if missing - err := os.MkdirAll(filepath.Dir(target), 0755) + err := os.MkdirAll(targetDir, 0755) if err != nil { return err }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel