rfjakob / gocryptfs

Encrypted overlay filesystem written in Go
https://nuetzlich.net/gocryptfs/
MIT License
3.5k stars 249 forks source link

Proposal: Xattr handling of files/directories without read permission on macOS #344

Open slackner opened 5 years ago

slackner commented 5 years ago

On macOS, the xattr tests still cause a couple of test failures:

DecryptBlock: Block is too short: 3 bytes
DecryptBlock: Block is too short: 2 bytes
GetXAttr: Block is too short
GetXAttr: cipher: message authentication failed
GetXAttr: cipher: message authentication failed
GetXAttr: cipher: message authentication failed
--- FAIL: TestList0000File (0.00s)
    xattr_integration_test.go:303: xattr.list /var/folders/6x/tlqzyq0j38j9xw6qkl8p3jcm0000gq/T/gocryptfs-test-parent/016447944/default-plain/TestList0000File : permission denied
--- FAIL: TestList0000Dir (0.00s)
    xattr_integration_test.go:330: xattr.list /var/folders/6x/tlqzyq0j38j9xw6qkl8p3jcm0000gq/T/gocryptfs-test-parent/016447944/default-plain/TestList0000Dir : permission denied
--- FAIL: TestSet0200Dir (0.00s)
    xattr_integration_test.go:344: xattr.LSet /var/folders/6x/tlqzyq0j38j9xw6qkl8p3jcm0000gq/T/gocryptfs-test-parent/016447944/default-plain/TestSet0200Dir user.foo: permission denied
FAIL
FAIL    github.com/rfjakob/gocryptfs/tests/xattr    0.282s

On Linux we fixed these with the /proc/self/... trick, but this method doesn't work on macOS. However, there is one way how we could solve it (already mentioned in previous bug reports): Emulating it with Fchdir. The method would work like this:

Unfortunately, this means we have to add new emulation code involving the chdirMutex. However, with these fixes, both Linux and macOS would handle all xattr corner cases correctly. What do you think?

rfjakob commented 5 years ago

Sounds good, yes