aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2022-01-10 20:05:36 +0100
committerJakob Unterwurzacher2022-01-10 20:05:36 +0100
commit5f955423b736d56b5b741fbd1b853c83044aa0fe (patch)
treee0a74b15deb5c99c7e1984b7cf13f1d17598e91b
parentc23a7f225984af1aa9fd0113f93be837a13d9b08 (diff)
fusefrontend: fix -force_owner not affecting MKNOD
Fixes https://github.com/rfjakob/gocryptfs/issues/629
-rw-r--r--internal/fusefrontend/node.go6
-rw-r--r--tests/defaults/main_test.go15
2 files changed, 20 insertions, 1 deletions
diff --git a/internal/fusefrontend/node.go b/internal/fusefrontend/node.go
index 182cda5..ead77c9 100644
--- a/internal/fusefrontend/node.go
+++ b/internal/fusefrontend/node.go
@@ -277,7 +277,13 @@ func (n *Node) Mknod(ctx context.Context, name string, mode, rdev uint32, out *f
errno = fs.ToErrno(err)
return
}
+
inode = n.newChild(ctx, st, out)
+
+ if rn.args.ForceOwner != nil {
+ out.Owner = *rn.args.ForceOwner
+ }
+
return inode, 0
}
diff --git a/tests/defaults/main_test.go b/tests/defaults/main_test.go
index 0f31a72..7633e8b 100644
--- a/tests/defaults/main_test.go
+++ b/tests/defaults/main_test.go
@@ -427,10 +427,11 @@ func TestFsync(t *testing.T) {
}
// force_owner was broken by the v2.0 rewrite:
-// The owner was only forced for GETATTR, but not for CREATE or LOOKUP.
+// The owner was only forced for GETATTR, but not for CREATE, LOOKUP, MKNOD.
//
// https://github.com/rfjakob/gocryptfs/issues/609
// https://github.com/rfjakob/gocryptfs/pull/610
+// https://github.com/rfjakob/gocryptfs/issues/629
func TestForceOwner(t *testing.T) {
cDir := test_helpers.InitFS(t)
os.Chmod(cDir, 0777) // Mount needs to be accessible for us
@@ -479,6 +480,18 @@ func TestForceOwner(t *testing.T) {
t.Errorf("GETATTR returned uid or gid != 1234: %#v", st)
}
+ // Test MKNOD
+ sock := pDir + "/sock"
+ if err := syscall.Mknod(sock, syscall.S_IFSOCK|0600, 0); err != nil {
+ t.Fatal(err)
+ }
+ if err := syscall.Stat(sock, &st); err != nil {
+ t.Fatal(err)
+ }
+ if st.Uid != 1234 || st.Gid != 1234 {
+ t.Errorf("MKNOD returned uid or gid != 1234: %#v", st)
+ }
+
// Remount to clear cache
test_helpers.UnmountPanic(pDir)
test_helpers.MountOrFatal(t, cDir, pDir, "-force_owner=1234:1234", "-extpass=echo test")