Allow :z and :Z with ProcessOptions

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
This commit is contained in:
Matthew Heon 2019-08-23 15:10:57 -04:00
parent 5bdd97f77f
commit 820e242e82
1 changed files with 8 additions and 1 deletions

View File

@ -27,7 +27,7 @@ type DefaultMountOptions struct {
// is not included, they will be set unconditionally. // is not included, they will be set unconditionally.
func ProcessOptions(options []string, isTmpfs bool, defaults *DefaultMountOptions) ([]string, error) { func ProcessOptions(options []string, isTmpfs bool, defaults *DefaultMountOptions) ([]string, error) {
var ( var (
foundWrite, foundSize, foundProp, foundMode, foundExec, foundSuid, foundDev, foundCopyUp, foundBind bool foundWrite, foundSize, foundProp, foundMode, foundExec, foundSuid, foundDev, foundCopyUp, foundBind, foundZ bool
) )
for _, opt := range options { for _, opt := range options {
@ -91,6 +91,13 @@ func ProcessOptions(options []string, isTmpfs bool, defaults *DefaultMountOption
return nil, errors.Wrapf(ErrDupeMntOption, "only one of 'rbind' and 'bind' can be used") return nil, errors.Wrapf(ErrDupeMntOption, "only one of 'rbind' and 'bind' can be used")
} }
foundBind = true foundBind = true
case "z", "Z":
if isTmpfs {
return nil, errors.Wrapf(ErrBadMntOption, "the 'z' and 'Z' options are not allowed with tmpfs mounts")
}
if foundZ {
return nil, errors.Wrapf(ErrDupeMntOption, "only one of 'z' and 'Z' can be used")
}
default: default:
return nil, errors.Wrapf(ErrBadMntOption, "unknown mount option %q", opt) return nil, errors.Wrapf(ErrBadMntOption, "unknown mount option %q", opt)
} }