diff options
| -rw-r--r-- | Documentation/MANPAGE.md | 2 | ||||
| -rw-r--r-- | cli_args.go | 4 | ||||
| -rw-r--r-- | internal/readpassword/read.go | 11 | 
3 files changed, 13 insertions, 4 deletions
| diff --git a/Documentation/MANPAGE.md b/Documentation/MANPAGE.md index 9dd4a12..63f86cf 100644 --- a/Documentation/MANPAGE.md +++ b/Documentation/MANPAGE.md @@ -149,7 +149,7 @@ Options:  **-passfile string**  :	Read password from the specified file. This is a shortcut for -	specifying "-extpass /bin/cat FILE". +	specifying '-extpass="/bin/cat -- FILE"'.  **-passwd**  :	Change the password. Will ask for the old password, check if it is diff --git a/cli_args.go b/cli_args.go index 89cbdd9..25392c4 100644 --- a/cli_args.go +++ b/cli_args.go @@ -151,9 +151,9 @@ func parseCliOpts() (args argContainer) {  			os.Exit(ErrExitUsage)  		}  	} -	// "-passfile FILE" is a shortcut for "-extpass=/bin/cat FILE" +	// '-passfile FILE' is a shortcut for -extpass='/bin/cat -- FILE'  	if args.passfile != "" { -		args.extpass = "/bin/cat " + args.passfile +		args.extpass = "/bin/cat -- " + args.passfile  	}  	if args.extpass != "" && args.masterkey != "" {  		tlog.Fatal.Printf("The options -extpass and -masterkey cannot be used at the same time") diff --git a/internal/readpassword/read.go b/internal/readpassword/read.go index 6945f0a..f00b425 100644 --- a/internal/readpassword/read.go +++ b/internal/readpassword/read.go @@ -83,7 +83,16 @@ func readPasswordStdin() string {  // Exits on read error or empty result.  func readPasswordExtpass(extpass string) string {  	tlog.Info.Println("Reading password from extpass program") -	parts := strings.Split(extpass, " ") +	var parts []string +	// The option "-passfile=FILE" gets transformed to +	// "-extpass="/bin/cat -- FILE". We don't want to split FILE on spaces, +	// so let's handle it manually. +	passfileCat := "/bin/cat -- " +	if strings.HasPrefix(extpass, passfileCat) { +		parts = []string{"/bin/cat", "--", extpass[len(passfileCat):]} +	} else { +		parts = strings.Split(extpass, " ") +	}  	cmd := exec.Command(parts[0], parts[1:]...)  	cmd.Stderr = os.Stderr  	pipe, err := cmd.StdoutPipe() | 
