From ba75aa1ab0dcef8ad8c8fbb11e8895413ad26787 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Thu, 27 Jan 2022 15:44:09 +0100 Subject: root_test: add TestOverlay ; syscallcompat: add QuirkNoUserXattr --- internal/syscallcompat/quirks.go | 2 ++ internal/syscallcompat/quirks_linux.go | 4 ++++ tests/root_test/root_test.go | 31 +++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/internal/syscallcompat/quirks.go b/internal/syscallcompat/quirks.go index 110c00d..858f16d 100644 --- a/internal/syscallcompat/quirks.go +++ b/internal/syscallcompat/quirks.go @@ -13,6 +13,8 @@ const ( // On MacOS ExFAT, all empty files share inode number 1: // https://github.com/rfjakob/gocryptfs/issues/585 QuirkDuplicateIno1 + // QuirkNoUserXattr means that user.* xattrs are not supported + QuirkNoUserXattr ) func logQuirk(s string) { diff --git a/internal/syscallcompat/quirks_linux.go b/internal/syscallcompat/quirks_linux.go index bcdcf07..5ef2d8a 100644 --- a/internal/syscallcompat/quirks_linux.go +++ b/internal/syscallcompat/quirks_linux.go @@ -27,5 +27,9 @@ func DetectQuirks(cipherdir string) (q uint64) { q |= QuirkBrokenFalloc } + if uint32(st.Type) == unix.TMPFS_MAGIC { + logQuirk("tmpfs detected, no extended attributes except acls will work.") + } + return q } diff --git a/tests/root_test/root_test.go b/tests/root_test/root_test.go index fe38cfa..462aaeb 100644 --- a/tests/root_test/root_test.go +++ b/tests/root_test/root_test.go @@ -362,3 +362,34 @@ func TestBtrfsQuirks(t *testing.T) { t.Errorf("wrong quirk: %v", quirk) } } + +func TestOverlay(t *testing.T) { + if os.Getuid() != 0 { + t.Skip("must run as root") + } + cDir := test_helpers.InitFS(t) + if syscallcompat.DetectQuirks(cDir)|syscallcompat.QuirkNoUserXattr != 0 { + t.Logf("No user xattrs! overlay mount will likely fail.") + } + os.Chmod(cDir, 0755) + pDir := cDir + ".mnt" + test_helpers.MountOrFatal(t, cDir, pDir, "-allow_other", "-extpass=echo test") + defer test_helpers.UnmountPanic(pDir) + + for _, d := range []string{"lower", "upper", "work", "merged"} { + err := os.Mkdir(pDir+"/"+d, 0700) + if err != nil { + t.Fatal(err) + } + } + ovlMnt := pDir + "/merged" + cmd := exec.Command("mount", "-t", "overlay", "overlay", + "-o", "lowerdir="+pDir+"/lower,upperdir="+pDir+"/upper,workdir="+pDir+"/work", + ovlMnt) + out, err := cmd.CombinedOutput() + if err != nil { + t.Log(string(out)) + t.Fatal(err) + } + defer syscall.Unmount(ovlMnt, 0) +} -- cgit v1.2.3