]> Cypherpunks.ru repositories - gocheese.git/commitdiff
Skip commented lines in password file
authorSergey Matveev <stargrave@stargrave.org>
Tue, 3 Dec 2019 14:55:48 +0000 (17:55 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 3 Dec 2019 14:55:48 +0000 (17:55 +0300)
gocheese.texi
passwd.go

index 8ad7b69db949fd0919d28e95cc2b8941c1fb5507..f89df36221c40070d6bc5e360c3af7fc28042170 100644 (file)
@@ -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
index b13a342c92835a25dfc67f968dc956dfb54ae3d1..852192f8b7ea898cb54d7ea3a4e912f884e13bc9 100644 (file)
--- 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)