Explorar el Código

make `ergo genpasswd` warn for bad passwords

tags/v2.8.0-rc1
Shivaram Lingamneni hace 2 años
padre
commit
7d5cb723b4
Se han modificado 2 ficheros con 8 adiciones y 4 borrados
  1. 4
    0
      ergo.go
  2. 4
    4
      irc/accounts.go

+ 4
- 0
ergo.go Ver fichero

128
 		} else {
128
 		} else {
129
 			password = getPassword()
129
 			password = getPassword()
130
 		}
130
 		}
131
+		if err := irc.ValidatePassphrase(password); err != nil {
132
+			log.Printf("WARNING: this password contains characters that may cause problems with your IRC client software.\n")
133
+			log.Printf("We strongly recommend choosing a different password.\n")
134
+		}
131
 		hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.MinCost)
135
 		hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.MinCost)
132
 		if err != nil {
136
 		if err != nil {
133
 			log.Fatal("encoding error:", err.Error())
137
 			log.Fatal("encoding error:", err.Error())

+ 4
- 4
irc/accounts.go Ver fichero

503
 	}
503
 	}
504
 }
504
 }
505
 
505
 
506
-// validatePassphrase checks whether a passphrase is allowed by our rules
507
-func validatePassphrase(passphrase string) error {
506
+// ValidatePassphrase checks whether a passphrase is allowed by our rules
507
+func ValidatePassphrase(passphrase string) error {
508
 	// sanity check the length
508
 	// sanity check the length
509
 	if len(passphrase) == 0 || len(passphrase) > 300 {
509
 	if len(passphrase) == 0 || len(passphrase) > 300 {
510
 		return errAccountBadPassphrase
510
 		return errAccountBadPassphrase
1122
 }
1122
 }
1123
 
1123
 
1124
 func (am *AccountManager) NsResetpass(client *Client, accountName, code, password string) (err error) {
1124
 func (am *AccountManager) NsResetpass(client *Client, accountName, code, password string) (err error) {
1125
-	if validatePassphrase(password) != nil {
1125
+	if ValidatePassphrase(password) != nil {
1126
 		return errAccountBadPassphrase
1126
 		return errAccountBadPassphrase
1127
 	}
1127
 	}
1128
 	account, err := am.LoadAccount(accountName)
1128
 	account, err := am.LoadAccount(accountName)
2181
 		return nil
2181
 		return nil
2182
 	}
2182
 	}
2183
 
2183
 
2184
-	if validatePassphrase(passphrase) != nil {
2184
+	if ValidatePassphrase(passphrase) != nil {
2185
 		return errAccountBadPassphrase
2185
 		return errAccountBadPassphrase
2186
 	}
2186
 	}
2187
 
2187
 

Loading…
Cancelar
Guardar