server(filesystem): fix archives in subdirectories

When creating an archive starting from a subdirectory instead of the
root of a server's filesystem, the walker would treat the paths as if
they where relative to the parent of the subdirectory, instead of as
descendants of the subdirectory.

Fixes https://github.com/pterodactyl/panel/issues/5030
This commit is contained in:
Matthew Penner
2024-03-14 13:46:36 -06:00
parent 979df34392
commit ac9bd1d95e
2 changed files with 30 additions and 0 deletions

View File

@@ -66,6 +66,13 @@ func (fs *UnixFS) walkDir(b []byte, parentfd int, name, relative string, d DirEn
}
for _, d1 := range dirs {
// TODO: the path.Join on this line may actually be partially incorrect.
// If we are not walking starting at the root, relative will contain the
// name of the directory we are starting the walk from, which will be
// relative to the root of the filesystem instead of from where the walk
// was initiated from.
//
// ref; https://github.com/pterodactyl/panel/issues/5030
if err := fs.walkDir(b, dirfd, d1.Name(), path.Join(relative, d1.Name()), d1, walkDirFn); err != nil {
if err == SkipDir {
break