fusefrontend_reverse: secure StatFs agains symlink races

...by ignoring the path that was passed in.

https://github.com/rfjakob/gocryptfs/issues/165
This commit is contained in:
Jakob Unterwurzacher 2017-12-02 21:36:07 +01:00
parent 316b916358
commit 441e796e70
1 changed files with 14 additions and 3 deletions

View File

@ -297,9 +297,20 @@ func (rfs *ReverseFS) OpenDir(cipherPath string, context *fuse.Context) ([]fuse.
return entries, fuse.OK
}
// StatFs - FUSE call
func (rfs *ReverseFS) StatFs(name string) *fuse.StatfsOut {
return rfs.loopbackfs.StatFs(name)
// StatFs - FUSE call. Returns information about the filesystem (free space
// etc).
// Securing statfs against symlink races seems to be more trouble than
// it's worth, so we just ignore the path and always return info about the
// backing storage root dir.
func (rfs *ReverseFS) StatFs(path string) *fuse.StatfsOut {
var s syscall.Statfs_t
err := syscall.Statfs(rfs.args.Cipherdir, &s)
if err != nil {
return nil
}
out := &fuse.StatfsOut{}
out.FromStatfsT(&s)
return out
}
// Readlink - FUSE call