From: Sergey Matveev Date: Tue, 3 Dec 2019 14:55:48 +0000 (+0300) Subject: Skip commented lines in password file X-Git-Tag: v2.0.0~18 X-Git-Url: http://www.git.cypherpunks.ru/?p=gocheese.git;a=commitdiff_plain;h=b144ad5b2dd5d62dd14909afd6696b3137bdf0db Skip commented lines in password file --- 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)