]> Cypherpunks.ru repositories - gocheese.git/blobdiff - passwd.go
URL fixes
[gocheese.git] / passwd.go
index 6fb75f57a192702bcc793495a9c44de708d163af..dae17a5364b687107f8590caac1231bae71198b3 100644 (file)
--- a/passwd.go
+++ b/passwd.go
@@ -1,7 +1,7 @@
 /*
 GoCheese -- Python private package repository and caching proxy
-Copyright (C) 2019 Sergey Matveev <stargrave@stargrave.org>
-              2019 Elena Balakhonova <balakhonova_e@riseup.net>
+Copyright (C) 2019-2020 Sergey Matveev <stargrave@stargrave.org>
+              2019-2020 Elena Balakhonova <balakhonova_e@riseup.net>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -22,9 +22,16 @@ import (
        "errors"
        "io/ioutil"
        "log"
+       "os"
        "strings"
 )
 
+var passwords map[string]Auther = make(map[string]Auther)
+
+type Auther interface {
+       Auth(password string) bool
+}
+
 func strToAuther(verifier string) (string, Auther, error) {
        st := strings.SplitN(verifier, "$", 3)
        if len(st) != 3 || st[0] != "" {
@@ -46,6 +53,9 @@ func strToAuther(verifier string) (string, Auther, error) {
 
 func refreshPasswd() {
        passwd, err := ioutil.ReadFile(*passwdPath)
+       if os.IsNotExist(err) {
+               return
+       }
        if err != nil {
                log.Fatal(err)
        }
@@ -67,7 +77,7 @@ func refreshPasswd() {
                        log.Fatalf("%s:%d: %s: %s", *passwdPath, i, login, err)
                }
                passwordsNew[login] = auther
-               log.Println("Added password for " + login)
+               log.Println("added password for " + login)
        }
        passwords = passwordsNew
 }