aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-03-02 19:11:24 +0100
committerJakob Unterwurzacher2017-03-02 19:12:21 +0100
commitb2f3dbb8bd37ebca50eeb33775c980e2ca1f9053 (patch)
tree42197ea1b78ddeed5e96c0c46e52d07f4b5af297 /internal
parentb765cc526d3881f7b655200823c5ca72c03548bc (diff)
fusefrontend: when chown'ing a directory, also chown its diriv
When filename encryption is active, every directory contains a "gocryptfs.diriv" file. This file should also change the owner. Fixes https://github.com/rfjakob/gocryptfs/issues/86
Diffstat (limited to 'internal')
-rw-r--r--internal/fusefrontend/fs.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index cdbb7e5..e6e9bdf 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -187,7 +187,19 @@ func (fs *FS) Chown(path string, uid uint32, gid uint32, context *fuse.Context)
if err != nil {
return fuse.ToStatus(err)
}
- return fuse.ToStatus(os.Lchown(cPath, int(uid), int(gid)))
+ code = fuse.ToStatus(os.Lchown(cPath, int(uid), int(gid)))
+ if !code.Ok() {
+ return code
+ }
+ if !fs.args.PlaintextNames {
+ // When filename encryption is active, every directory contains
+ // a "gocryptfs.diriv" file. This file should also change the owner.
+ // Instead of checking if "cPath" is a directory, we just blindly
+ // execute the Lchown on "cPath/gocryptfs.diriv" and ignore errors.
+ dirIVPath := filepath.Join(cPath, nametransform.DirIVFilename)
+ os.Lchown(dirIVPath, int(uid), int(gid))
+ }
+ return fuse.OK
}
// Mknod implements pathfs.Filesystem.