feat: add option to allow symlinked directories as buckets

This adds the ability to treat symlinks to directories at the top
level gateway directory as buckets the same as normal directories.

This could be a potential security issue allowing traversal into
other filesystems within the system, so is defaulted to off. This
can be enabled when specifically needed for both posix and scoutfs
backend systems.

Fixes #644
This commit is contained in:
Ben McClelland
2024-07-13 10:21:15 -07:00
parent 5d33c7bde5
commit f6dd2f947c
6 changed files with 57 additions and 18 deletions
+10 -2
View File
@@ -24,6 +24,7 @@ import (
var (
chownuid, chowngid bool
bucketlinks bool
)
func posixCommand() *cli.Command {
@@ -54,6 +55,12 @@ will be translated into the file /mnt/fs/gwroot/mybucket/a/b/c/myobject`,
EnvVars: []string{"VGW_CHOWN_GID"},
Destination: &chowngid,
},
&cli.BoolFlag{
Name: "bucketlinks",
Usage: "allow symlinked directories at bucket level to be treated as buckets",
EnvVars: []string{"VGW_BUCKET_LINKS"},
Destination: &bucketlinks,
},
},
}
}
@@ -70,8 +77,9 @@ func runPosix(ctx *cli.Context) error {
}
be, err := posix.New(gwroot, meta.XattrMeta{}, posix.PosixOpts{
ChownUID: chownuid,
ChownGID: chowngid,
ChownUID: chownuid,
ChownGID: chowngid,
BucketLinks: bucketlinks,
})
if err != nil {
return fmt.Errorf("init posix: %v", err)
+7
View File
@@ -63,6 +63,12 @@ move interfaces as well as support for tiered filesystems.`,
EnvVars: []string{"VGW_CHOWN_GID"},
Destination: &chowngid,
},
&cli.BoolFlag{
Name: "bucketlinks",
Usage: "allow symlinked directories at bucket level to be treated as buckets",
EnvVars: []string{"VGW_BUCKET_LINKS"},
Destination: &bucketlinks,
},
},
}
}
@@ -76,6 +82,7 @@ func runScoutfs(ctx *cli.Context) error {
opts.GlacierMode = glacier
opts.ChownUID = chownuid
opts.ChownGID = chowngid
opts.BucketLinks = bucketlinks
be, err := scoutfs.New(ctx.Args().Get(0), opts)
if err != nil {