Allow passwords with column

Before this patch, an `authfile` with multiple column symbols was not
valid.

After this patch, all characters after the first `:` constitute the
password, until EOL.
This commit is contained in:
Pierre Prinetti
2022-07-02 22:44:40 +02:00
committed by nkanaev
parent c1bcc0c517
commit c9dd977600
3 changed files with 73 additions and 11 deletions

View File

@@ -1,7 +1,6 @@
package main
import (
"bufio"
"flag"
"fmt"
"log"
@@ -94,16 +93,9 @@ func main() {
log.Fatal("Failed to open auth file: ", err)
}
defer f.Close()
scanner := bufio.NewScanner(f)
for scanner.Scan() {
line := scanner.Text()
parts := strings.Split(line, ":")
if len(parts) != 2 {
log.Fatalf("Invalid auth: %v (expected `username:password`)", line)
}
username = parts[0]
password = parts[1]
break
username, password, err = parseAuthfile(f)
if err != nil {
log.Fatal("Failed to parse auth file: ", err)
}
}