idmap should be able to be specified along with other options

[NO NEW TESTS NEEDED] crun is not available everywhere to test idmap.
Kernel might not be recent enough and not all file systems support
idmap option.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2022-02-08 17:07:29 -05:00
parent 6ffd59828d
commit 61f97083c6

View File

@ -25,7 +25,7 @@ type defaultMountOptions struct {
// The sourcePath variable, if not empty, contains a bind mount source. // The sourcePath variable, if not empty, contains a bind mount source.
func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string, error) { func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string, error) {
var ( var (
foundWrite, foundSize, foundProp, foundMode, foundExec, foundSuid, foundDev, foundCopyUp, foundBind, foundZ, foundU, foundOverlay bool foundWrite, foundSize, foundProp, foundMode, foundExec, foundSuid, foundDev, foundCopyUp, foundBind, foundZ, foundU, foundOverlay, foundIdmap bool
) )
newOptions := make([]string, 0, len(options)) newOptions := make([]string, 0, len(options))
@ -49,9 +49,10 @@ func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string
case "O": case "O":
foundOverlay = true foundOverlay = true
case "idmap": case "idmap":
if len(options) > 1 { if foundIdmap {
return nil, errors.Wrapf(ErrDupeMntOption, "'O' option can not be used with other options") return nil, errors.Wrapf(ErrDupeMntOption, "the 'idmap' option can only be set once")
} }
foundIdmap = true
case "exec", "noexec": case "exec", "noexec":
if foundExec { if foundExec {
return nil, errors.Wrapf(ErrDupeMntOption, "only one of 'noexec' and 'exec' can be used") return nil, errors.Wrapf(ErrDupeMntOption, "only one of 'noexec' and 'exec' can be used")