aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2025-06-05 19:31:29 +0200
committerJakob Unterwurzacher2025-06-05 19:31:29 +0200
commit4358a9f998d469bf6aac077d76847498710c6b42 (patch)
tree3d00301be582c364880d696005d3a94095ab6b8f
parente55a637512131c21a7eb16574aba799abd2a336f (diff)
mount: fix -force_owner not allowing file/dir createHEADmaster
Fixes https://github.com/rfjakob/gocryptfs/issues/783
-rw-r--r--mount.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/mount.go b/mount.go
index 1005a39..5c0f064 100644
--- a/mount.go
+++ b/mount.go
@@ -315,9 +315,13 @@ func initFuseFrontend(args *argContainer) (rootNode fs.InodeEmbedder, wipeKeys f
}
}
}
- // If allow_other is set and we run as root, try to give newly created files to
- // the right user.
- if args.allow_other && os.Getuid() == 0 {
+ // If allow_other is set and we run as root, create files as the accessing
+ // user.
+ // Except when -force_owner is set, because in this case the user may
+ // not have write permissions. And the point of -force_owner is to map uids,
+ // so we want the files on the backing dir to get the uid the gocryptfs process
+ // is running as.
+ if args.allow_other && os.Getuid() == 0 && args._forceOwner == nil {
frontendArgs.PreserveOwner = true
}