aboutsummaryrefslogtreecommitdiff
path: root/masterkey.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-03-22 00:02:10 +0100
committerJakob Unterwurzacher2018-03-22 00:02:10 +0100
commit9bc039a4bac6b51d9ebe116de5c311e90343a088 (patch)
treef4ebd37e2cbe4088435421fb7c9550c186161b09 /masterkey.go
parent9c86daf499dca8a69b058ec56803d06fbba4fdab (diff)
Add `-masterkey=stdin` functionality
https://github.com/rfjakob/gocryptfs/issues/218
Diffstat (limited to 'masterkey.go')
-rw-r--r--masterkey.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/masterkey.go b/masterkey.go
index 3d7afd1..6fda035 100644
--- a/masterkey.go
+++ b/masterkey.go
@@ -46,7 +46,7 @@ paper and store it in a drawer. Use "-q" to suppress this message.
// parseMasterKey - Parse a hex-encoded master key that was passed on the command line
// Calls os.Exit on failure
-func parseMasterKey(masterkey string) []byte {
+func parseMasterKey(masterkey string, fromStdin bool) []byte {
masterkey = strings.Replace(masterkey, "-", "", -1)
key, err := hex.DecodeString(masterkey)
if err != nil {
@@ -58,8 +58,10 @@ func parseMasterKey(masterkey string) []byte {
os.Exit(exitcodes.MasterKey)
}
tlog.Info.Printf("Using explicit master key.")
- tlog.Info.Printf(tlog.ColorYellow +
- "THE MASTER KEY IS VISIBLE VIA \"ps ax\" AND MAY BE STORED IN YOUR SHELL HISTORY!\n" +
- "ONLY USE THIS MODE FOR EMERGENCIES." + tlog.ColorReset)
+ if !fromStdin {
+ tlog.Info.Printf(tlog.ColorYellow +
+ "THE MASTER KEY IS VISIBLE VIA \"ps ax\" AND MAY BE STORED IN YOUR SHELL HISTORY!\n" +
+ "ONLY USE THIS MODE FOR EMERGENCIES" + tlog.ColorReset)
+ }
return key
}