From e433d9038ed0393326aeae6443a278fb65c0b61b Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Tue, 21 Mar 2023 07:22:37 -0600 Subject: [PATCH] Fix linux test remove debug lines --- protect_linux.go | 2 -- protect_linux_ro_dir_test.go | 19 +++++++------------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/protect_linux.go b/protect_linux.go index f1bb598..4c316ad 100644 --- a/protect_linux.go +++ b/protect_linux.go @@ -22,7 +22,6 @@ func (l lands) landAdd(path, flags string) error { switch mode := s.Mode(); { case mode.IsDir(): - log.Println("directory", path) switch flags { case "r": l = append(l, landlock.RODirs(path)) @@ -32,7 +31,6 @@ func (l lands) landAdd(path, flags string) error { l = append(l, landlock.RWDirs(path)) } default: - log.Println("file", path) switch flags { case "r": log.Println("READ ONLY") diff --git a/protect_linux_ro_dir_test.go b/protect_linux_ro_dir_test.go index 50023bf..106d32f 100644 --- a/protect_linux_ro_dir_test.go +++ b/protect_linux_ro_dir_test.go @@ -2,38 +2,33 @@ package protect import ( "os" + "path" "runtime" "testing" ) -/* -FIXME func TestLandlockFileWrite(t *testing.T) { if runtime.GOOS != "linux" { t.Skip("Not running on Linux... skipping landlock test") } - f, err := os.CreateTemp("", "landlockTest") + dir, err := os.MkdirTemp("", "landlock") if err != nil { t.Fatal(err) } - defer os.Remove(f.Name()) + defer os.RemoveAll(dir) - unveil("/tmp", "r") + unveil(dir, "r") err = unveilBlock() if err != nil { t.Fatal(err) } - if c, err := f.Write([]byte("badbeef")); err == nil { - t.Fatalf("wrote %d bytes to %q when I shouldn't have been able too\n", c, f.Name()) - } - - if err := f.Close(); err != nil { - t.Fatal(err) + f, err := os.OpenFile(path.Join(dir, "deadbeef"), os.O_RDWR|os.O_CREATE, 0600) + if err == nil { + t.Fatalf("should not have been able to create %q, but was able to do so\n", f.Name()) } } -*/ func TestLandlockRO(t *testing.T) { if runtime.GOOS != "linux" {