Skip to content

Commit

Permalink
Fix addition of mount options when using RO tmpfs
Browse files Browse the repository at this point in the history
For read-only containers set to create tmpfs filesystems over
/run and other common destinations, we were incorrectly setting
mount options, resulting in duplicate mount options.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
  • Loading branch information
mheon committed Aug 23, 2019
1 parent 75aff55 commit b32ef81
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pkg/spec/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,16 @@ func (config *CreateConfig) parseVolumes(runtime *libpod.Runtime) ([]spec.Mount,
// If requested, add tmpfs filesystems for read-only containers.
if config.ReadOnlyRootfs && config.ReadOnlyTmpfs {
readonlyTmpfs := []string{"/tmp", "/var/tmp", "/run"}
options := []string{"rw", "rprivate", "exec", "nosuid", "nodev", "tmpcopyup"}
options := []string{"rw", "rprivate", "nosuid", "nodev", "tmpcopyup"}
for _, dest := range readonlyTmpfs {
if _, ok := baseMounts[dest]; ok {
continue
}
localOpts := options
if dest == "/run" {
localOpts = append(localOpts, "dev", "suid", "noexec", "size=65536k")
localOpts = append(localOpts, "noexec", "size=65536k")
} else {
localOpts = append(localOpts, "exec")
}
baseMounts[dest] = spec.Mount{
Destination: dest,
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/mountOpts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var (
// ErrBadMntOption indicates that an invalid mount option was passed.
ErrBadMntOption = errors.Errorf("invalid mount option")
// ErrDupeMntOption indicates that a duplicate mount option was passed.
ErrDupeMntOption = errors.Errorf("duplicate option passed")
ErrDupeMntOption = errors.Errorf("duplicate mount option passed")
)

// DefaultMountOptions sets default mount options for ProcessOptions.
Expand Down

0 comments on commit b32ef81

Please sign in to comment.