X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=passwd.go;h=1dffe21c24ec070ff24de7ec8ae2b13923d3bfdf;hb=5f74f27dba4c477281305586ef96a39b4751851e;hp=6fb75f57a192702bcc793495a9c44de708d163af;hpb=bcfc26f87e27a5d749eeed3194681e8018df4c5b;p=gocheese.git diff --git a/passwd.go b/passwd.go index 6fb75f5..1dffe21 100644 --- a/passwd.go +++ b/passwd.go @@ -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 }