summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-08-08 14:20:29 +0200
committerGitHub <noreply@github.com>2019-08-08 14:20:29 +0200
commit8776a577bf6b86a4e034c54243c5e4a419d14c35 (patch)
treef4c228599300c89fdd24c051941bf37849960d9f /pkg
parent31bfb12aec6123bd97e84b2067096b09676ca6ac (diff)
parentc0a124ea890cdeefa9330b7ef600f41db76ee3d9 (diff)
downloadpodman-8776a577bf6b86a4e034c54243c5e4a419d14c35.tar.gz
podman-8776a577bf6b86a4e034c54243c5e4a419d14c35.tar.bz2
podman-8776a577bf6b86a4e034c54243c5e4a419d14c35.zip
Merge pull request #3738 from mheon/mount_opts_bools
Allow --ro=[true|false] with mount flag
Diffstat (limited to 'pkg')
-rw-r--r--pkg/spec/storage.go31
1 files changed, 30 insertions, 1 deletions
diff --git a/pkg/spec/storage.go b/pkg/spec/storage.go
index ac7a2c30f..e0bb48a9c 100644
--- a/pkg/spec/storage.go
+++ b/pkg/spec/storage.go
@@ -410,13 +410,42 @@ func getBindMount(args []string) (spec.Mount, error) {
setSource := false
setDest := false
+ setRORW := false
for _, val := range args {
kv := strings.Split(val, "=")
switch kv[0] {
case "bind-nonrecursive":
newMount.Options = append(newMount.Options, "bind")
- case "ro", "nosuid", "nodev", "noexec":
+ case "ro", "rw":
+ if setRORW {
+ return newMount, errors.Wrapf(optionArgError, "cannot pass 'ro' or 'rw' options more than once")
+ }
+ setRORW = true
+ // Can be formatted as one of:
+ // ro
+ // ro=[true|false]
+ // rw
+ // rw=[true|false]
+ if len(kv) == 1 {
+ newMount.Options = append(newMount.Options, kv[0])
+ } else if len(kv) == 2 {
+ switch strings.ToLower(kv[1]) {
+ case "true":
+ newMount.Options = append(newMount.Options, kv[0])
+ case "false":
+ // Set the opposite only for rw
+ // ro's opposite is the default
+ if kv[0] == "rw" {
+ newMount.Options = append(newMount.Options, "ro")
+ }
+ default:
+ return newMount, errors.Wrapf(optionArgError, "%s must be set to true or false, instead received %q", kv[0], kv[1])
+ }
+ } else {
+ return newMount, errors.Wrapf(optionArgError, "badly formatted option %q", val)
+ }
+ case "nosuid", "nodev", "noexec":
// TODO: detect duplication of these options.
// (Is this necessary?)
newMount.Options = append(newMount.Options, kv[0])