Commit Graph

308 Commits

Author SHA1 Message Date
Jakob Unterwurzacher
3b61244b72 tests: TestBadname: simplify test by using empty files
Simplify the tests by using empty files. Empty
files are valid, and we don't check the content
anyway.

Also adjust comment style a little and add
a missing break statement.
2020-06-06 12:53:45 +02:00
DerDonut
a8230d271f Added auto decryption of invalid file names
Changed invalid file decoding and decryption. Function
DecryptName now shortens the filename until the filename is
decodable and decryptable. Will work with valid **and**
invalid Base64URL delimiter (valid delimiter [0-9a-zA-z_\\-].
If the filename is not decryptable at all, it returns the
original cipher name with flag suffix Changed cli tests to
generate decryptable and undecryptable file names with correct
encrypted content. Replacing #474, extends #393
2020-06-06 12:20:31 +02:00
Jakob Unterwurzacher
a56e7cc5ac sshfs-benchmark.bash: fix locale trouble and move to tests
Locale trouble was

   sshfs-benchmark.bash: line 31: printf: 4.71: invalid number

because printf expected "4,71" in the German locale.
Force the C locale.
2020-06-06 12:15:41 +02:00
Jakob Unterwurzacher
f8ad2ac3e2 dircache: increase cache size & lifetime
Looking at the dircache debug output, we see
that a "git status" workload has a very bad
cache hit rate because the entries expire or
get evicted before they can be reused.

Increase both cache size and lifetime for
a 4x speedup:

Before: 75s
After:  17s

https://github.com/rfjakob/gocryptfs/issues/410
2020-05-17 21:37:36 +02:00
Jakob Unterwurzacher
416080203b main: accept multiple -passfile options
Each file will be read and then concatenated
for the effictive password. This can be used as a
kind of multi-factor authenticiton.

Fixes https://github.com/rfjakob/gocryptfs/issues/288
2020-05-17 19:31:04 +02:00
Jakob Unterwurzacher
ead7008a08 Fix spelling mistakes found by misspell
https://github.com/client9/misspell
2020-05-10 00:25:49 +02:00
Jakob Unterwurzacher
a9895b3487 gocryptfs-xray: add -0 flag, add tests
The -0 flags works like xargs -0.
2020-05-10 00:04:14 +02:00
Jakob Unterwurzacher
171b1eac91 test_helpers: use new ctlsock.CtlSock API 2020-05-09 19:09:33 +02:00
Jakob Unterwurzacher
f0184804f4 test_helper: kill lsof after 1 second
lsof may get stuck when gocryptfs itself is stuck.
2020-05-09 19:03:16 +02:00
Jakob Unterwurzacher
16221facb9 ctlsock: create exported ctlsock client library
The former interal ctlsock server package is renamed
to ctlsocksrv.
2020-05-09 17:36:41 +02:00
Jakob Unterwurzacher
3ef563493a tests: add TestPasswdMasterkeyStdin
Tests that `gocryptfs -passwd -masterkey=stdin` works.
This was fixed by ff04b1d83a.

Fixes https://github.com/rfjakob/gocryptfs/issues/461
2020-05-09 16:53:25 +02:00
Jakob Unterwurzacher
c19baa10f8 tests: use t.Name()
We did not use t.Name() as it was not available
before Go 1.8. Now the oldest Go version we support is
Go 1.11, so we can use it.
2020-05-09 15:42:57 +02:00
Jakob Unterwurzacher
5dbf376860 tests: cli: rename TestBypass -> TestBadname
The command line option is now called `-badname`,
so adjust the test name to match.
2020-05-09 15:29:21 +02:00
Jakob Unterwurzacher
518771e4e2 fusefrontend_reverse: use inomap for inode number translation
Gets rid of static inode number value limitations.

Fixes https://github.com/rfjakob/gocryptfs/issues/457
2020-05-03 15:22:10 +02:00
Jakob Unterwurzacher
db93a6c54c tests: reverse: add inode mapping test (TestVirtualFileIno)
Verify that virtual files get assigned inode numbers
we expect.
2020-05-03 14:49:32 +02:00
Jakob Unterwurzacher
fdfaa849f8 tests: test xattr acls
Fixes https://github.com/rfjakob/gocryptfs/issues/453
2020-02-29 20:38:48 +01:00
orcas
9ec042f2f6 Show undecryptable filenames if they match supplied glob
Resolves https://github.com/rfjakob/gocryptfs/issues/393
2020-02-28 22:17:59 +01:00
Jakob Unterwurzacher
6eca07e36e tests: randomize data in testWriteN
Just writing zeros carries the risk of not detecting
wrongly created file holes. Write random data instead.
2020-02-15 21:56:08 +01:00
Jakob Unterwurzacher
dc21cd3572 tests: cli: add TestSymlinkedCipherdir
https://github.com/rfjakob/gocryptfs/issues/450
2020-01-25 16:54:57 +01:00
Pavol Rusnak
1364b44ae3 remove Trezor support 2019-12-28 19:50:49 +01:00
Jakob Unterwurzacher
7dda2363e1 Fix "go get" failure
Move the statusTxtContent to fix this confusing error
when running `go get github.com/rfjakob/gocryptfs/...`:

  $ go get github.com/rfjakob/gocryptfs/...
  # github.com/rfjakob/gocryptfs/tests/example_filesystems
  tests/example_filesystems/example_test_helpers.go:22:16: undefined: statusTxtContent
  tests/example_filesystems/example_test_helpers.go:75:16: undefined: statusTxtContent
2019-12-24 00:38:40 +01:00
Jakob Unterwurzacher
31ff557f85 tests: also check inode number in VerifySize
Check Stat() vs Fstat() result. Not very useful
at the moment as the kernel never seems to call Fstat().
2019-11-16 21:25:14 +01:00
Jakob Unterwurzacher
f7ddae24ed tests: fsstress: clean up leftover mounts on startup
Broken mounts may accumulate when the fs crashes.
2019-11-10 22:06:40 +01:00
Jakob Unterwurzacher
d404dcd3e3 tests: drop "-l" flag from fsstress-loopback.bash
No longer supported by go-fuse loopback.
2019-11-10 20:59:07 +01:00
Jakob Unterwurzacher
74b723d765 tests: send SIGUSR1 to loopback
loopback needs to receive SIGUSR1 to write a memory profile.
2019-11-03 20:04:23 +01:00
Jakob Unterwurzacher
6c91f697e1 tests: make extractloop work with go-fuse loopback again
The "-l" flag is no longer supported in go-fuse loopback, drop
it.
2019-10-19 19:58:39 +02:00
Jakob Unterwurzacher
65bc006a78 stress_tests: use /var/tmp by default
There is a good chance that /tmp is tmpfs, and we want to
run our tests on a real filesystem.
2019-10-06 22:34:19 +02:00
Jakob Unterwurzacher
8c44294087 tests: use /var/tmp by default
On Fedora, /tmp is tmpfs, which behaves differently than ext4
(inode numbers are never reused, for example).

Use /var/tmp, which is ext4 on Fedora, to get a more realistic
test environment.

This also allows us to drop the xattr workaround.
2019-10-06 21:53:20 +02:00
Jakob Unterwurzacher
1fb18f4a9e tests: filter leaked fds by prefix
When running

  $ go test ./tests/matrix/

in isolation, it failed like this:

  fd leak? before, after:
  [0r=/dev/null 3w=/dev/null 5r=/proc/8078/fd (hidden:4)]
  [0r=/dev/null 3w=/dev/null 5w=/tmp/go-build366655199/b001/testlog.txt 7r=/proc/8078/fd (hidden:4)]

Filter by prefix to get rid of this spurious test failure.
2019-10-06 19:37:51 +02:00
Jakob Unterwurzacher
d361f6e35b tests: clarify which process seems to be leaking fds
The tests check if they leak fds themselves, but we also
check if gocryptfs leaks fds. Clarify what is what in the
error message.
2019-10-06 18:48:09 +02:00
Jakob Unterwurzacher
ce13851bbf tests: add TestNotIdle
Mount with idle timeout of 100ms read something every 10ms. The fs should
NOT get unmounted. Regression test for https://github.com/rfjakob/gocryptfs/issues/421
2019-09-08 16:16:18 +02:00
Jakob Unterwurzacher
ea634090dc test_helpers: ListFds: handle an exited process gracefully
This used to dump a backtrace to the console which obscured what
is going on.
2019-09-08 16:15:35 +02:00
Jakob Unterwurzacher
7eba4f0788 tests: matrix: test -serialize_reads
Test if https://github.com/rfjakob/gocryptfs/pull/413 works
as intended.
2019-09-01 12:51:42 +02:00
Jakob Unterwurzacher
991adfc934 -passwd now takes a passed -scryptn flag into account
https://github.com/rfjakob/gocryptfs/issues/400
2019-05-13 23:01:44 +02:00
Jakob Unterwurzacher
8d083e61f4 tests: root_test: also test file creation 2019-05-01 18:30:16 +02:00
Jakob Unterwurzacher
e22c8ea0bd tests: fix root_test permission issues
The parent directories need execute all permissions.
2019-05-01 18:29:06 +02:00
Jakob Unterwurzacher
96935e16b9 tests: add root_tests (tests that must run as root)
First test is a reproducer for
https://github.com/rfjakob/gocryptfs/issues/394 "Group permissions: No write access"
2019-05-01 13:12:44 +02:00
Jakob Unterwurzacher
3ac9872230 tests: split testParentDir by UID
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-05-01 13:12:44 +02:00
Jakob Unterwurzacher
41dfbe67f8 test_helpers: better function comments for InitFS and Mount
It's confusing that you must pass "-extpass" for Mount but not
for InitFS. Note that in the comment.
2019-05-01 13:12:44 +02:00
leilaes
cc0a603ef8 Add CodeLingo Tenet to fix missing close file 2019-04-10 13:33:58 +02:00
Jakob Unterwurzacher
24036ab89f tests: speed up new tests a little
Before: ok  	github.com/rfjakob/gocryptfs/tests/matrix	18.560s
After:  ok  	github.com/rfjakob/gocryptfs/tests/matrix	13.425s
2019-04-08 20:34:24 +02:00
Jakob Unterwurzacher
d851cf8055 tests: add TestConcurrentReadCreate, move to new file
https://github.com/rfjakob/gocryptfs/issues/363
2019-04-08 20:27:13 +02:00
Jakob Unterwurzacher
d22ccf68b2 tests: add TestConcurrentReadWrite
Another attempt to find out what is going on behind
https://github.com/rfjakob/gocryptfs/issues/363
2019-04-08 20:27:13 +02:00
Jakob Unterwurzacher
311c34af4b tests: add additional TestWrite10Tight test
Try to find out what goes wrong in
https://github.com/rfjakob/gocryptfs/issues/363
2019-04-08 20:27:13 +02:00
Jakob Unterwurzacher
fe06e9f456 readpassword: delete CheckTrailingGarbage
CheckTrailingGarbage was called even when "-passfile" was
used, which is stupid, and causes false positives:

https://github.com/rfjakob/gocryptfs/issues/391
(false error "Received trailing garbage after the password"
when using -passfile in .bash_profile)

Instead of trying to improve the logic to handle that case
and make everything even more complicated, delete the function.

It is unclear if actually helps in some cases, and it definitely
harms as shown by the above bug report.
2019-04-08 20:18:45 +02:00
Jakob Unterwurzacher
8f2723b387 Allow "nofail" for /etc/fstab use 2019-03-31 14:33:02 +02:00
Jakob Unterwurzacher
ec17445b99 forward mode: create gocryptfs.diriv files with 0440 permissions
Makes it easier to share an encrypted folder via a network drive.

https://github.com/rfjakob/gocryptfs/issues/387
2019-03-30 20:06:40 +01:00
Eduardo M KALINOWSKI
3bc100aeb3 reverse mode: support wildcard exclude (--exclude-wildcard)
This adds support for gitignore-like wildcards and exclude patters in
reverse mode. It (somewhat) fixes #273: no regexp support, but the
syntax should be powerful enough to satisfy most needs.

Also, since adding a lot of --exclude options can be tedious, it adds
the --exclude-from option to read patterns from a file (or files).
2019-03-26 20:56:37 +01:00
Jakob Unterwurzacher
cd7a686211 tests: fix data race in TestDirIVRace
Ironically, the test for DirIV races had a data race itself
by writing to a bool without taking a lock.

Found by running "./test.bash -race":

WARNING: DATA RACE
Write at 0x00c00001dea5 by goroutine 22:
  github.com/rfjakob/gocryptfs/tests/defaults.TestDirIVRace.func1()
      /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/defaults/diriv_test.go:39 +0x38
  github.com/rfjakob/gocryptfs/tests/defaults.TestDirIVRace()
      /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/defaults/diriv_test.go:73 +0x65c
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:865 +0x163

Previous read at 0x00c00001dea5 by goroutine 23:
  github.com/rfjakob/gocryptfs/tests/defaults.TestDirIVRace.func2()
      /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/defaults/diriv_test.go:51 +0x8b

Goroutine 22 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:916 +0x699
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /usr/local/go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:1072 +0x2eb
  github.com/rfjakob/gocryptfs/tests/defaults.TestMain()
      /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/defaults/main_test.go:21 +0xe1
  main.main()
      _testmain.go:76 +0x222

Goroutine 23 (running) created at:
  github.com/rfjakob/gocryptfs/tests/defaults.TestDirIVRace()
      /home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/defaults/diriv_test.go:43 +0x48d
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:865 +0x163
==================
--- FAIL: TestDirIVRace (0.00s)
    testing.go:809: race detected during execution of test
FAIL
2019-03-03 14:09:33 +01:00
Jakob Unterwurzacher
173218895c tests: fix compile error in matrix_test.go
Error was:

tests/matrix/matrix_test.go:101:9: no new variables on left side of :=
2019-02-17 17:25:41 +01:00