Use clean path for map and comparison.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2019-03-03 21:01:18 -08:00
parent 210e80289b
commit 0464298b1e
3 changed files with 22 additions and 6 deletions

View File

@@ -186,7 +186,7 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
if len(volumeMounts) > 0 {
mountMap := make(map[string]string)
for _, v := range volumeMounts {
mountMap[v.HostPath] = v.ContainerPath
mountMap[filepath.Clean(v.HostPath)] = v.ContainerPath
}
opts = append(opts, customopts.WithVolumes(mountMap))
}
@@ -750,7 +750,7 @@ func setOCIBindMountsPrivileged(g *generator) {
spec := g.Config
// clear readonly for /sys and cgroup
for i, m := range spec.Mounts {
if spec.Mounts[i].Destination == "/sys" {
if filepath.Clean(spec.Mounts[i].Destination) == "/sys" {
clearReadOnly(&spec.Mounts[i])
}
if m.Type == "cgroup" {
@@ -908,7 +908,7 @@ func defaultRuntimeSpec(id string) (*runtimespec.Spec, error) {
// TODO(random-liu): Mount tmpfs for /run and handle copy-up.
var mounts []runtimespec.Mount
for _, mount := range spec.Mounts {
if mount.Destination == "/run" {
if filepath.Clean(mount.Destination) == "/run" {
continue
}
mounts = append(mounts, mount)