summaryrefslogtreecommitdiff
path: root/internal/readpassword/read.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-01-29 00:34:12 +0100
committerJakob Unterwurzacher2017-01-29 00:34:12 +0100
commit6166dad05c1bf505f1c0fca1fbe8bf6a27d02db9 (patch)
tree436e69d74445f56f0858d2a459d3e2b0edfea3fc /internal/readpassword/read.go
parentde200aad72f8718041f345b68c3c77332f995861 (diff)
readpassword: support spaces in "-passfile" filename
...and while we are at it, also filenames starting with "-".
Diffstat (limited to 'internal/readpassword/read.go')
-rw-r--r--internal/readpassword/read.go11
1 files changed, 10 insertions, 1 deletions
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()