Clean the source and target paths when adding a mount

This commit is contained in:
Matthew Penner 2020-07-04 15:37:52 -06:00
parent 3a6050446f
commit 9f95efa3ae

View File

@ -18,6 +18,7 @@ import (
"github.com/pterodactyl/wings/config" "github.com/pterodactyl/wings/config"
"io" "io"
"os" "os"
"path/filepath"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -671,8 +672,10 @@ func (d *DockerEnvironment) Create() error {
} }
for _, m := range d.Server.Mounts { for _, m := range d.Server.Mounts {
source := filepath.Clean(m.Source)
for _, allowed := range config.Get().AllowedMounts { for _, allowed := range config.Get().AllowedMounts {
if !strings.HasPrefix(m.Source, allowed) { if !strings.HasPrefix(source, allowed) {
continue continue
} }
@ -685,8 +688,8 @@ func (d *DockerEnvironment) Create() error {
mounts = append(mounts, mount.Mount{ mounts = append(mounts, mount.Mount{
Type: mount.TypeBind, Type: mount.TypeBind,
Source: m.Source, Source: source,
Target: m.Target, Target: filepath.Clean(m.Target),
ReadOnly: m.ReadOnly, ReadOnly: m.ReadOnly,
}) })
} }