summaryrefslogtreecommitdiff
path: root/mount.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-04-01 14:51:53 +0200
committerJakob Unterwurzacher2018-04-01 14:51:53 +0200
commita4f3a7dca2edd54ccc7941c73a33ba0ca0d34fdb (patch)
tree381f66c693757fbacbb3ca916ab9caef952fff62 /mount.go
parent6e637f38ffccd8be3d0e025aae53aeb382d99a08 (diff)
main: move masterkey logic into new helper getMasterKey
The new helper will also be used by fsck.
Diffstat (limited to 'mount.go')
-rw-r--r--mount.go33
1 files changed, 2 insertions, 31 deletions
diff --git a/mount.go b/mount.go
index c5b1c05..c21fa01 100644
--- a/mount.go
+++ b/mount.go
@@ -29,7 +29,6 @@ import (
"github.com/rfjakob/gocryptfs/internal/fusefrontend"
"github.com/rfjakob/gocryptfs/internal/fusefrontend_reverse"
"github.com/rfjakob/gocryptfs/internal/nametransform"
- "github.com/rfjakob/gocryptfs/internal/readpassword"
"github.com/rfjakob/gocryptfs/internal/tlog"
)
@@ -96,37 +95,9 @@ func doMount(args *argContainer) {
var confFile *configfile.ConfFile
var srv *fuse.Server
{
- // Get master key (may prompt for the password)
var masterkey []byte
- masterkeyFromStdin := false
- if args.masterkey == "stdin" {
- args.masterkey = string(readpassword.Once("", "Masterkey"))
- masterkeyFromStdin = true
- }
- if args.masterkey != "" {
- // "-masterkey"
- masterkey = parseMasterKey(args.masterkey, masterkeyFromStdin)
- } else if args.zerokey {
- // "-zerokey"
- tlog.Info.Printf("Using all-zero dummy master key.")
- tlog.Info.Printf(tlog.ColorYellow +
- "ZEROKEY MODE PROVIDES NO SECURITY AT ALL AND SHOULD ONLY BE USED FOR TESTING." +
- tlog.ColorReset)
- masterkey = make([]byte, cryptocore.KeyLen)
- } else {
- // Load master key from config file
- // Prompts the user for the password
- masterkey, confFile, err = loadConfig(args)
- if err != nil {
- if args._ctlsockFd != nil {
- // Close the socket file (which also deletes it)
- args._ctlsockFd.Close()
- }
- exitcodes.Exit(err)
- }
- readpassword.CheckTrailingGarbage()
- printMasterKey(masterkey)
- }
+ // Get master key (may prompt for the password)
+ masterkey, confFile = getMasterKey(args)
// We cannot use JSON for pretty-printing as the fields are unexported
tlog.Debug.Printf("cli args: %#v", args)
// Initialize FUSE server