summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-07-15 06:46:09 -0400
committerGitHub <noreply@github.com>2021-07-15 06:46:09 -0400
commit61245884abb181ee4dd46280a56dec5f25d2432d (patch)
tree3b55d10a0532d2d9b5c893d84462e5f73198878c
parent1568247ec8fa0c1a23bbd4631c1ea2fcfd85e281 (diff)
parente73d4829900c4ef47ffca4be306ef84b944aa9c2 (diff)
downloadpodman-61245884abb181ee4dd46280a56dec5f25d2432d.tar.gz
podman-61245884abb181ee4dd46280a56dec5f25d2432d.tar.bz2
podman-61245884abb181ee4dd46280a56dec5f25d2432d.zip
Merge pull request #10936 from AkihiroSuda/issue10929
CNI-in-slirp4netns: fix bind-mount for /run/systemd/resolve/stub-resolv.conf
-rw-r--r--libpod/networking_linux.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index 48b0c495c..15639aac4 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -177,6 +177,21 @@ func (r *RootlessCNI) Do(toRun func() error) error {
if err != nil {
return err
}
+ logrus.Debugf("The actual path of /etc/resolv.conf on the host is %q", resolvePath)
+ // When /etc/resolv.conf on the host is a symlink to /run/systemd/resolve/stub-resolv.conf,
+ // we have to mount an empty filesystem on /run/systemd/resolve in the child namespace,
+ // so as to isolate the directory from the host mount namespace.
+ //
+ // Otherwise our bind-mount for /run/systemd/resolve/stub-resolv.conf is unmounted
+ // when systemd-resolved unlinks and recreates /run/systemd/resolve/stub-resolv.conf on the host.
+ // see: https://github.com/containers/podman/issues/10929
+ if strings.HasPrefix(resolvePath, "/run/systemd/resolve/") {
+ rsr := r.getPath("/run/systemd/resolve")
+ err = unix.Mount("", rsr, "tmpfs", unix.MS_NOEXEC|unix.MS_NOSUID|unix.MS_NODEV, "")
+ if err != nil {
+ return errors.Wrapf(err, "failed to mount tmpfs on %q for rootless cni", rsr)
+ }
+ }
if strings.HasPrefix(resolvePath, "/run/") {
resolvePath = r.getPath(resolvePath)
err = os.MkdirAll(filepath.Dir(resolvePath), 0700)