From b2f3dbb8bd37ebca50eeb33775c980e2ca1f9053 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Thu, 2 Mar 2017 19:11:24 +0100 Subject: 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 --- internal/fusefrontend/fs.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'internal') 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. -- cgit v1.2.3