summaryrefslogtreecommitdiff
path: root/masterkey.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-06-26 20:44:10 +0200
committerJakob Unterwurzacher2018-07-01 20:56:22 +0200
commit6d64dfe8f7acd8e9ca4a659d26318e442c2db85a (patch)
treeff140c9b8991708d2d8d0f051035d8e1fcd9189b /masterkey.go
parent991891a5c4b75a8815ebd3add8b453cbcb36012a (diff)
Only print masterkey once on -init
It is no longer printed at all when mounting a filesystem, printing on -init can be disabled with -q. https://github.com/rfjakob/gocryptfs/issues/76
Diffstat (limited to 'masterkey.go')
-rw-r--r--masterkey.go38
1 files changed, 0 insertions, 38 deletions
diff --git a/masterkey.go b/masterkey.go
index 1b4d9c3..42a27be 100644
--- a/masterkey.go
+++ b/masterkey.go
@@ -5,8 +5,6 @@ import (
"os"
"strings"
- "golang.org/x/crypto/ssh/terminal"
-
"github.com/rfjakob/gocryptfs/internal/configfile"
"github.com/rfjakob/gocryptfs/internal/cryptocore"
"github.com/rfjakob/gocryptfs/internal/exitcodes"
@@ -14,38 +12,6 @@ import (
"github.com/rfjakob/gocryptfs/internal/tlog"
)
-// printMasterKey - remind the user that he should store the master key in
-// a safe place
-func printMasterKey(key []byte) {
- if !terminal.IsTerminal(int(os.Stdout.Fd())) {
- // We don't want the master key to end up in a log file
- tlog.Info.Printf("Not running on a terminal, suppressing master key display\n")
- return
- }
- h := hex.EncodeToString(key)
- var hChunked string
- // Try to make it less scary by splitting it up in chunks
- for i := 0; i < len(h); i += 8 {
- hChunked += h[i : i+8]
- if i < 52 {
- hChunked += "-"
- }
- if i == 24 {
- hChunked += "\n "
- }
- }
- tlog.Info.Printf(`
-Your master key is:
-
- %s
-
-If the gocryptfs.conf file becomes corrupted or you ever forget your password,
-there is only one hope for recovery: The master key. Print it to a piece of
-paper and store it in a drawer. Use "-q" to suppress this message.
-
-`, tlog.ColorGrey+hChunked+tlog.ColorReset)
-}
-
// parseMasterKey - Parse a hex-encoded master key that was passed on the command line
// Calls os.Exit on failure
func parseMasterKey(masterkey string, fromStdin bool) []byte {
@@ -106,9 +72,5 @@ func getMasterKey(args *argContainer) (masterkey []byte, confFile *configfile.Co
if !args.trezor {
readpassword.CheckTrailingGarbage()
}
- if !args.fsck {
- // We only want to print the masterkey message on a normal mount.
- printMasterKey(masterkey)
- }
return masterkey, confFile
}