summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cryptfs/config_file.go16
-rw-r--r--cryptfs/config_test.go6
-rw-r--r--cryptfs/content_test.go2
-rw-r--r--cryptfs/log.go2
-rw-r--r--integration_tests/helpers.go10
-rw-r--r--integration_tests/main_test.go7
-rw-r--r--integration_tests/performance_test.go4
-rw-r--r--main.go25
-rw-r--r--pathfs_frontend/fs.go24
9 files changed, 49 insertions, 47 deletions
diff --git a/cryptfs/config_file.go b/cryptfs/config_file.go
index 346bef8..db0abf5 100644
--- a/cryptfs/config_file.go
+++ b/cryptfs/config_file.go
@@ -10,7 +10,7 @@ import "os"
const (
// The dot "." is not used in base64url (RFC4648), hence
// we can never clash with an encrypted file.
- ConfDefaultName = "gocryptfs.conf"
+ ConfDefaultName = "gocryptfs.conf"
FlagPlaintextNames = "PlaintextNames"
)
@@ -79,12 +79,12 @@ func LoadConfFile(filename string, password string) ([]byte, *ConfFile, error) {
}
// Verify that we know all feature flags
- for _, flag := range(cf.FeatureFlags) {
- switch(flag) {
- case FlagPlaintextNames:
- continue
- default:
- return nil, nil, fmt.Errorf("Unsupported feature flag %s\n", flag)
+ for _, flag := range cf.FeatureFlags {
+ switch flag {
+ case FlagPlaintextNames:
+ continue
+ default:
+ return nil, nil, fmt.Errorf("Unsupported feature flag %s\n", flag)
}
}
@@ -151,7 +151,7 @@ func (cf *ConfFile) WriteFile() error {
// isFeatureFlagSet - is the feature flag "flagWant" enabled?
func (cf *ConfFile) isFeatureFlagSet(flagWant string) bool {
- for _, flag := range(cf.FeatureFlags) {
+ for _, flag := range cf.FeatureFlags {
if flag == flagWant {
return true
}
diff --git a/cryptfs/config_test.go b/cryptfs/config_test.go
index 2e46a25..cd8ed2f 100644
--- a/cryptfs/config_test.go
+++ b/cryptfs/config_test.go
@@ -26,13 +26,13 @@ func TestLoadV2(t *testing.T) {
}
elapsed := time.Since(t1)
- if elapsed < 100 *time.Millisecond {
- t.Errorf("scrypt calculation runs too fast: %d ms", elapsed / time.Millisecond)
+ if elapsed < 100*time.Millisecond {
+ t.Errorf("scrypt calculation runs too fast: %d ms", elapsed/time.Millisecond)
}
}
func TestLoadV2PwdError(t *testing.T) {
- if ! testing.Verbose() {
+ if !testing.Verbose() {
Warn.Disable()
}
_, _, err := LoadConfFile("config_test/v2.conf", "wrongpassword")
diff --git a/cryptfs/content_test.go b/cryptfs/content_test.go
index dbedf87..1b269bd 100644
--- a/cryptfs/content_test.go
+++ b/cryptfs/content_test.go
@@ -57,7 +57,7 @@ func TestCiphertextRange(t *testing.T) {
skipBytes := blocks[0].Skip
if alignedLength < r.length {
- t.Errorf("alignedLength=%s is smaller than length=%d", alignedLength, r.length)
+ t.Errorf("alignedLength=%d is smaller than length=%d", alignedLength, r.length)
}
if (alignedOffset-HEADER_LEN)%f.cipherBS != 0 {
t.Errorf("alignedOffset=%d is not aligned", alignedOffset)
diff --git a/cryptfs/log.go b/cryptfs/log.go
index 6173e63..64dc80e 100644
--- a/cryptfs/log.go
+++ b/cryptfs/log.go
@@ -47,7 +47,9 @@ func (l *logChannel) Md5sum(buf []byte) string {
// Debug messages
var Debug = logChannel{false}
+
// Informational message e.g. startup information
var Info = logChannel{true}
+
// A warning, meaning nothing serious by itself but might indicate problems
var Warn = logChannel{true}
diff --git a/integration_tests/helpers.go b/integration_tests/helpers.go
index 9bfd9fc..fdad28b 100644
--- a/integration_tests/helpers.go
+++ b/integration_tests/helpers.go
@@ -1,17 +1,19 @@
package integration_tests
import (
- "os"
- "os/exec"
- "fmt"
- "io/ioutil"
"crypto/md5"
"encoding/hex"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "os/exec"
"testing"
)
const tmpDir = "/tmp/gocryptfs_main_test/"
+
// Mountpoint
+// Note: the code assumes that both have a trailing slash!
const plainDir = tmpDir + "plain/"
const cipherDir = tmpDir + "cipher/"
diff --git a/integration_tests/main_test.go b/integration_tests/main_test.go
index 222c192..6049646 100644
--- a/integration_tests/main_test.go
+++ b/integration_tests/main_test.go
@@ -1,10 +1,10 @@
package integration_tests
import (
- "flag"
"bytes"
"crypto/md5"
"encoding/hex"
+ "flag"
"fmt"
"io/ioutil"
"os"
@@ -33,7 +33,6 @@ func TestMain(m *testing.M) {
os.Exit(r)
}
-
if testing.Verbose() {
fmt.Printf("***** Testing with native Go crypto\n")
}
@@ -278,7 +277,7 @@ func TestFiltered(t *testing.T) {
filteredFile := plainDir + "gocryptfs.conf"
file, err := os.Create(filteredFile)
if plaintextNames == true && err == nil {
- fmt.Errorf("should have failed but didn't")
+ t.Errorf("should have failed but didn't")
} else if plaintextNames == false && err != nil {
t.Error(err)
}
@@ -286,7 +285,7 @@ func TestFiltered(t *testing.T) {
err = os.Remove(filteredFile)
if plaintextNames == true && err == nil {
- fmt.Errorf("should have failed but didn't")
+ t.Errorf("should have failed but didn't")
} else if plaintextNames == false && err != nil {
t.Error(err)
}
diff --git a/integration_tests/performance_test.go b/integration_tests/performance_test.go
index e46cb91..b24474c 100644
--- a/integration_tests/performance_test.go
+++ b/integration_tests/performance_test.go
@@ -1,10 +1,10 @@
package integration_tests
import (
- "io/ioutil"
- "os"
"fmt"
"io"
+ "io/ioutil"
+ "os"
"testing"
)
diff --git a/main.go b/main.go
index 707585d..4917f75 100644
--- a/main.go
+++ b/main.go
@@ -64,11 +64,10 @@ func usageText() {
}
type argContainer struct {
- debug, init, zerokey, fusedebug, openssl, passwd, foreground, version,
- plaintextnames, quiet bool
- masterkey, mountpoint, cipherdir string
- cpuprofile *string
- notifypid int
+ debug, init, zerokey, fusedebug, openssl, passwd, foreground, version,
+ plaintextnames, quiet bool
+ masterkey, mountpoint, cipherdir, cpuprofile string
+ notifypid int
}
var flagSet *flag.FlagSet
@@ -88,13 +87,13 @@ func main() {
flagSet.BoolVar(&args.passwd, "passwd", false, "Change password")
flagSet.BoolVar(&args.foreground, "f", false, "Stay in the foreground")
flagSet.BoolVar(&args.version, "version", false, "Print version and exit")
- flagSet.BoolVar(&args.plaintextnames, "plaintextnames", false,
- "Do not encrypt file names - can only be used together with -init")
+ flagSet.BoolVar(&args.plaintextnames, "plaintextnames", false, "Do not encrypt "+
+ "file names - can only be used together with -init")
flagSet.BoolVar(&args.quiet, "q", false, "Quiet - silence informational messages")
flagSet.StringVar(&args.masterkey, "masterkey", "", "Mount with explicit master key")
- args.cpuprofile = flagSet.String("cpuprofile", "", "Write cpu profile to specified file")
- flagSet.IntVar(&args.notifypid, "notifypid", 0,
- "Send USR1 to the specified process after successful mount - used internally for daemonization")
+ flagSet.StringVar(&args.cpuprofile, "cpuprofile", "", "Write cpu profile to specified file")
+ flagSet.IntVar(&args.notifypid, "notifypid", 0, "Send USR1 to the specified process after "+
+ "successful mount - used internally for daemonization")
flagSet.Parse(os.Args[1:])
if args.version {
fmt.Printf("%s %s; on-disk format %d\n", PROGRAM_NAME, GitVersion, cryptfs.HEADER_CURRENT_VERSION)
@@ -106,13 +105,13 @@ func main() {
if !args.foreground {
daemonize() // does not return
}
- if *args.cpuprofile != "" {
- f, err := os.Create(*args.cpuprofile)
+ if args.cpuprofile != "" {
+ f, err := os.Create(args.cpuprofile)
if err != nil {
fmt.Println(err)
os.Exit(ERREXIT_INIT)
}
- cryptfs.Info.Printf("Writing CPU profile to %s\n", *args.cpuprofile)
+ cryptfs.Info.Printf("Writing CPU profile to %s\n", args.cpuprofile)
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
diff --git a/pathfs_frontend/fs.go b/pathfs_frontend/fs.go
index 9f5b1d6..c0a3a41 100644
--- a/pathfs_frontend/fs.go
+++ b/pathfs_frontend/fs.go
@@ -90,7 +90,7 @@ func (fs *FS) mangleOpenFlags(flags uint32) (newFlags int, writeOnly bool) {
func (fs *FS) Open(path string, flags uint32, context *fuse.Context) (fuseFile nodefs.File, status fuse.Status) {
cryptfs.Debug.Printf("Open(%s)\n", path)
- if fs.CryptFS.IsFiltered(path){
+ if fs.CryptFS.IsFiltered(path) {
return nil, fuse.EPERM
}
iflags, writeOnly := fs.mangleOpenFlags(flags)
@@ -103,7 +103,7 @@ func (fs *FS) Open(path string, flags uint32, context *fuse.Context) (fuseFile n
}
func (fs *FS) Create(path string, flags uint32, mode uint32, context *fuse.Context) (fuseFile nodefs.File, code fuse.Status) {
- if fs.CryptFS.IsFiltered(path){
+ if fs.CryptFS.IsFiltered(path) {
return nil, fuse.EPERM
}
iflags, writeOnly := fs.mangleOpenFlags(flags)
@@ -115,21 +115,21 @@ func (fs *FS) Create(path string, flags uint32, mode uint32, context *fuse.Conte
}
func (fs *FS) Chmod(path string, mode uint32, context *fuse.Context) (code fuse.Status) {
- if fs.CryptFS.IsFiltered(path){
+ if fs.CryptFS.IsFiltered(path) {
return fuse.EPERM
}
return fs.FileSystem.Chmod(fs.EncryptPath(path), mode, context)
}
func (fs *FS) Chown(path string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) {
- if fs.CryptFS.IsFiltered(path){
+ if fs.CryptFS.IsFiltered(path) {
return fuse.EPERM
}
return fs.FileSystem.Chown(fs.EncryptPath(path), uid, gid, context)
}
func (fs *FS) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) (code fuse.Status) {
- if fs.CryptFS.IsFiltered(name){
+ if fs.CryptFS.IsFiltered(name) {
return fuse.EPERM
}
return fs.FileSystem.Mknod(fs.EncryptPath(name), mode, dev, context)
@@ -141,7 +141,7 @@ func (fs *FS) Truncate(path string, offset uint64, context *fuse.Context) (code
}
func (fs *FS) Utimens(path string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status) {
- if fs.CryptFS.IsFiltered(path){
+ if fs.CryptFS.IsFiltered(path) {
return fuse.EPERM
}
return fs.FileSystem.Utimens(fs.EncryptPath(path), Atime, Mtime, context)
@@ -161,14 +161,14 @@ func (fs *FS) Readlink(name string, context *fuse.Context) (out string, status f
}
func (fs *FS) Mkdir(path string, mode uint32, context *fuse.Context) (code fuse.Status) {
- if fs.CryptFS.IsFiltered(path){
+ if fs.CryptFS.IsFiltered(path) {
return fuse.EPERM
}
return fs.FileSystem.Mkdir(fs.EncryptPath(path), mode, context)
}
func (fs *FS) Unlink(name string, context *fuse.Context) (code fuse.Status) {
- if fs.CryptFS.IsFiltered(name){
+ if fs.CryptFS.IsFiltered(name) {
return fuse.EPERM
}
cName := fs.EncryptPath(name)
@@ -184,7 +184,7 @@ func (fs *FS) Rmdir(name string, context *fuse.Context) (code fuse.Status) {
}
func (fs *FS) Symlink(pointedTo string, linkName string, context *fuse.Context) (code fuse.Status) {
- if fs.CryptFS.IsFiltered(linkName){
+ if fs.CryptFS.IsFiltered(linkName) {
return fuse.EPERM
}
// TODO symlink encryption
@@ -193,21 +193,21 @@ func (fs *FS) Symlink(pointedTo string, linkName string, context *fuse.Context)
}
func (fs *FS) Rename(oldPath string, newPath string, context *fuse.Context) (code fuse.Status) {
- if fs.CryptFS.IsFiltered(newPath){
+ if fs.CryptFS.IsFiltered(newPath) {
return fuse.EPERM
}
return fs.FileSystem.Rename(fs.EncryptPath(oldPath), fs.EncryptPath(newPath), context)
}
func (fs *FS) Link(orig string, newName string, context *fuse.Context) (code fuse.Status) {
- if fs.CryptFS.IsFiltered(newName){
+ if fs.CryptFS.IsFiltered(newName) {
return fuse.EPERM
}
return fs.FileSystem.Link(fs.EncryptPath(orig), fs.EncryptPath(newName), context)
}
func (fs *FS) Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) {
- if fs.CryptFS.IsFiltered(name){
+ if fs.CryptFS.IsFiltered(name) {
return fuse.EPERM
}
return fs.FileSystem.Access(fs.EncryptPath(name), mode, context)