aboutsummaryrefslogtreecommitdiff
path: root/gocryptfs_main
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-10-06 20:24:52 +0200
committerJakob Unterwurzacher2015-10-06 20:24:52 +0200
commit39ea272e233504a710ce6885434984b2f45fb398 (patch)
tree483583a5f1cea83858f8b9ad8c2d81857954ce6d /gocryptfs_main
parentc2bd208bbe2ab1b328435bb7ddd72a2268f8aa39 (diff)
Add "--openssl=false" command line option
Also make main_test try both variants
Diffstat (limited to 'gocryptfs_main')
-rw-r--r--gocryptfs_main/main.go15
-rw-r--r--gocryptfs_main/main_test.go30
2 files changed, 30 insertions, 15 deletions
diff --git a/gocryptfs_main/main.go b/gocryptfs_main/main.go
index 3674eb2..9ba2648 100644
--- a/gocryptfs_main/main.go
+++ b/gocryptfs_main/main.go
@@ -22,8 +22,7 @@ import (
)
const (
- USE_CLUEFS = false // Use cluefs or pathfs FUSE frontend
- USE_OPENSSL = true // 3x speed increase compared to Go's built-in GCM
+ USE_OPENSSL = true
PATHFS_DEBUG = false
PROGRAM_NAME = "gocryptfs"
@@ -64,12 +63,13 @@ func main() {
runtime.GOMAXPROCS(4)
// Parse command line arguments
- var debug, init, zerokey, fusedebug bool
+ var debug, init, zerokey, fusedebug, openssl bool
flag.BoolVar(&debug, "debug", false, "Enable debug output")
flag.BoolVar(&fusedebug, "fusedebug", false, "Enable fuse library debug output")
flag.BoolVar(&init, "init", false, "Initialize encrypted directory")
flag.BoolVar(&zerokey, "zerokey", false, "Use all-zero dummy master key")
+ flag.BoolVar(&openssl, "openssl", true, "Use OpenSSL instead of built-in Go crypto")
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
flag.Parse()
@@ -87,6 +87,9 @@ func main() {
cryptfs.Debug.Enable()
cryptfs.Debug.Printf("Debug output enabled\n")
}
+ if openssl == false {
+ fmt.Printf("Openssl disabled\n")
+ }
if init {
if flag.NArg() != 1 {
fmt.Printf("usage: %s --init CIPHERDIR\n", PROGRAM_NAME)
@@ -131,7 +134,7 @@ func main() {
fmt.Printf("done.\n")
}
- srv := pathfsFrontend(key, cipherdir, mountpoint, fusedebug)
+ srv := pathfsFrontend(key, cipherdir, mountpoint, fusedebug, openssl)
fmt.Printf("Mounted.\n")
if zerokey == false {
@@ -199,9 +202,9 @@ func dirEmpty(dir string) bool {
return false
}
-func pathfsFrontend(key []byte, cipherdir string, mountpoint string, debug bool) *fuse.Server {
+func pathfsFrontend(key []byte, cipherdir string, mountpoint string, debug bool, openssl bool) *fuse.Server {
- finalFs := pathfs_frontend.NewFS(key, cipherdir, USE_OPENSSL)
+ finalFs := pathfs_frontend.NewFS(key, cipherdir, openssl)
pathFsOpts := &pathfs.PathNodeFsOptions{ClientInodes: true}
pathFs := pathfs.NewPathNodeFs(finalFs, pathFsOpts)
fuseOpts := &nodefs.Options{
diff --git a/gocryptfs_main/main_test.go b/gocryptfs_main/main_test.go
index 218c256..f171a8c 100644
--- a/gocryptfs_main/main_test.go
+++ b/gocryptfs_main/main_test.go
@@ -10,13 +10,27 @@ import (
"os"
"os/exec"
"testing"
- "time"
)
const tmpDir = "../tmp/"
const plainDir = tmpDir + "plain/"
const cipherDir = tmpDir + "cipher/"
+func mount(extraArgs ...string) {
+ var args []string
+ args = append(args, extraArgs...)
+ args = append(args, cipherDir)
+ args = append(args, plainDir)
+ c := exec.Command("../gocryptfs", args...)
+ c.Stdout = os.Stdout
+ c.Stderr = os.Stderr
+ err := c.Run()
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+}
+
func unmount() error {
fu := exec.Command("fusermount", "-z", "-u", plainDir)
fu.Stdout = os.Stdout
@@ -35,6 +49,7 @@ func md5fn(filename string) string {
return hash
}
+// This is the entry point for the tests
func TestMain(m *testing.M) {
fu := exec.Command("fusermount", "-z", "-u", plainDir)
@@ -52,17 +67,14 @@ func TestMain(m *testing.M) {
panic("Could not create cipherDir")
}
- //c := exec.Command("./gocryptfs", "--zerokey", "--cpuprofile", "/tmp/gcfs.cpu", cipherDir, plainDir)
- c := exec.Command("./gocryptfs_main", "--zerokey", cipherDir, plainDir)
- c.Stdout = os.Stdout
- c.Stderr = os.Stderr
- go c.Run()
-
- time.Sleep(3 * time.Second)
-
+ mount("--zerokey", "--openssl=false")
r := m.Run()
+ unmount()
+ mount("--zerokey")
+ r = m.Run()
unmount()
+
os.Exit(r)
}