tests: reverse: check Access() call
This commit is contained in:
parent
45c1ea499e
commit
62e7eb7d04
@ -70,9 +70,9 @@ func (rfs *ReverseFS) rDecryptName(cName string, dirIV []byte, pDir string) (pNa
|
||||
}
|
||||
} else {
|
||||
// It makes no sense to decrypt a ".name" file. This is a virtual file
|
||||
// that has no represantation in the plaintext filesystem. ".name"
|
||||
// that has no representation in the plaintext filesystem. ".name"
|
||||
// files should have already been handled in virtualfile.go.
|
||||
tlog.Warn.Printf("decryptPath: tried to decrypt %q!? Returning EINVAL.", cName)
|
||||
tlog.Warn.Printf("rDecryptName: cannot decrypt virtual file %q", cName)
|
||||
return "", syscall.EINVAL
|
||||
}
|
||||
return pName, nil
|
||||
|
@ -3,6 +3,7 @@ package reverse_test
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"github.com/rfjakob/gocryptfs/tests/test_helpers"
|
||||
@ -65,3 +66,26 @@ func TestConfigMapping(t *testing.T) {
|
||||
t.Errorf("empty file")
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the access() syscall works on virtual files
|
||||
func TestAccessVirtual(t *testing.T) {
|
||||
if plaintextnames {
|
||||
t.Skip()
|
||||
}
|
||||
var R_OK uint32 = 4
|
||||
var W_OK uint32 = 2
|
||||
var X_OK uint32 = 1
|
||||
fn := dirB + "/gocryptfs.diriv"
|
||||
err := syscall.Access(fn, R_OK)
|
||||
if err != nil {
|
||||
t.Errorf("%q should be readable, but got error: %v", fn, err)
|
||||
}
|
||||
err = syscall.Access(fn, W_OK)
|
||||
if err == nil {
|
||||
t.Errorf("should NOT be writeable")
|
||||
}
|
||||
err = syscall.Access(fn, X_OK)
|
||||
if err == nil {
|
||||
t.Errorf("should NOT be executable")
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,20 @@ import (
|
||||
"github.com/rfjakob/gocryptfs/tests/test_helpers"
|
||||
)
|
||||
|
||||
var dirA, dirB, dirC string
|
||||
var x240 = string(bytes.Repeat([]byte("x"), 240))
|
||||
var plaintextnames bool
|
||||
|
||||
// dirA is a normal directory
|
||||
var dirA string
|
||||
|
||||
// dirB is the reverse mount backed by dirA
|
||||
var dirB string
|
||||
|
||||
// dirC is a forward mount backed by dirB
|
||||
var dirC string
|
||||
|
||||
// Create directory "dirA", mount it reverse to "dirB", mount it forward
|
||||
// to "dirC".
|
||||
func TestMain(m *testing.M) {
|
||||
var r int
|
||||
for _, plaintextnames = range []bool{false, true} {
|
||||
|
Loading…
Reference in New Issue
Block a user