diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2019-01-18 15:01:53 -0500 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2019-02-08 15:02:28 -0500 |
commit | 14eaca337af0fe3c66624a1a808157b6de8bff68 (patch) | |
tree | 5f09e9c7578491da839b71351f7ff0b3f205157f /libpod | |
parent | 2ba7b991b2bae4148eef977136c57f9da828f9bf (diff) | |
download | podman-14eaca337af0fe3c66624a1a808157b6de8bff68.tar.gz podman-14eaca337af0fe3c66624a1a808157b6de8bff68.tar.bz2 podman-14eaca337af0fe3c66624a1a808157b6de8bff68.zip |
Vendor in latest opencontainers/selinux
This will now verify labels passed in by the user.
Will also prevent users from accidently relabeling their homedir.
podman run -ti -v ~/home/user:Z fedora sh
Is not a good idea.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/oci.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/libpod/oci.go b/libpod/oci.go index 31c1a7e85..a1894b52f 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -357,18 +357,25 @@ func (r *OCIRuntime) createOCIContainer(ctr *Container, cgroupParent string, res // Set the label of the conmon process to be level :s0 // This will allow the container processes to talk to fifo-files // passed into the container by conmon - var plabel string + var ( + plabel string + con selinux.Context + ) plabel, err = selinux.CurrentLabel() if err != nil { childPipe.Close() return errors.Wrapf(err, "Failed to get current SELinux label") } - c := selinux.NewContext(plabel) + con, err = selinux.NewContext(plabel) + if err != nil { + return errors.Wrapf(err, "Failed to get new context from SELinux label") + } + runtime.LockOSThread() - if c["level"] != "s0" && c["level"] != "" { - c["level"] = "s0" - if err = label.SetProcessLabel(c.Get()); err != nil { + if con["level"] != "s0" && con["level"] != "" { + con["level"] = "s0" + if err = label.SetProcessLabel(con.Get()); err != nil { runtime.UnlockOSThread() return err } |