Files
seaweedfs/weed/command/mount_std_test.go
T
07e1299f98 mount: add -idmap to allow ID-mapped bind mounts (#12922)
* mount: add -idmap to allow ID-mapped bind mounts

FUSE allows ID-mapped mounts only for a server that announces FUSE_ALLOW_IDMAP.
Once announced, the kernel sends uid and gid 0xFFFFFFFF on most requests after checking permissions itself, so the checks that read the caller treat that value as already checked.

* fuse: refuse an unsupported -o idmap before starting the child

The child exits on checkIdmap, but the parent waits for its readiness signal
and never returns, so weed fuse -o idmap hung on macOS and FreeBSD.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mount: refuse -idmap on Windows instead of ignoring it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fuse: take -o defaultPermissions as the mount flag

-o defaultPermissions=false was forwarded to the kernel as an unknown
option, which failed the mount, and left the flag at true, so
-o idmap,defaultPermissions=false passed the idmap check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 15:25:34 -08:00

75 lines
1.7 KiB
Go

//go:build linux || darwin || freebsd
package command
import "testing"
func Test_bucketPathForMountRoot(t *testing.T) {
tests := []struct {
name string
mountRoot string
expected string
ok bool
}{
{
name: "bucket root mount",
mountRoot: "/buckets/test",
expected: "/buckets/test",
ok: true,
},
{
name: "bucket root with trailing slash",
mountRoot: "/buckets/test/",
expected: "/buckets/test",
ok: true,
},
{
name: "subdirectory mount",
mountRoot: "/buckets/test/data",
expected: "",
ok: false,
},
{
name: "non-bucket mount",
mountRoot: "/data/test",
expected: "",
ok: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotPath, gotOK := bucketPathForMountRoot(tt.mountRoot, "/buckets")
if gotOK != tt.ok {
t.Fatalf("expected ok=%v, got %v", tt.ok, gotOK)
}
if gotPath != tt.expected {
t.Fatalf("expected path %q, got %q", tt.expected, gotPath)
}
})
}
}
func TestCheckIdmap(t *testing.T) {
tests := []struct {
name string
goos string
idmap bool
defaultPermissions bool
ok bool
}{
{"off", "darwin", false, false, true},
{"linux", "linux", true, true, true},
{"not linux", "darwin", true, true, false},
{"without default permissions", "linux", true, false, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := checkIdmap(tt.goos, tt.idmap, tt.defaultPermissions)
if (err == nil) != tt.ok {
t.Fatalf("checkIdmap(%q, %v, %v) = %v, want ok=%v", tt.goos, tt.idmap, tt.defaultPermissions, err, tt.ok)
}
})
}
}