summaryrefslogtreecommitdiff
path: root/masterkey.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-10-11 09:13:51 +0200
committerJakob Unterwurzacher2016-10-11 09:13:51 +0200
commit72efd3b6c3668191bd596c65caf623571ee12908 (patch)
treed5156b10c901c4cca5ea6f96918cf5b2fdb4479e /masterkey.go
parentc8e5dc9844dbdb7fbd48c8409b37926900d4c5fc (diff)
main: suppress master key display if not running on a terminal
Mounting through fstab or pam_mount may get the output logged into syslog. We don't want the master key to end up in syslog.
Diffstat (limited to 'masterkey.go')
-rw-r--r--masterkey.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/masterkey.go b/masterkey.go
index 2a93a38..2e8ca4c 100644
--- a/masterkey.go
+++ b/masterkey.go
@@ -5,6 +5,8 @@ import (
"os"
"strings"
+ "golang.org/x/crypto/ssh/terminal"
+
"github.com/rfjakob/gocryptfs/internal/cryptocore"
"github.com/rfjakob/gocryptfs/internal/tlog"
)
@@ -12,9 +14,13 @@ import (
// 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]
@@ -25,7 +31,6 @@ func printMasterKey(key []byte) {
hChunked += "\n "
}
}
-
tlog.Info.Printf(`
Your master key is: