Skip to content

Commit

Permalink
[NO TESTS NEEDED] Create /etc/mtab with the correct ownership
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
umohnani8 committed Jun 23, 2021
1 parent e50e0da commit 9db534e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libpod/container_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9db534e

Please sign in to comment.