summaryrefslogtreecommitdiff
path: root/internal/syscallcompat
AgeCommit message (Collapse)Author
2020-10-14syscallcompat: don't retry Close()Jakob Unterwurzacher
After Close() returns, the fd is dead, even if we received EINTR. Don't retry, we could shoot down an unrelated fd that received the same fd number.
2020-10-14syscallcompat: retry ops on EINTRJakob Unterwurzacher
Retry operations that have been shown to throw EINTR errors on CIFS. Todo: Solution for this pain in the back: warning: unix.Getdents returned errno 2 in the middle of data rm: cannot remove 'linux-3.0.old3/Documentation/ABI/removed': Input/output error Progress towards fixing https://github.com/rfjakob/gocryptfs/issues/483 .
2020-10-11syscallcompat: Openat: retry on EINTRJakob Unterwurzacher
Towards fixing https://github.com/rfjakob/gocryptfs/issues/507
2020-09-09syscallcompat: add Renameat2 for DarwinJakob Unterwurzacher
2020-07-11v2api: remove OpenatUserCtx, MknodatUserCtx helpersJakob Unterwurzacher
Instead, use the new toFuseCtx() function introduced in an earlier commit.
2020-07-11v2api: implement MknodJakob Unterwurzacher
2020-06-21v2api: implement MkdirJakob Unterwurzacher
2020-06-21v2api: implement CreateJakob Unterwurzacher
2020-06-21v2api: implement Lookup()Jakob Unterwurzacher
Compiles, but untested otherwise. No caching.
2020-05-24syscallcompat: warn when Getdents truncates dataJakob Unterwurzacher
On CIFS mounts, unix.Getdents can return sudden ENOENT in the middle of data. This will not be reported as an error by user space tools, so return EIO instead. Also log it as a warning. https://github.com/rfjakob/gocryptfs/issues/483
2020-05-23syscallcompat: getdents: retry on EINTRJakob Unterwurzacher
Fixes: https://github.com/rfjakob/gocryptfs/issues/483 Related: https://github.com/golang/go/issues/38836
2020-05-17Update go-fuse import path to github.com/hanwen/go-fuse/v2Jakob Unterwurzacher
We need https://github.com/hanwen/go-fuse/commit/fd7328faf9fdf75709f7ba7df7072aaf4eeb18b3 to fix a crash reported in https://github.com/rfjakob/gocryptfs/issues/430 : 2019/10/30 17:14:16 Unknown opcode 2016 panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x508d38] This patch is only in the v2.x.x branch. Upgrade to v2, as the old API is also supported there. Running git grep hanwen/go-fuse | grep -v hanwen/go-fuse/v2 to check for forgotten references comes back clean.
2019-05-19Fix unix2syscall_darwin.go build failureJakob Unterwurzacher
Error was +GOOS=darwin +GOARCH=amd64 +go build -tags without_openssl # github.com/rfjakob/gocryptfs/internal/syscallcompat internal/syscallcompat/unix2syscall_darwin.go:22:32: u.Atimespec undefined (type unix.Stat_t has no field or method Atimespec) internal/syscallcompat/unix2syscall_darwin.go:23:32: u.Mtimespec undefined (type unix.Stat_t has no field or method Mtimespec) internal/syscallcompat/unix2syscall_darwin.go:24:32: u.Ctimespec undefined (type unix.Stat_t has no field or method Ctimespec) caused by https://github.com/golang/sys/commit/87c872767d25fb96dfe96c794fd028b38a08440b#diff-4913a9178621eadcdf191db17915fbcb
2019-05-01syscallcompat: fetch supplementary groups for OpenatUser & friendsSebastian Lackner
Handled the same way in GlusterFS, disorderfs, libfuse. Fixes https://github.com/rfjakob/gocryptfs/issues/394
2019-05-01tests: split testParentDir by UIDJakob Unterwurzacher
When we run tests as root, they will leave root-owned files in testParentDir, which causes trouble when we run tests as a normal user later on. Split by UID.
2019-01-20Revert "syscallcompat: drop Faccessat AT_SYMLINK_NOFOLLOW helper"Jakob Unterwurzacher
Breaks mounting on MacOS: unix.Faccessat on Darwin does NOT (yet) support AT_SYMLINK_NOFOLLOW. See d44fe89ba4f3252c5bd00c4f7730197732f2a26a . This reverts commit 0805a63df1b5f915b228727f6074c2506922d0ad.
2019-01-20syscallcompat: drop Faccessat AT_SYMLINK_NOFOLLOW helperJakob Unterwurzacher
unix.Faccessat has added support for AT_SYMLINK_NOFOLLOW in July 2018, https://github.com/golang/sys/commit/bd9dbc187b6e1dacfdd2722a87e83093c2d7bd6e#diff-341484dbbe3180cd7a31ef2ad2d679b6 which means we no longer need our own helper. Closes https://github.com/rfjakob/gocryptfs/issues/347
2019-01-16fusefrontend: Rework the Utimens handling on macOS.Sebastian Lackner
For Linux, everything effectively stays the same. For both path-based and fd-based Utimens() calls, we use unix.UtimesNanoAt(). To avoid introducing a separate syscall wrapper for futimens() (as done in go-fuse, for example), we instead use the /proc/self/fd - trick. On macOS, this changes quite a lot: * Path-based Utimens() calls were previously completely broken, since unix.UtimensNanoAt() ignores the passed file descriptor. Note that this cannot be fixed easily since there IS no appropriate syscall available on macOS prior to High Sierra (10.13). We emulate this case by using Fchdir() + setattrlist(). * Fd-based Utimens() calls were previously translated to f.GetAttr() (to fill any empty parameters) and syscall.Futimes(), which does not does support nanosecond precision. Both issues can be fixed by switching to fsetattrlist(). Fixes https://github.com/rfjakob/gocryptfs/issues/350
2019-01-14tests: reduce noise on MacOSJakob Unterwurzacher
This should get rid of Openat: O_NOFOLLOW missing: flags = 0x0 Fchmodat: adding missing AT_SYMLINK_NOFOLLOW flag sys_common_test.go:203: chmod on symlink should have failed, but did not. New mode=0333 UnmountErr: "[...]/057376762.mnt" was not found in MountInfo, cannot check for FD leak and add some context to --- FAIL: TestUtimesNano (0.00s) matrix_test.go:628: no such file or directory See https://github.com/rfjakob/gocryptfs/pull/343#issuecomment-453888006 for full test output
2019-01-14syscallcompat: fix FchmodatNofollow testsJakob Unterwurzacher
FchmodatNofollow dropped the flags parameter.
2019-01-14syscallcompat: rework Fchmodat to FchmodatNofollowJakob Unterwurzacher
We never want Fchmodat to follow symlinks, so follow what Qemu does, and call our function FchmodatNofollow.
2019-01-14syscallcompat: Drop Fstatat emulation on macOS.Sebastian Lackner
2019-01-14syscallcompat: Drop Mkdirat emulation on macOS.Sebastian Lackner
2019-01-14syscallcompat: Drop Symlinkat emulation on macOS.Sebastian Lackner
2019-01-14syscallcompat: Drop Fchownat emulation on macOS.Sebastian Lackner
2019-01-14syscallcompat: Drop Fchmodat emulation on macOS.Sebastian Lackner
On macOS the function has a flags argument, so we don't need the /proc/self/fd trick used on Linux.
2019-01-14syscallcompat: Drop Unlinkat emulation on macOS.Sebastian Lackner
2019-01-14syscallcompat: Drop Renameat emulation on macOS.Sebastian Lackner
2019-01-14syscallcompat: Drop Openat emulation on macOS.Sebastian Lackner
2019-01-14syscallcompat: Use pthread_setugid_np() to implement *User() functions on macOS.Sebastian Lackner
Fixes -allow_other mode on macOS.
2019-01-13macos: filter SUID and SGID bits in OpenatUser, MknodatUser, MkdiratUserJakob Unterwurzacher
When gocryptfs runs as root, we don't want to allow people to create SUID root files.
2019-01-12fusefrontend: -allow_other: Use SymlinkatUser in Symlink FUSE call.Sebastian Lackner
Instead of manually adjusting the user after creating the symlink, adjust effective permissions and let the kernel deal with it. Related to https://github.com/rfjakob/gocryptfs/issues/338.
2019-01-12fusefrontend: -allow_other: Use MknodatUser in Mknod FUSE call.Sebastian Lackner
Instead of manually adjusting the user and mode after creating the device file, adjust effective permissions and let the kernel deal with it. Related to https://github.com/rfjakob/gocryptfs/issues/338.
2019-01-12fusefrontend: -allow_other: Use MkdiratUser in Mkdir FUSE call.Sebastian Lackner
Revert commit fcaca5fc94d981aa637beb752edc8cb3c2265e96. Instead of manually adjusting the user and mode after creating the directory, adjust effective permissions and let the kernel deal with it. Related to https://github.com/rfjakob/gocryptfs/issues/338.
2019-01-12fusefrontend: -allow_other: Use OpenatUser in Create FUSE call.Sebastian Lackner
Revert commit b22cc03c7516b2003880db8375d26c76d6dff093. Instead of manually adjusting the user and mode after creating the file, adjust effective permissions and let the kernel deal with it. Related to https://github.com/rfjakob/gocryptfs/issues/338.
2019-01-07syscallcompat: Implement workaround for Fchmodat with AT_SYMLINK_NOFOLLOW.Sebastian Lackner
Fixes https://github.com/rfjakob/gocryptfs/issues/259
2019-01-07tests: add Fchmodat testJakob Unterwurzacher
Test that we handle symlinks correctly.
2019-01-05fusefrontend: Allow to set/remove xattr on directory without read permission.Sebastian Lackner
Setting/removing extended attributes on directories was partially fixed with commit eff35e60b63331e3e10f921792baa10b236a721d. However, on most file systems it is also possible to do these operations without read access (see tests). Since we cannot open a write-access fd to a directory, we have to use the /proc/self/fd trick (already used for ListXAttr) for the other operations aswell. For simplicity, let's separate the Linux and Darwin code again (basically revert commit f320b76fd189a363a34bffe981aa67ab97df3362), and always use the /proc/self/fd trick on Linux. On Darwin we use the best-effort approach with openBackingFile() as a fallback. More discussion about the available options is available in https://github.com/rfjakob/gocryptfs/issues/308.
2019-01-03syscallcompat: Use O_PATH to open base directory.Sebastian Lackner
Also remove some unnecessary flags: When O_PATH is specified in flags, flag bits other than O_CLOEXEC, O_DIRECTORY, and O_NOFOLLOW are ignored.
2019-01-03fusefrontend: add dirCacheJakob Unterwurzacher
2019-01-02fusefrontend: xattr: fix operations on files without read permissionsJakob Unterwurzacher
* 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
2019-01-02syscallcompat: add Fgetxattr / Fsetxattr wrappersJakob Unterwurzacher
These take care of buffer sizing and parsing.
2019-01-01fusefrontend: make Readlink() symlink-safeJakob Unterwurzacher
Now symlink-safe through Readlinkat().
2018-11-17syscallcompat: downgrade DT_UNKNOWN message level on XFSJakob Unterwurzacher
Old XFS filesystems always return DT_UNKNOWN. Downgrade the message to "info" level if we are on XFS. Using the "warning" level means that users on old XFS filesystems cannot run the test suite as it intentionally aborts on any warnings. Fixes https://github.com/rfjakob/gocryptfs/issues/267
2018-10-11tests: syscallcompat: allow failure for symlinks > 1000Jakob Unterwurzacher
MacOS and old XFS versions do not support very long symlinks, but let's not make the tests fail because of that. https://github.com/rfjakob/gocryptfs/issues/267
2018-09-22syscallcompat: untangle Openat flag checkJakob Unterwurzacher
Check for O_NWFOLLOW and O_EXCL separately to make the logic clearer.
2018-09-08syscallcompat: use O_PATH in OpenDirNofollowJakob Unterwurzacher
This fixes the "0100 directory" problem in reverse mode, and should be slightly faster.
2018-09-08syscallcompat: untangle OpenNofollow and rename to OpenDirNofollowJakob Unterwurzacher
The function used to do two things: 1) Walk the directory tree in a manner safe from symlink attacks 2) Open the final component in the mode requested by the caller This change drops (2), which was only used once, and lets the caller handle it. This simplifies the function and makes it fit for reuse in forward mode in openBackingPath(), and for using O_PATH on Linux.
2018-08-26syscallcompat: drop Fchmodat flagsv1.6.1Jakob Unterwurzacher
These were silently ignored until now (!) but are rejected by Go 1.11 stdlib. Drop the flags so the tests work again, until we figure out a better solution. https://github.com/golang/go/issues/20130
2018-07-15fusefrontend: doWrite: delete file header if first write failsJakob Unterwurzacher
xfstests generic/083 fills the filesystem almost completely while running fsstress in parallel. In fsck, these would show up: readFileID 2580: incomplete file, got 18 instead of 19 bytes This could happen when writing the file header works, but writing the actual data fails. Now we kill the header again by truncating the file to zero.