Code cleanup and avoid server race
This commit is contained in:
parent
e28c05ae56
commit
5079c67aee
|
@ -41,13 +41,12 @@ func IsPathResolutionError(err error) bool {
|
||||||
|
|
||||||
type Filesystem struct {
|
type Filesystem struct {
|
||||||
Server *Server
|
Server *Server
|
||||||
Configuration *config.SystemConfiguration
|
|
||||||
cacheDiskMu sync.Mutex
|
cacheDiskMu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the root path that contains all of a server's data.
|
// Returns the root path that contains all of a server's data.
|
||||||
func (fs *Filesystem) Path() string {
|
func (fs *Filesystem) Path() string {
|
||||||
return filepath.Join(fs.Configuration.Data, fs.Server.Uuid)
|
return filepath.Join(config.Get().System.Data, fs.Server.Id())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalizes a directory being passed in to ensure the user is not able to escape
|
// Normalizes a directory being passed in to ensure the user is not able to escape
|
||||||
|
@ -475,7 +474,7 @@ func (fs *Filesystem) Chown(path string) error {
|
||||||
if s, err := os.Stat(cleaned); err != nil {
|
if s, err := os.Stat(cleaned); err != nil {
|
||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
} else if !s.IsDir() {
|
} else if !s.IsDir() {
|
||||||
return os.Chown(cleaned, fs.Configuration.User.Uid, fs.Configuration.User.Gid)
|
return os.Chown(cleaned, config.Get().System.User.Uid, config.Get().System.User.Gid)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fs.chownDirectory(cleaned)
|
return fs.chownDirectory(cleaned)
|
||||||
|
@ -521,7 +520,7 @@ func (fs *Filesystem) chownDirectory(path string) error {
|
||||||
fs.chownDirectory(p)
|
fs.chownDirectory(p)
|
||||||
}(p)
|
}(p)
|
||||||
} else {
|
} else {
|
||||||
os.Chown(p, fs.Configuration.User.Uid, fs.Configuration.User.Gid)
|
os.Chown(p, config.Get().System.User.Uid, config.Get().System.User.Gid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"github.com/patrickmn/go-cache"
|
"github.com/patrickmn/go-cache"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/pterodactyl/wings/api"
|
"github.com/pterodactyl/wings/api"
|
||||||
"github.com/pterodactyl/wings/config"
|
|
||||||
"github.com/remeh/sizedwaitgroup"
|
"github.com/remeh/sizedwaitgroup"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -109,7 +108,6 @@ func FromConfiguration(data *api.ServerConfigurationResponse) (*Server, error) {
|
||||||
Server: s,
|
Server: s,
|
||||||
}
|
}
|
||||||
s.Filesystem = Filesystem{
|
s.Filesystem = Filesystem{
|
||||||
Configuration: &config.Get().System,
|
|
||||||
Server: s,
|
Server: s,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user