X-Git-Url: https://ruderich.org/simon/gitweb/?p=nsscash%2Fnsscash.git;a=blobdiff_plain;f=passwd.go;h=2698765212e0975738ebc8d8273140daee528816;hp=07a62d8b8667d510d395fb8b5bd4a8a0c2c55570;hb=c6b898ea9ab372c58c59658c2acf17ea831d71db;hpb=424a573023a06c50fd8dad43174c12c42f7dada5 diff --git a/passwd.go b/passwd.go index 07a62d8..2698765 100644 --- a/passwd.go +++ b/passwd.go @@ -48,9 +48,15 @@ type Passwd struct { func ParsePasswds(r io.Reader) ([]Passwd, error) { var res []Passwd - s := bufio.NewScanner(r) - for s.Scan() { - t := s.Text() + s := bufio.NewReader(r) + for { + t, err := s.ReadString('\n') + if err != nil { + if err == io.EOF { + break + } + return nil, err + } x := strings.Split(t, ":") if len(x) != 7 { @@ -73,14 +79,10 @@ func ParsePasswds(r io.Reader) ([]Passwd, error) { Gid: gid, Gecos: x[4], Dir: x[5], - Shell: x[6], + // ReadString() contains the delimiter + Shell: strings.TrimSuffix(x[6], "\n"), }) } - err := s.Err() - if err != nil { - return nil, err - } - return res, nil }