From b144ad5b2dd5d62dd14909afd6696b3137bdf0db Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 3 Dec 2019 17:55:48 +0300 Subject: [PATCH] Skip commented lines in password file --- gocheese.texi | 2 ++ passwd.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/gocheese.texi b/gocheese.texi index 8ad7b69..f89df36 100644 --- a/gocheese.texi +++ b/gocheese.texi @@ -75,6 +75,8 @@ following format: username:hashed-password @end verbatim +Empty lines and having @verb{|#|} at the beginning are skipped. + Supported hashing algorithms are: @table @asis diff --git a/passwd.go b/passwd.go index b13a342..852192f 100644 --- a/passwd.go +++ b/passwd.go @@ -31,6 +31,9 @@ func refreshPasswd() { } passwordsNew := make(map[string]Auther) for i, credentials := range strings.Split(strings.TrimRight(string(passwd), "\n"), "\n") { + if len(credentials) == 0 || strings.HasPrefix(credentials, "#") { + continue + } splitted := strings.Split(credentials, ":") if len(splitted) != 2 { log.Fatalf("%s:%d: Wrong login:password format", *passwdPath, i) -- 2.44.0