d1c0ca5260
This wonderfully large commit replaces basically everything under the `server/filesystem` package, re-implementing essentially everything. This is related to https://github.com/pterodactyl/wings/security/advisories/GHSA-494h-9924-xww9 If any vulnerabilities related to symlinks persist after this commit, I will be very upset. Signed-off-by: Matthew Penner <me@matthewp.io>
25 lines
706 B
Go
25 lines
706 B
Go
package filesystem
|
|
|
|
import (
|
|
"syscall"
|
|
"time"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// CTime returns the time that the file/folder was created.
|
|
//
|
|
// TODO: remove. Ctim is not actually ever been correct and doesn't actually
|
|
// return the creation time.
|
|
func (s *Stat) CTime() time.Time {
|
|
if st, ok := s.Sys().(*unix.Stat_t); ok {
|
|
// Do not remove these "redundant" type-casts, they are required for 32-bit builds to work.
|
|
return time.Unix(int64(st.Ctim.Sec), int64(st.Ctim.Nsec))
|
|
}
|
|
if st, ok := s.Sys().(*syscall.Stat_t); ok {
|
|
// Do not remove these "redundant" type-casts, they are required for 32-bit builds to work.
|
|
return time.Unix(int64(st.Ctim.Sec), int64(st.Ctim.Nsec))
|
|
}
|
|
return time.Time{}
|
|
}
|