Skip to content

Commit

Permalink
oci: partially restore comment on read-only mounts for uid/gid uses
Browse files Browse the repository at this point in the history
Commit cab0562 removed the tryReadonlyMounts
utility, in favor of mounts.ReadOnlyMounts() that was added in commit
daa3a76.

That change made part of the comment redundant, because mounts.ReadOnlyMounts
handles both overlayfs read-only mounts (by skipping the workdir mounts), and
sets the "ro" option for other mount-types, but the reason why we're using a
read-only mount is still relevant, so restoring that part of the comment.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit cb2c3ec)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Apr 17, 2023
1 parent d945322 commit 1bbf98e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions oci/spec_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,10 @@ func WithUser(userstr string) SpecOpts {
return err
}

// Use a read-only mount when trying to get user/group information
// from the container's rootfs. Since the option does read operation
// only, we append ReadOnly mount option to prevent the Linux kernel
// from syncing whole filesystem in umount syscall.
return mount.WithReadonlyTempMount(ctx, mounts, f)
default:
return fmt.Errorf("invalid USER value %s", userstr)
Expand Down Expand Up @@ -743,6 +747,10 @@ func WithUserID(uid uint32) SpecOpts {
return err
}

// Use a read-only mount when trying to get user/group information
// from the container's rootfs. Since the option does read operation
// only, we append ReadOnly mount option to prevent the Linux kernel
// from syncing whole filesystem in umount syscall.
return mount.WithReadonlyTempMount(ctx, mounts, setUser)
}
}
Expand Down Expand Up @@ -787,6 +795,10 @@ func WithUsername(username string) SpecOpts {
return err
}

// Use a read-only mount when trying to get user/group information
// from the container's rootfs. Since the option does read operation
// only, we append ReadOnly mount option to prevent the Linux kernel
// from syncing whole filesystem in umount syscall.
return mount.WithReadonlyTempMount(ctx, mounts, setUser)
} else if s.Windows != nil {
s.Process.User.Username = username
Expand Down Expand Up @@ -865,6 +877,10 @@ func WithAdditionalGIDs(userstr string) SpecOpts {
return err
}

// Use a read-only mount when trying to get user/group information
// from the container's rootfs. Since the option does read operation
// only, we append ReadOnly mount option to prevent the Linux kernel
// from syncing whole filesystem in umount syscall.
return mount.WithReadonlyTempMount(ctx, mounts, setAdditionalGids)
}
}
Expand Down Expand Up @@ -926,6 +942,10 @@ func WithAppendAdditionalGroups(groups ...string) SpecOpts {
return err
}

// Use a read-only mount when trying to get user/group information
// from the container's rootfs. Since the option does read operation
// only, we append ReadOnly mount option to prevent the Linux kernel
// from syncing whole filesystem in umount syscall.
return mount.WithReadonlyTempMount(ctx, mounts, setAdditionalGids)
}
}
Expand Down

0 comments on commit 1bbf98e

Please sign in to comment.