password-source stdin incorrect
chuckliu1979 opened this issue · comments
Chuck Liu commented
if use password-source:stdin, the password reading from os.Stdin contains character '\n' which caused incorrect auth
i made a patch for it:
ff@ff-ThinkPad-W540:~/projects/jira$ git diff
diff --git a/jiracli/password.go b/jiracli/password.go
index 1baa986..032363c 100644
--- a/jiracli/password.go
+++ b/jiracli/password.go
@@ -3,7 +3,6 @@ package jiracli
import (
"bytes"
"fmt"
-
"io/ioutil" "os" "os/exec" "strings"
@@ -118,11 +117,12 @@ func (o *GlobalOptions) GetPass() string {
}
} else if o.PasswordSource.Value == "stdin" {
log.Info("Reading password from stdin.")
-
allBytes, err := ioutil.ReadAll(os.Stdin)
-
var buffer [512]byte
-
nBytes, err := os.Stdin.Read(buffer[:]) if err != nil { panic(fmt.Sprintf("unable to read bytes from stdin: %s", err)) }
-
o.cachedPassword = string(allBytes)
-
o.cachedPassword = string(buffer[:nBytes-1]) } else { log.Warningf("Unknown password-source: %s", o.PasswordSource) }
ff@ff-ThinkPad-W540:~/projects/jira$