Add "--openssl=false" command line option
Also make main_test try both variants
This commit is contained in:
parent
c2bd208bbe
commit
39ea272e23
|
@ -21,3 +21,6 @@ fi
|
||||||
"$main" $* < /proc/self/fd/0 & wait
|
"$main" $* < /proc/self/fd/0 & wait
|
||||||
# The "& wait" is neccessary because bash only processes signals when
|
# The "& wait" is neccessary because bash only processes signals when
|
||||||
# executing internal commands
|
# executing internal commands
|
||||||
|
|
||||||
|
# We did not get USR1 - something went wrong
|
||||||
|
exit 1
|
||||||
|
|
|
@ -22,8 +22,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
USE_CLUEFS = false // Use cluefs or pathfs FUSE frontend
|
USE_OPENSSL = true
|
||||||
USE_OPENSSL = true // 3x speed increase compared to Go's built-in GCM
|
|
||||||
PATHFS_DEBUG = false
|
PATHFS_DEBUG = false
|
||||||
|
|
||||||
PROGRAM_NAME = "gocryptfs"
|
PROGRAM_NAME = "gocryptfs"
|
||||||
|
@ -64,12 +63,13 @@ func main() {
|
||||||
runtime.GOMAXPROCS(4)
|
runtime.GOMAXPROCS(4)
|
||||||
|
|
||||||
// Parse command line arguments
|
// 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(&debug, "debug", false, "Enable debug output")
|
||||||
flag.BoolVar(&fusedebug, "fusedebug", false, "Enable fuse library debug output")
|
flag.BoolVar(&fusedebug, "fusedebug", false, "Enable fuse library debug output")
|
||||||
flag.BoolVar(&init, "init", false, "Initialize encrypted directory")
|
flag.BoolVar(&init, "init", false, "Initialize encrypted directory")
|
||||||
flag.BoolVar(&zerokey, "zerokey", false, "Use all-zero dummy master key")
|
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")
|
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -87,6 +87,9 @@ func main() {
|
||||||
cryptfs.Debug.Enable()
|
cryptfs.Debug.Enable()
|
||||||
cryptfs.Debug.Printf("Debug output enabled\n")
|
cryptfs.Debug.Printf("Debug output enabled\n")
|
||||||
}
|
}
|
||||||
|
if openssl == false {
|
||||||
|
fmt.Printf("Openssl disabled\n")
|
||||||
|
}
|
||||||
if init {
|
if init {
|
||||||
if flag.NArg() != 1 {
|
if flag.NArg() != 1 {
|
||||||
fmt.Printf("usage: %s --init CIPHERDIR\n", PROGRAM_NAME)
|
fmt.Printf("usage: %s --init CIPHERDIR\n", PROGRAM_NAME)
|
||||||
|
@ -131,7 +134,7 @@ func main() {
|
||||||
fmt.Printf("done.\n")
|
fmt.Printf("done.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
srv := pathfsFrontend(key, cipherdir, mountpoint, fusedebug)
|
srv := pathfsFrontend(key, cipherdir, mountpoint, fusedebug, openssl)
|
||||||
fmt.Printf("Mounted.\n")
|
fmt.Printf("Mounted.\n")
|
||||||
|
|
||||||
if zerokey == false {
|
if zerokey == false {
|
||||||
|
@ -199,9 +202,9 @@ func dirEmpty(dir string) bool {
|
||||||
return false
|
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}
|
pathFsOpts := &pathfs.PathNodeFsOptions{ClientInodes: true}
|
||||||
pathFs := pathfs.NewPathNodeFs(finalFs, pathFsOpts)
|
pathFs := pathfs.NewPathNodeFs(finalFs, pathFsOpts)
|
||||||
fuseOpts := &nodefs.Options{
|
fuseOpts := &nodefs.Options{
|
||||||
|
|
|
@ -10,13 +10,27 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const tmpDir = "../tmp/"
|
const tmpDir = "../tmp/"
|
||||||
const plainDir = tmpDir + "plain/"
|
const plainDir = tmpDir + "plain/"
|
||||||
const cipherDir = tmpDir + "cipher/"
|
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 {
|
func unmount() error {
|
||||||
fu := exec.Command("fusermount", "-z", "-u", plainDir)
|
fu := exec.Command("fusermount", "-z", "-u", plainDir)
|
||||||
fu.Stdout = os.Stdout
|
fu.Stdout = os.Stdout
|
||||||
|
@ -35,6 +49,7 @@ func md5fn(filename string) string {
|
||||||
return hash
|
return hash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is the entry point for the tests
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
|
||||||
fu := exec.Command("fusermount", "-z", "-u", plainDir)
|
fu := exec.Command("fusermount", "-z", "-u", plainDir)
|
||||||
|
@ -52,17 +67,14 @@ func TestMain(m *testing.M) {
|
||||||
panic("Could not create cipherDir")
|
panic("Could not create cipherDir")
|
||||||
}
|
}
|
||||||
|
|
||||||
//c := exec.Command("./gocryptfs", "--zerokey", "--cpuprofile", "/tmp/gcfs.cpu", cipherDir, plainDir)
|
mount("--zerokey", "--openssl=false")
|
||||||
c := exec.Command("./gocryptfs_main", "--zerokey", cipherDir, plainDir)
|
|
||||||
c.Stdout = os.Stdout
|
|
||||||
c.Stderr = os.Stderr
|
|
||||||
go c.Run()
|
|
||||||
|
|
||||||
time.Sleep(3 * time.Second)
|
|
||||||
|
|
||||||
r := m.Run()
|
r := m.Run()
|
||||||
|
|
||||||
unmount()
|
unmount()
|
||||||
|
|
||||||
|
mount("--zerokey")
|
||||||
|
r = m.Run()
|
||||||
|
unmount()
|
||||||
|
|
||||||
os.Exit(r)
|
os.Exit(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue