From 9db534e53af884abfbcea2bd0efbbb89ca0b949c Mon Sep 17 00:00:00 2001 From: Urvashi Mohnani Date: Wed, 23 Jun 2021 14:24:55 -0400 Subject: [NO TESTS NEEDED] Create /etc/mtab with the correct ownership Create the /etc and /etc/mtab directories with the correct ownership based on what the UID and GID is for the container. This was causing issue when starting the infra container with userns as the /etc directory wasn't being created with the correct ownership. Signed-off-by: Urvashi Mohnani --- libpod/container_internal.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libpod') diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 545b78976..2555f15ec 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -1535,7 +1535,7 @@ func (c *Container) mountStorage() (_ string, deferredErr error) { // If /etc/mtab does not exist in container image, then we need to // create it, so that mount command within the container will work. mtab := filepath.Join(mountPoint, "/etc/mtab") - if err := os.MkdirAll(filepath.Dir(mtab), 0755); err != nil { + if err := idtools.MkdirAllAs(filepath.Dir(mtab), 0755, c.RootUID(), c.RootGID()); err != nil { return "", errors.Wrap(err, "error creating mtab directory") } if err = os.Symlink("/proc/mounts", mtab); err != nil && !os.IsExist(err) { -- cgit v1.2.3-54-g00ecf