From 416080203b4dd79de857eaf7c7cc97d050e00a9f Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 17 May 2020 19:31:04 +0200 Subject: main: accept multiple -passfile options Each file will be read and then concatenated for the effictive password. This can be used as a kind of multi-factor authenticiton. Fixes https://github.com/rfjakob/gocryptfs/issues/288 --- internal/readpassword/read.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'internal/readpassword/read.go') diff --git a/internal/readpassword/read.go b/internal/readpassword/read.go index 92a0886..e116f0b 100644 --- a/internal/readpassword/read.go +++ b/internal/readpassword/read.go @@ -20,11 +20,11 @@ const ( maxPasswordLen = 2048 ) -// Once tries to get a password from the user, either from the terminal, extpass +// Once tries to get a password from the user, either from the terminal, extpass, passfile // or stdin. Leave "prompt" empty to use the default "Password: " prompt. -func Once(extpass []string, passfile string, prompt string) []byte { - if passfile != "" { - return readPassFile(passfile) +func Once(extpass []string, passfile []string, prompt string) []byte { + if len(passfile) != 0 { + return readPassFileConcatenate(passfile) } if len(extpass) != 0 { return readPasswordExtpass(extpass) @@ -40,9 +40,9 @@ func Once(extpass []string, passfile string, prompt string) []byte { // Twice is the same as Once but will prompt twice if we get the password from // the terminal. -func Twice(extpass []string, passfile string) []byte { - if passfile != "" { - return readPassFile(passfile) +func Twice(extpass []string, passfile []string) []byte { + if len(passfile) != 0 { + return readPassFileConcatenate(passfile) } if len(extpass) != 0 { return readPasswordExtpass(extpass) -- cgit v1.2.3