diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2019-09-16 08:39:39 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2019-09-16 09:56:43 -0400 |
commit | 405ef9bc5636b8940f93413231ed1e4299e3d4ac (patch) | |
tree | 19c24974ec46d5d5136b25250d86bb7be02984e2 /pkg | |
parent | a1970e1915fa99c1893bccd3a71a11d2bff77602 (diff) | |
download | podman-405ef9bc5636b8940f93413231ed1e4299e3d4ac.tar.gz podman-405ef9bc5636b8940f93413231ed1e4299e3d4ac.tar.bz2 podman-405ef9bc5636b8940f93413231ed1e4299e3d4ac.zip |
Add 'relabel' to --mount options
Currently if a user specifies a --mount option, their is no way to tell SELinux
to relabel the mount point.
This patch addes the relabel=shared and relabel=private options.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/spec/storage.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/pkg/spec/storage.go b/pkg/spec/storage.go index bc0eaad6d..cc091dcee 100644 --- a/pkg/spec/storage.go +++ b/pkg/spec/storage.go @@ -389,7 +389,7 @@ func getBindMount(args []string) (spec.Mount, error) { Type: TypeBind, } - var setSource, setDest, setRORW, setSuid, setDev, setExec bool + var setSource, setDest, setRORW, setSuid, setDev, setExec, setRelabel bool for _, val := range args { kv := strings.Split(val, "=") @@ -467,6 +467,22 @@ func getBindMount(args []string) (spec.Mount, error) { } newMount.Destination = kv[1] setDest = true + case "relabel": + if setRelabel { + return newMount, errors.Wrapf(optionArgError, "cannot pass 'relabel' option more than once") + } + setRelabel = true + if len(kv) != 2 { + return newMount, errors.Wrapf(util.ErrBadMntOption, "%s mount option must be 'private' or 'shared'", kv[0]) + } + switch kv[1] { + case "private": + newMount.Options = append(newMount.Options, "z") + case "shared": + newMount.Options = append(newMount.Options, "Z") + default: + return newMount, errors.Wrapf(util.ErrBadMntOption, "%s mount option must be 'private' or 'shared'", kv[0]) + } default: return newMount, errors.Wrapf(util.ErrBadMntOption, kv[0]) } |