diff options
author | Jakob Unterwurzacher | 2019-01-02 20:48:46 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2019-01-02 20:48:46 +0100 |
commit | b214be5e3f76dd17efc9832131f4a7e0414b4cea (patch) | |
tree | 511e71e93a919f7319df7ee774eaa5c2e1fd974c /internal/fusefrontend/fs.go | |
parent | d269c28d169cdf071acf57d283b756cde2b6437f (diff) |
fusefrontend: xattr: fix operations on files without read permissions
* listxattr is fixed via the /proc/self/fd trick
* setxattr,removexattr are fixed by opening the file O_WRONLY
Fixes https://github.com/rfjakob/gocryptfs/issues/308
Diffstat (limited to 'internal/fusefrontend/fs.go')
-rw-r--r-- | internal/fusefrontend/fs.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go index e7c3903..5c52a19 100644 --- a/internal/fusefrontend/fs.go +++ b/internal/fusefrontend/fs.go @@ -160,6 +160,17 @@ func (fs *FS) Open(path string, flags uint32, context *fuse.Context) (fuseFile n return NewFile(f, fs) } +// openBackingFile opens the ciphertext file that backs relative plaintext +// path "relPath". Always adds O_NOFOLLOW to the flags. +func (fs *FS) openBackingFile(relPath string, flags int) (fd int, err error) { + dirfd, cName, err := fs.openBackingDir(relPath) + if err != nil { + return -1, err + } + defer syscall.Close(dirfd) + return syscallcompat.Openat(dirfd, cName, flags|syscall.O_NOFOLLOW, 0) +} + // Due to RMW, we always need read permissions on the backing file. This is a // problem if the file permissions do not allow reading (i.e. 0200 permissions). // This function works around that problem by chmod'ing the file, obtaining a fd, |