diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-03 18:34:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-03 18:34:01 +0200 |
commit | 2d9b9e81a30ac46848587414d34955ad4cb991a7 (patch) | |
tree | a9467bc800c4441448873018912de215950d540a /pkg/util/mountOpts.go | |
parent | a89d62ac3a445a5d76bd72d4b8e1bb9262ba74c6 (diff) | |
parent | e0614367ca27c2e47649e08291e0f1d19d42232e (diff) | |
download | podman-2d9b9e81a30ac46848587414d34955ad4cb991a7.tar.gz podman-2d9b9e81a30ac46848587414d34955ad4cb991a7.tar.bz2 podman-2d9b9e81a30ac46848587414d34955ad4cb991a7.zip |
Merge pull request #5676 from kolyshkin/volume-flags-alt
Fix/improve pkg/storage.InitFSMounts
Diffstat (limited to 'pkg/util/mountOpts.go')
-rw-r--r-- | pkg/util/mountOpts.go | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/pkg/util/mountOpts.go b/pkg/util/mountOpts.go index d21800bc3..329a7c913 100644 --- a/pkg/util/mountOpts.go +++ b/pkg/util/mountOpts.go @@ -13,19 +13,17 @@ var ( ErrDupeMntOption = errors.Errorf("duplicate mount option passed") ) -// DefaultMountOptions sets default mount options for ProcessOptions. -type DefaultMountOptions struct { - Noexec bool - Nosuid bool - Nodev bool +type defaultMountOptions struct { + noexec bool + nosuid bool + nodev bool } // ProcessOptions parses the options for a bind or tmpfs mount and ensures that // they are sensible and follow convention. The isTmpfs variable controls // whether extra, tmpfs-specific options will be allowed. -// The defaults variable controls default mount options that will be set. If it -// is not included, they will be set unconditionally. -func ProcessOptions(options []string, isTmpfs bool, defaults *DefaultMountOptions) ([]string, error) { +// The sourcePath variable, if not empty, contains a bind mount source. +func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string, error) { var ( foundWrite, foundSize, foundProp, foundMode, foundExec, foundSuid, foundDev, foundCopyUp, foundBind, foundZ bool ) @@ -122,13 +120,17 @@ func ProcessOptions(options []string, isTmpfs bool, defaults *DefaultMountOption if !foundProp { newOptions = append(newOptions, "rprivate") } - if !foundExec && (defaults == nil || defaults.Noexec) { + defaults, err := getDefaultMountOptions(sourcePath) + if err != nil { + return nil, err + } + if !foundExec && defaults.noexec { newOptions = append(newOptions, "noexec") } - if !foundSuid && (defaults == nil || defaults.Nosuid) { + if !foundSuid && defaults.nosuid { newOptions = append(newOptions, "nosuid") } - if !foundDev && (defaults == nil || defaults.Nodev) { + if !foundDev && defaults.nodev { newOptions = append(newOptions, "nodev") } if isTmpfs && !foundCopyUp { |