vfs: Add link permissions

This commit is contained in:
Filipe Azevedo 2022-12-07 21:43:41 +01:00 committed by albertony
parent 0801342108
commit 8323727d19
2 changed files with 7 additions and 0 deletions

View File

@ -140,6 +140,7 @@ func TestVFSNew(t *testing.T) {
// Check making a VFS with nil options
var defaultOpt = vfscommon.DefaultOpt
defaultOpt.DirPerms |= os.ModeDir
defaultOpt.LinkPerms |= os.ModeSymlink
assert.Equal(t, vfs.Opt, defaultOpt)
assert.Equal(t, vfs.f, r.Fremote)

View File

@ -22,6 +22,7 @@ type Options struct {
GID uint32
DirPerms os.FileMode
FilePerms os.FileMode
LinkPerms os.FileMode
ChunkSize fs.SizeSuffix // if > 0 read files in chunks
ChunkSizeLimit fs.SizeSuffix // if > ChunkSize double the chunk size after each chunk until reached
CacheMode CacheMode
@ -52,6 +53,7 @@ var DefaultOpt = Options{
GID: ^uint32(0), // overridden for non windows in mount_unix.go
DirPerms: os.FileMode(0777),
FilePerms: os.FileMode(0666),
LinkPerms: os.ModePerm,
CacheMode: CacheModeOff,
CacheMaxAge: 3600 * time.Second,
CachePollInterval: 60 * time.Second,
@ -72,8 +74,12 @@ func (opt *Options) Init() {
// Mask the permissions with the umask
opt.DirPerms &= ^os.FileMode(opt.Umask)
opt.FilePerms &= ^os.FileMode(opt.Umask)
opt.LinkPerms &= ^os.FileMode(opt.Umask)
// Make sure directories are returned as directories
opt.DirPerms |= os.ModeDir
// Make sure links are returned as links
opt.LinkPerms |= os.ModeSymlink
}