Browse Source

Trim password if from executable output

Blallo 3 years ago
parent
commit
54fb7b3be3
1 changed files with 6 additions and 1 deletions
  1. 6 1
      config/config.go

+ 6 - 1
config/config.go

@@ -7,6 +7,7 @@ import (
 	"log"
 	"os"
 	"path"
+	"strings"
 
 	"git.lattuga.net/blallo/papero/worker"
 	"github.com/mitchellh/go-homedir"
@@ -178,7 +179,11 @@ func validatePort(port int) (int, error) {
 
 func getPassword(connection *connectionInfo) (string, error) {
 	if connection.PasswordExec.Present() {
-		return connection.PasswordExec.Run()
+		pass, err := connection.PasswordExec.Run()
+		if err != nil {
+			return "", err
+		}
+		return strings.TrimRight(pass, "\n"), nil
 	}
 	if connection.PasswordFile != "" {
 		file, err := os.Open(connection.PasswordFile)