| Age | Commit message (Collapse) | Author |
|
.gocryptfs.reverse.conf is passed through to gocryptfs.conf in the
reverse view unencrypted. lookupConf, VirtualConfNode.Getattr and
VirtualConfNode.Open accessed it via syscall.Stat/Open on the full path,
following symlinks. Anybody with write access to the backing directory
could replace it with a symlink to, for example, /etc/shadow and read the
target in plaintext through the mount when gocryptfs runs as root.
Add RootNode.openConf(), which opens the file relative to the backing
dir with O_NOFOLLOW|O_NONBLOCK (O_NONBLOCK so a FIFO cannot hang us) and
rejects anything that is not a regular file. Use it for all three.
Add TestConfigSymlink as a regression test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
openWriteOnlyFile chmods the file via woFd and then reopens it by name.
O_NOFOLLOW prevents following symlinks, but cName could still have been
replaced by a different regular file in between, and we would return an
fd to that file.
Add syscallcompat.ReopenFd():
* Linux: open /proc/self/fd/N, which always resolves to the file woFd
refers to.
* Other platforms: reopen by name and compare dev/ino against woFd,
returning EAGAIN on mismatch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
FchmodatNofollow called syscall.Openat directly, so the O_PATH fd lacked
O_CLOEXEC and could leak to child processes (logger(1)), which is exactly
what our Openat() wrapper prevents. Use the wrapper, which also retries
on EINTR.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
AT_SYMLINK_NOFOLLOW
Our helper did Fstatat(AT_SYMLINK_NOFOLLOW) followed by a symlink-following
unix.Faccessat(..., 0). If the file is swapped for a symlink in between, we
check access on the symlink target.
x/sys now handles AT_SYMLINK_NOFOLLOW on all our platforms: faccessat2 with
fallback emulation on Linux, libc faccessat on Darwin, and the native
syscall on FreeBSD. The Darwin breakage that caused the revert in
3d6b2685 should no longer apply.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
Fixes #1023
|
|
There is a performance penalty here, but the alternative is
potential data loss on a system crash / power outage as shown in
https://github.com/rfjakob/gocryptfs/issues/1033 .
Also deduplicate the code a little using goto.
Fixes https://github.com/rfjakob/gocryptfs/issues/1033
|
|
Before:
$ mkdir asd
mkdir: cannot create directory ‘asd’: Operation not supported
Sep 01 22:24:15 brikett gocryptfs[185344]: go-fuse: can't convert error type: wanted 16 bytes, got 0
After:
$ mkdir asdasd
mkdir: cannot create directory ‘asdasd’: Input/output error
Sep 01 22:25:00 brikett gocryptfs[185784]: prepareAtSyscall: could not read gocryptfs.diriv: wanted 16 bytes, got 0
https://github.com/rfjakob/gocryptfs/issues/1033
|
|
We should never call it in -plaintextnames mode.
|
|
node.Setattr opens its own file handle and called truncate directly,
without ContentLock. truncate ends in doWrite, which documents that the
caller holds that lock, and file.Setattr and Allocate both take it.
Besides leaving a path truncate unserialized against concurrent writes,
this skipped the write-operation counter that ContentLock.Lock()
increments. isConsecutiveWrite() reads that counter to notice foreign
modifications, so an already-open handle kept assuming its next write
appends, skipped writePadHole() and grew the file past a short last
block. That block no longer decrypted, and every later operation on the
file failed with EIO.
Fixes #1024
|
|
Forward the backing filesystem's STATX_BTIME on Linux while preserving
existing metadata translations and fallback behavior.
On Linux 6.6 and newer, this allows statx consumers such as GNU stat
to report birth time when the backing filesystem provides it. Older
kernels and backing filesystems without birth-time support retain the
existing behavior. No on-disk format change or migration is required.
Reverse mode remains unchanged.
Fixes #868.
Related context: #732
|
|
|
|
|
|
|
|
...and one typo.
|
|
|
|
|
|
|
|
Prevent reads and writes concurrent with the truncate operation. It's
racy on tmpfs and ext4 ( https://lore.kernel.org/all/18e9fa0f-ec31-9107-459c-ae1694503f87@gmail.com/t/ )
as evident by TestOpenTruncate test failures:
=== RUN TestOpenTruncate
cluster_test.go:209: POSIX compliance issue: non-exlusive create failed with err=file exists
doRead 16384215: corrupt block #0: cipher: message authentication failed
ino16384215 fh8: RMW read failed: errno=5
cluster_test.go:214: iteration 1: WriteAt: write /tmp/gocryptfs-test-parent-1026/1358464214/TestOpenTruncate.1788296708.mnt2/foo: input/output error
--- FAIL: TestOpenTruncate (0.06s)
FAIL
exit status 1
FAIL github.com/rfjakob/gocryptfs/v2/tests/cluster 7.880s
Relates-to: https://github.com/rfjakob/gocryptfs/issues/56
|
|
Complain loudly when the underlying storage does not support
byte-range locks.
https://github.com/rfjakob/gocryptfs/issues/754
|
|
With -sharedstorage, when we get a decryption error, we lock the
byte range and try again.
This makes concurrent R/W safe agains torn writes.
https://github.com/rfjakob/gocryptfs/issues/754
|
|
As we must write complete ciphertext blocks (except at EOF), non-overlapping
plaintext writes can overlap in the ciphertext.
And because overlapping writes can turn the data into data soup (see
TestPoCTornWrite) we serialize them using fcntl locking.
|
|
With -sharedstorage, we keep the on-disk file header.
Other mounts may have the file ID cached so we cannot mess with it.
This makes TestOpenTruncate pass.
|
|
Multiple host writing to the same empty file at the same time
could have overwritten each other's newly created file header,
leading to data corruption.
Fix the race by placing a byte-range lock on the file when
creating the file header.
|
|
In reverse mode, a custom config file passed via -config that lives inside
CIPHERDIR was presented as an ordinary encrypted file in the encrypted view,
which is useless and confusing. By default the config is mapped to a virtual
gocryptfs.conf, but ConfigCustom skips that mapping, so an in-CIPHERDIR custom
config was neither mapped nor hidden.
Plumb the config path into the reverse RootNode and treat a custom config file
located inside CIPHERDIR as excluded in isExcludedPlain, hiding it from both
readdir and lookup. Also document the -config reverse-mode behaviour in
MANPAGE.md and add a regression test.
Fixes #1009
|
|
use maps and slices instead of explicit for loop
|
|
|
|
Freebsd-support: Change bash shebang to use /usr/bin/env
Freebsd-support: Fix go vet "undefined" fixes when running make ci
freebsd: stub xattr functions
/proc/PID/fd does not exist on freebsd.
freebsd-support: modify FchmodatNofollow for FreeBSD
FreeBSD supports the Fchmodat system call, with the AT_SYMLINK_NOFOLLOW
flag. FchmodatNofollow has been modified to use this system call and
flag.
freebsd-support: PR changes and fixes
* Functions in fusefrontend_reverse/node_xattr_freebsd.go have been
stubbed for now.
* asuser_freebsd.go updated to only run f() when context is nil;
otherwise log a warning and return an error.
* emulate.go build flags updated, and FreeBSD specific version added.
* sys_freebsd.go bug in Renameat2 with RENAME_EXCHANGE flag fixed.
FreeBSD does not support atomic file swapping, so this flag now
returns an error.
* unix2syscall and atime is identical between FreeBSD and Darwin,
updated filenames so Go will build the file for FreeBSD and Mac OS.
freebsd-support: Addressed more PR comments and fixed build tags
|
|
This fixes #686. Now the `gocryptfs.longname.*.name` are present and readable in the
reverse mount, regardless of the complexity of the exclusion patterns.
The main issue was a `cPath` instead of `dPath` for the exclude check in
`fusefrontend_reverse/node_helpers.go`. Also added a check to avoid the exclusion of
`gocryptfs.conf` in the root directory.
The test run results are in line with the main branch.
Fixes https://github.com/rfjakob/gocryptfs/issues/686
|
|
|
|
Fixes: ab4c0446d3db0665fc2e9a05c0319541d21811eb
|
|
|
|
No need to attach it to the root node. Also rename it
to mangleOpenCreateFlags.
|
|
Also add tests that opening a symlink (using unix.O_PATH | unix.O_NOFOLLOW)
works.
https://github.com/rfjakob/gocryptfs/issues/993
|
|
With O_NOFOLLOW we error out with ELOOP when the user tries
to manipulate symlinks.
https://github.com/rfjakob/gocryptfs/issues/993
|
|
|
|
Error: internal/syscallcompat/quirks_darwin.go:36:3: undefined: logQuirk
|
|
been passed
Reported by @Tunoac, https://github.com/rfjakob/gocryptfs/issues/395#issuecomment-3828507487
|
|
Summary: Store as NFC, read as NFD.
This commit resolves https://github.com/rfjakob/gocryptfs/issues/850
by addressing Unicode normalization mismatches on macOS between NFC
(used by CLI tools) and NFD (used by GUI apps). The solution is inspired
by Cryptomator's approach ( https://github.com/cryptomator/cryptomator/issues/264 ).
Forward mode on MacOS now enforces NFC for storage but presents NFD
as recommended by https://developer.apple.com/library/archive/qa/qa1173/_index.html
and https://github.com/macfuse/macfuse/wiki/File-Names-(Unicode-Normalization-Forms) .
See https://github.com/rfjakob/gocryptfs/pull/949 for more info.
This commit does nothing for reverse mode as it is not clear if
anything can be done. Reverse mode can not influence how the
file names are stored, hence mapping normalized names back to
what is actually on disk seems difficult.
|
|
* added -noxattr flag which ignores all xattr operations
|
|
Use hkdf from stable api instead of eXperimental
|
|
$ go version
go version go1.25.4 linux/amd64
$ go vet ./...
./init_dir.go:71:21: non-constant format string in call to (*github.com/rfjakob/gocryptfs/v2/internal/tlog.toggledLogger).Printf
./main.go:123:19: non-constant format string in call to (*github.com/rfjakob/gocryptfs/v2/internal/tlog.toggledLogger).Printf
./masterkey.go:29:20: non-constant format string in call to (*github.com/rfjakob/gocryptfs/v2/internal/tlog.toggledLogger).Printf
./masterkey.go:56:20: non-constant format string in call to (*github.com/rfjakob/gocryptfs/v2/internal/tlog.toggledLogger).Printf
./mount.go:415:20: non-constant format string in call to (*github.com/rfjakob/gocryptfs/v2/internal/tlog.toggledLogger).Printf
internal/tlog/log.go:76:18: non-constant format string in call to (*log.Logger).Printf
internal/syscallcompat/quirks.go:19:19: non-constant format string in call to (*github.com/rfjakob/gocryptfs/v2/internal/tlog.toggledLogger).Printf
|
|
tmpfs supports user xattrs since Linux 6.6 (anno 2023):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2daf18a7884dc03d5164ab9c7dc3f2ea70638469
|
|
Fixes https://github.com/rfjakob/gocryptfs/issues/827
|
|
Fixes https://github.com/rfjakob/gocryptfs/issues/964
|
|
Fix macos file saving problem by implementing RENAME_EXCHANGE flag.
With test.
The dummy value for RENAME_WHITEOUT collides with the new
flags. Move it wayyy up.
https://github.com/rfjakob/gocryptfs/issues/914
|
|
This makes building with just CGO_ENABLED=0 work.
|
|
|
|
Fixes https://github.com/rfjakob/gocryptfs/issues/951
|
|
|
|
|