mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
durable: red test, a created lock directory's parent must be 0755
V1-SPEC r2.45 (1): MkdirAll(locks, 0700) also makes a missing parent /run/sw-block 0700; created by root, it keeps the unit's user out even after the locks directory is chowned. The tmpfiles.d layout is parent 0755, locks 0700. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4c5d05e058
commit
286f5ebeb8
1 file changed
+40
@@ -0,0 +1,40 @@
|
||||
//go:build unix
|
||||
|
||||
package durable_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/durable"
|
||||
)
|
||||
|
||||
// V1-SPEC r2.45 (1), as the tmpfiles.d entry lays it out: a lock directory
|
||||
// the provider creates gets a traversable parent (0755) and is itself 0700,
|
||||
// whatever the umask. A 0700 parent created by root would keep the unit's
|
||||
// user out even after the locks directory is chowned to it.
|
||||
func TestHostVolumeLockCreatesParent0755AndLocks0700(t *testing.T) {
|
||||
old := syscall.Umask(0o077) // a strict umask must not narrow the parent
|
||||
defer syscall.Umask(old)
|
||||
parent := filepath.Join(t.TempDir(), "sw-block")
|
||||
locks := filepath.Join(parent, "locks")
|
||||
p, err := durable.NewDurableProvider(durable.ProviderConfig{
|
||||
Impl: durable.ImplWALStore, StorageRoot: t.TempDir(), BlockSize: 4096, NumBlocks: pcBlocks,
|
||||
HostVolumeLock: true, VolumeLockDirTestOnly: locks,
|
||||
}, v1View())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_ = p.Close()
|
||||
for path, want := range map[string]os.FileMode{parent: 0o755, locks: 0o700} {
|
||||
fi, err := os.Stat(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := fi.Mode().Perm(); got != want {
|
||||
t.Fatalf("%s created %v, want %v", path, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user