Commit Graph

2064 Commits

Author SHA1 Message Date
NekoGirlSAIKOU 4808adc761 Add comment to pass Codacy Static Code Analysis 2022-08-28 11:09:06 +02:00
NekoGirlSAIKOU 1bff80b46c Fix invalid -longnamemax for reverse mode 2022-08-28 11:09:01 +02:00
Jakob Unterwurzacher bf29c9f99d tests: add TestLongnamemax100Reverse
Fails right now as reported in https://github.com/rfjakob/gocryptfs/pull/655

--- FAIL: TestLongnamemax100Reverse (0.09s)
    longnamemax_test.go:104: l=64: should see a longname now
    longnamemax_test.go:104: l=65: should see a longname now
    longnamemax_test.go:104: l=66: should see a longname now
    longnamemax_test.go:104: l=67: should see a longname now
    longnamemax_test.go:104: l=68: should see a longname now
    longnamemax_test.go:104: l=69: should see a longname now
    longnamemax_test.go:104: l=70: should see a longname now
    longnamemax_test.go:104: l=71: should see a longname now
    longnamemax_test.go:104: l=72: should see a longname now
    longnamemax_test.go:104: l=73: should see a longname now
    longnamemax_test.go:104: l=74: should see a longname now
    longnamemax_test.go:104: l=75: should see a longname now
    longnamemax_test.go:104: l=76: should see a longname now
    longnamemax_test.go:104: l=77: should see a longname now
    longnamemax_test.go:104: l=78: should see a longname now
    longnamemax_test.go:104: l=79: should see a longname now
    longnamemax_test.go:104: l=80: should see a longname now
    longnamemax_test.go:104: l=81: should see a longname now
    longnamemax_test.go:104: l=82: should see a longname now
    longnamemax_test.go:104: l=83: should see a longname now
    longnamemax_test.go:104: l=84: should see a longname now
    longnamemax_test.go:104: l=85: should see a longname now
    longnamemax_test.go:104: l=86: should see a longname now
    longnamemax_test.go:104: l=87: should see a longname now
    longnamemax_test.go:104: l=88: should see a longname now
    longnamemax_test.go:104: l=89: should see a longname now
    longnamemax_test.go:104: l=90: should see a longname now
    longnamemax_test.go:104: l=91: should see a longname now
    longnamemax_test.go:104: l=92: should see a longname now
    longnamemax_test.go:104: l=93: should see a longname now
    longnamemax_test.go:104: l=94: should see a longname now
    longnamemax_test.go:104: l=95: should see a longname now
    longnamemax_test.go:104: l=96: should see a longname now
    longnamemax_test.go:104: l=97: should see a longname now
    longnamemax_test.go:104: l=98: should see a longname now
    longnamemax_test.go:104: l=99: should see a longname now
    longnamemax_test.go:104: l=100: should see a longname now
    longnamemax_test.go:104: l=101: should see a longname now
    longnamemax_test.go:104: l=102: should see a longname now
    longnamemax_test.go:104: l=103: should see a longname now
    longnamemax_test.go:104: l=104: should see a longname now
    longnamemax_test.go:104: l=105: should see a longname now
    longnamemax_test.go:104: l=106: should see a longname now
    longnamemax_test.go:104: l=107: should see a longname now
    longnamemax_test.go:104: l=108: should see a longname now
    longnamemax_test.go:104: l=109: should see a longname now
    longnamemax_test.go:104: l=110: should see a longname now
    longnamemax_test.go:104: l=111: should see a longname now
    longnamemax_test.go:104: l=112: should see a longname now
    longnamemax_test.go:104: l=113: should see a longname now
    longnamemax_test.go:104: l=114: should see a longname now
    longnamemax_test.go:104: l=115: should see a longname now
    longnamemax_test.go:104: l=116: should see a longname now
    longnamemax_test.go:104: l=117: should see a longname now
    longnamemax_test.go:104: l=118: should see a longname now
    longnamemax_test.go:104: l=119: should see a longname now
    longnamemax_test.go:104: l=120: should see a longname now
    longnamemax_test.go:104: l=121: should see a longname now
    longnamemax_test.go:104: l=122: should see a longname now
    longnamemax_test.go:104: l=123: should see a longname now
    longnamemax_test.go:104: l=124: should see a longname now
    longnamemax_test.go:104: l=125: should see a longname now
    longnamemax_test.go:104: l=126: should see a longname now
    longnamemax_test.go:104: l=127: should see a longname now
    longnamemax_test.go:104: l=128: should see a longname now
    longnamemax_test.go:104: l=129: should see a longname now
    longnamemax_test.go:104: l=130: should see a longname now
    longnamemax_test.go:104: l=131: should see a longname now
    longnamemax_test.go:104: l=132: should see a longname now
    longnamemax_test.go:104: l=133: should see a longname now
    longnamemax_test.go:104: l=134: should see a longname now
    longnamemax_test.go:104: l=135: should see a longname now
    longnamemax_test.go:104: l=136: should see a longname now
    longnamemax_test.go:104: l=137: should see a longname now
    longnamemax_test.go:104: l=138: should see a longname now
    longnamemax_test.go:104: l=139: should see a longname now
    longnamemax_test.go:104: l=140: should see a longname now
    longnamemax_test.go:104: l=141: should see a longname now
    longnamemax_test.go:104: l=142: should see a longname now
    longnamemax_test.go:104: l=143: should see a longname now
    longnamemax_test.go:104: l=144: should see a longname now
    longnamemax_test.go:104: l=145: should see a longname now
    longnamemax_test.go:104: l=146: should see a longname now
    longnamemax_test.go:104: l=147: should see a longname now
    longnamemax_test.go:104: l=148: should see a longname now
    longnamemax_test.go:104: l=149: should see a longname now
    longnamemax_test.go:104: l=150: should see a longname now
    longnamemax_test.go:104: l=151: should see a longname now
    longnamemax_test.go:104: l=152: should see a longname now
    longnamemax_test.go:104: l=153: should see a longname now
    longnamemax_test.go:104: l=154: should see a longname now
    longnamemax_test.go:104: l=155: should see a longname now
    longnamemax_test.go:104: l=156: should see a longname now
    longnamemax_test.go:104: l=157: should see a longname now
    longnamemax_test.go:104: l=158: should see a longname now
    longnamemax_test.go:104: l=159: should see a longname now
    longnamemax_test.go:104: l=160: should see a longname now
    longnamemax_test.go:104: l=161: should see a longname now
    longnamemax_test.go:104: l=162: should see a longname now
    longnamemax_test.go:104: l=163: should see a longname now
    longnamemax_test.go:104: l=164: should see a longname now
    longnamemax_test.go:104: l=165: should see a longname now
    longnamemax_test.go:104: l=166: should see a longname now
    longnamemax_test.go:104: l=167: should see a longname now
    longnamemax_test.go:104: l=168: should see a longname now
    longnamemax_test.go:104: l=169: should see a longname now
    longnamemax_test.go:104: l=170: should see a longname now
    longnamemax_test.go:104: l=171: should see a longname now
    longnamemax_test.go:104: l=172: should see a longname now
    longnamemax_test.go:104: l=173: should see a longname now
    longnamemax_test.go:104: l=174: should see a longname now
    longnamemax_test.go:104: l=175: should see a longname now
FAIL

https://github.com/rfjakob/gocryptfs/pull/655
2022-08-28 11:07:35 +02:00
Jakob Unterwurzacher 5582d8370c ctlsock: raise timeout to 10 seconds
There was at least one user who hit the earlier 1 second timeout. Raise to 10
seconds which ought to be enough for anyone.

Fixes https://github.com/rfjakob/gocryptfs/issues/683
2022-08-22 14:00:36 +02:00
Abirdcfly 702a2e19cc fix minor unreachable code caused by t.Fatal
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2022-08-15 14:24:18 +02:00
Matéo Duparc e6e4c201db
Fix typo in README 2022-06-26 13:57:44 +02:00
Yuta Hayashibe e9ecff7f07 Fix typos 2022-06-26 10:59:06 +02:00
Matéo Duparc 7afeb9f3a4
Adapt to the new API 2022-06-23 17:01:11 +02:00
Matéo Duparc 9e98192442
Fix race condition when registering files 2022-04-22 12:07:12 +02:00
Matéo Duparc 985d852343
Thread safety 2022-04-20 21:30:46 +02:00
Matéo Duparc b2ddf58e89
Return an error if the volume is already closed 2022-04-19 21:00:30 +02:00
Matéo Duparc 71eb2bdf7c
Update FUSE related stuff according to gocryptfs fusefrontend 2022-04-19 19:49:09 +02:00
Val c9e4e4f741 Fix reverse gocryptfs.conf access on macOS
Unlike the FUSE implementation on Linux, macFUSE doesn't cache the file
attributes from the `LOOKUP` call, so it calls `GETATTR` prior to
accessing a file.

In the case of the `VirtualConfNode` (reverse config file passthrough),
this resulted in the default `GETATTR` implementation returning an empty
result, ultimately resulting in a "permission denied" error.

    14:44:14.095207 rx 3: GETATTR n2
    14:44:14.095229 tx 3:     OK, {tA=1s {M0100000 SZ=0 L=0 0:0 0 0:8954996 A 0.000000 M 0.000000 C 0.000000}}
    14:44:14.099943 rx 4: ACCESS n2 {u=501 g=20 r}
    14:44:14.099990 tx 4:     13=permission denied

By impementing `Getattr` (from `fs.NodeGetattrer`) on `VirtualConfNode`
this solves the issue.
2022-04-02 15:15:04 +02:00
Jakob Unterwurzacher ad2904f9ed MANPAGE: document that -scryptn also applies to -passwd
Closes https://github.com/rfjakob/gocryptfs/issues/646
2022-03-19 15:18:39 +01:00
Matéo Duparc 89966b1aae
Allow the password hash to be returned when creating a volume 2022-03-01 10:57:57 +01:00
Jakob Unterwurzacher a2b54cfccd root_test: fix leftover loop mount
After running "make root_test" a few times df would look like this,
no good:

$ df
Filesystem                  1K-blocks       Used Available Use% Mounted on
[...]
/dev/loop11                      8729       8525         0 100% /tmp/gocryptfs-test-parent-0/4081611019/TestDiskFull.ext4.mnt
/dev/loop12                      8729       8525         0 100% /tmp/gocryptfs-test-parent-0/1959939106/TestDiskFull.ext4.mnt
/dev/loop13                      8729       8525         0 100% /tmp/gocryptfs-test-parent-0/2455888382/TestDiskFull.ext4.mnt
/dev/loop14                      8729       8525         0 100% /tmp/gocryptfs-test-parent-0/2002998275/TestDiskFull.ext4.mnt
/dev/loop15                      8729       8525         0 100% /var/tmp/gocryptfs-test-parent-0/806736609/TestDiskFull.ext4.mnt
/dev/loop16                      8729       8525         0 100% /tmp/gocryptfs-test-parent-0/4050106930/TestDiskFull.ext4.mnt
/dev/loop17                      8729       8525         0 100% /tmp/gocryptfs-test-parent-0/1661931756/TestDiskFull.ext4.mnt
/dev/loop18                      8729       8525         0 100% /tmp/gocryptfs-test-parent-0/617990718/TestDiskFull.ext4.mnt
/dev/loop19                      8729       8525         0 100% /tmp/gocryptfs-test-parent-0/3194420338/TestDiskFull.ext4.mnt
/dev/loop20                      8729       8525         0 100% /tmp/gocryptfs-test-parent-0/2180745159/TestDiskFull.ext4.mnt

Turns out the unmount failed with EBUSY, so use lazy
unmount.
2022-01-27 18:36:51 +01:00
Jakob Unterwurzacher ba75aa1ab0 root_test: add TestOverlay ; syscallcompat: add QuirkNoUserXattr 2022-01-27 15:44:09 +01:00
Jakob Unterwurzacher b636f79f89 MANPAGE: add missing -acl section
Looks like 86d8336b43
forgot to add the option to the manpage.
2022-01-22 16:19:33 +01:00
Jakob Unterwurzacher 47358938ec tests: fix build failure on Go 1.15 and older
These don't have os.ReadDir yet.

Error was:

	Error: vet: tests/defaults/overlayfs_test.go:104:15: ReadDir not declared by package os
2022-01-22 16:07:59 +01:00
Jakob Unterwurzacher 696f11499b tests: add skipped O_TMPFILE test
Looks like the FUSE protocol does support O_TMPFILE yet.

https://github.com/rfjakob/gocryptfs/issues/641
2022-01-22 14:06:39 +01:00
Jakob Unterwurzacher b859bc96ef fusefrontend: fix "duplicate case" darwin build failure
$ ./crossbuild.bash
[...]
+ GOOS=darwin
+ GOARCH=amd64
+ build
+ go build -tags without_openssl -o /dev/null
internal/fusefrontend/node.go:397:2: duplicate case syscallcompat.RENAME_NOREPLACE (value 0) in switch
	previous case at internal/fusefrontend/node.go:397:7
internal/fusefrontend/node.go:397:2: duplicate case syscallcompat.RENAME_EXCHANGE (value 0) in switch
	previous case at internal/fusefrontend/node.go:397:7
internal/fusefrontend/node.go:397:2: duplicate case syscallcompat.RENAME_WHITEOUT (value 0) in switch
	previous case at internal/fusefrontend/node.go:397:7
internal/fusefrontend/node.go:399:38: duplicate case syscallcompat.RENAME_NOREPLACE | syscallcompat.RENAME_WHITEOUT (value 0) in switch
	previous case at internal/fusefrontend/node.go:397:7
2022-01-22 12:44:04 +01:00
Jakob Unterwurzacher 3bac814ea9 tests: add TestRenameWhiteout, TestRenameExchange
f
2022-01-22 12:42:57 +01:00
Jakob Unterwurzacher b7cac4ffd0 fusefrontend: support RENAME_WHITEOUT, RENAME_EXCHANGE
Both new internal test and xfstests generic/013 are happy.

https://github.com/rfjakob/gocryptfs/issues/641
2022-01-22 12:28:27 +01:00
Jakob Unterwurzacher 3ca2b1983d tests: enable -fusedebug if FUSEDEBUG env is set 2022-01-22 11:46:08 +01:00
Matéo Duparc 1da2407a61
Better build script 2022-01-20 10:19:20 +01:00
Jakob Unterwurzacher 5f955423b7 fusefrontend: fix -force_owner not affecting MKNOD
Fixes https://github.com/rfjakob/gocryptfs/issues/629
2022-01-10 20:05:36 +01:00
Jakob Unterwurzacher c23a7f2259 test.bash: disable parallelism in verbose mode
This way we get live output, and hopefully see clearer
where things hang if they do.

Also, don't pass on flags to "go vet", the verbose output
is pretty useless.

https://github.com/rfjakob/gocryptfs/issues/625
2022-01-04 15:25:26 +01:00
Jakob Unterwurzacher 700ae685cc tests: improve SEEK_DATA test for MacOS
(1)

Create a 1 GiB file instead of 1 TiB, because
apparently, on MacOS, the file (sometimes?) is not
created sparse, and fills up users' disks:

https://github.com/rfjakob/gocryptfs/issues/625

(2)

On darwin, SEEK_DATA is not the same as on Linux
( 2f8b555de2 )
so use the value provided by the unix package.
2022-01-04 15:21:20 +01:00
Jakob Unterwurzacher 4b251f3ce1 readpassword: bubble up errors instead of exiting the process
This allows cleanups to happen in the caller, like removing
the control socket.

Fixes https://github.com/rfjakob/gocryptfs/issues/634
2022-01-03 15:18:59 +01:00
Jakob Unterwurzacher 1eaf1211a2 tests/cli: Check for leftover socket file
This fails at the moment:

$ go test ./tests/cli/
--- FAIL: TestMountPasswordEmpty (0.01s)
    cli_test.go:430: socket file "/tmp/gocryptfs-test-parent-1026/3413782690/TestMountPasswordEmpty.753166857.sock" left behind

https://github.com/rfjakob/gocryptfs/issues/634
2022-01-03 14:27:52 +01:00
Matéo Duparc b232bb7826
Deep copy path when registering file handle 2021-12-20 13:49:42 +01:00
Jakob Unterwurzacher 5749e70c7c nametransform: fix oversight in comment 2021-12-19 14:50:52 +01:00
Jakob Unterwurzacher 8d8b76dcac go.mod: upgrade go-fuse
We want
https://github.com/hanwen/go-fuse/commit/934a183ed91446d218b5471c4df9f93db039f6e
"fuse: prefer fusermount3 over fusermount; add debug output"

Fixes https://github.com/rfjakob/gocryptfs/issues/626
2021-12-19 14:46:43 +01:00
Jakob Unterwurzacher 64be5de75f fusefrontend: allow slashes in xattr names
xattr names have fewer restrictions than file names,
relax the validation.

Fixes https://github.com/rfjakob/gocryptfs/issues/627
2021-12-19 14:43:56 +01:00
Matéo Duparc d6e75be376
Use renameat instead of renameat2 2021-12-18 14:52:00 +01:00
Matéo Duparc f86a1aa6a8
libgocryptfs: update to gocryptfs v2.2.1 2021-12-18 14:33:17 +01:00
Jakob Unterwurzacher eb42e54182 tlog: only enable color if both stderr and stdout are a terminal
This

    gocryptfs -init /does/not/exist 2> err.log

used to write escape codes into err.log. Stop doing that.
2021-12-11 15:37:13 +01:00
Jakob Unterwurzacher a1f01419e2 tlog: respect NO_COLOR
Fixes https://github.com/rfjakob/gocryptfs/issues/617
2021-12-11 15:35:01 +01:00
Jakob Unterwurzacher bd1ecf5379 darwin: use O_NOFOLLOW for xattr opens
Running the tests we have lots of these:

Openat: O_NOFOLLOW missing: flags = 0x4
-wpanic turns this warning into a panic: Openat: O_NOFOLLOW missing: flags = 0x4
panic: -wpanic turns this warning into a panic: Openat: O_NOFOLLOW missing: flags = 0x4

goroutine 114 [running]:
log.(*Logger).Panic(0x14000118280, {0x14000313ca8, 0x1, 0x1})
	log/log.go:224 +0x90
github.com/rfjakob/gocryptfs/v2/internal/tlog.(*toggledLogger).Printf(0x14000076780, {0x1009dc2e8, 0x27}, {0x14000313d18, 0x1, 0x1})
	github.com/rfjakob/gocryptfs/v2/internal/tlog/log.go:78 +0x168
github.com/rfjakob/gocryptfs/v2/internal/syscallcompat.Openat(0x9, {0x1009d0747, 0x1}, 0x4, 0x0)
	github.com/rfjakob/gocryptfs/v2/internal/syscallcompat/sys_common.go:59 +0xf0
github.com/rfjakob/gocryptfs/v2/internal/fusefrontend.(*Node).getXAttr(0x14000142000, {0x1400001c140, 0x3a})
	github.com/rfjakob/gocryptfs/v2/internal/fusefrontend/node_xattr_darwin.go:30 +0x8c
github.com/rfjakob/gocryptfs/v2/internal/fusefrontend.(*Node).Getxattr(0x14000142000, {0x100a7eba0, 0x1400000c2e8}, {0x14000016348, 0x14}, {0x14000326000, 0x20, 0x4000})
	github.com/rfjakob/gocryptfs/v2/internal/fusefrontend/node_xattr.go:65 +0x1ac
github.com/hanwen/go-fuse/v2/fs.(*rawBridge).GetXAttr(0x1400008e140, 0x140001901e0, 0x140001133c0, {0x14000016348, 0x14}, {0x14000326000, 0x20, 0x4000})
	github.com/hanwen/go-fuse/v2@v2.1.1-0.20210825171523-3ab5d95a30ae/fs/bridge.go:685 +0x114
github.com/hanwen/go-fuse/v2/fuse.doGetXAttr(0x14000144000, 0x14000113200)
	github.com/hanwen/go-fuse/v2@v2.1.1-0.20210825171523-3ab5d95a30ae/fuse/opcode.go:270 +0x224
github.com/hanwen/go-fuse/v2/fuse.(*Server).handleRequest(0x14000144000, 0x14000113200)
	github.com/hanwen/go-fuse/v2@v2.1.1-0.20210825171523-3ab5d95a30ae/fuse/server.go:499 +0x214
created by github.com/hanwen/go-fuse/v2/fuse.(*Server).loop
	github.com/hanwen/go-fuse/v2@v2.1.1-0.20210825171523-3ab5d95a30ae/fuse/server.go:470 +0xac

https://github.com/rfjakob/gocryptfs/issues/625
2021-12-09 17:55:05 +01:00
Jakob Unterwurzacher a48d6c3041 test.bash, crossbuild: catch MacOS test build failures
Regression test for https://github.com/rfjakob/gocryptfs/issues/623

Fixes https://github.com/rfjakob/gocryptfs/issues/623
2021-12-08 18:53:15 +01:00
Jakob Unterwurzacher ec186c13ce root_test, getdents-debug: restrict to linux
This does not work neither make sense on MacOS.
2021-12-08 18:50:42 +01:00
Jakob Unterwurzacher 7d60315cd5 tests: convert Creat() calls to Open()
Creat() is equivalent to Open(..., O_CREAT|O_WRONLY|O_TRUNC, ...)
and MacOS does not have syscall.Creat().

https://github.com/rfjakob/gocryptfs/issues/623
2021-12-08 18:49:21 +01:00
Jakob Unterwurzacher de22cb1e5d crossbuild.bash: use shell function instead of variable
This will allow easy expansion of build steps.
2021-12-08 12:45:23 +01:00
Jakob Unterwurzacher 39e736c099 MANPAGE: fix typo 2021-12-04 12:37:12 +01:00
Jakob Unterwurzacher 8722b894a6 MANPAGE: -extpass: document dash duplication bug
Closes https://github.com/rfjakob/gocryptfs/issues/621
2021-12-04 12:34:29 +01:00
Jakob Unterwurzacher d530fbd400 docs: names longer than 175 bytes (not 176) are stored in longnames
Quoting fusefrontend_reverse/node_helpers.go :

	// File names are padded to 16-byte multiples, encrypted and
	// base64-encoded. We can encode at most 176 bytes to stay below the 255
	// bytes limit:
	// * base64(176 bytes) = 235 bytes
	// * base64(192 bytes) = 256 bytes (over 255!)
	// But the PKCS#7 padding is at least one byte. This means we can only use
	// 175 bytes for the file name.

Noticed by @bailey27 at https://github.com/rfjakob/gocryptfs/issues/499#issuecomment-955790427
2021-11-01 14:44:32 +01:00
Matéo Duparc 1973153602
Switch to v2 module 2021-10-24 10:48:44 +02:00
Jakob Unterwurzacher 87a6bb370a nametransform: fix math.MaxInt build failure on older Go
Failure is:

  # github.com/rfjakob/gocryptfs/v2/internal/nametransform
  internal/nametransform/names.go:47:33: undefined: math.MaxInt

math.MaxInt was only introduced in Go 1.17. Use MaxInt32 instead,
which is good enough, even on amd64. It only has to be larger than
any name we might encounter.
2021-10-21 16:44:05 +02:00
Jakob Unterwurzacher d14c9340d6 cli: add -longnamemax
Fixes https://github.com/rfjakob/gocryptfs/issues/499
2021-10-21 15:58:19 +02:00
Jakob Unterwurzacher d583bdb79e configfile: add LongNameMax support
Feature flag + numeric paramater

https://github.com/rfjakob/gocryptfs/issues/499
2021-10-21 14:55:30 +02:00