Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions sql/mysql_db/mysql_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,14 @@ func (db *MySQLDb) ValidateHash(salt []byte, user string, authResponse []byte, a
}

userEntry := db.GetUser(user, host, false, false)
if userEntry == nil || userEntry.Locked {
return nil, mysql.NewSQLError(mysql.ERAccessDeniedError, mysql.SSAccessDeniedError, "Access denied for user '%v'", user)
if userEntry == nil {
// Just return a simple error with the IP address
return nil, mysql.NewSQLError(mysql.ERAccessDeniedError, mysql.SSAccessDeniedError,
"Login not allowed. Connected from '%v'", host)
}

if userEntry.Locked {
return nil, mysql.NewSQLError(mysql.ERAccessDeniedError, mysql.SSAccessDeniedError, "Access denied for user '%v': Account is locked", user)
}
if len(userEntry.Password) > 0 {
if !validateMysqlNativePassword(authResponse, salt, userEntry.Password) {
Expand Down Expand Up @@ -567,6 +573,15 @@ func (db *MySQLDb) Negotiate(c *mysql.Conn, user string, addr net.Addr) (mysql.G
return connUser, nil
}
userEntry := db.GetUser(user, host, false, false)
if userEntry == nil {
// Just return a simple error with the IP address
return nil, mysql.NewSQLError(mysql.ERAccessDeniedError, mysql.SSAccessDeniedError,
"Login not allowed. Connected from '%v'", host)
}

if userEntry.Locked {
return nil, mysql.NewSQLError(mysql.ERAccessDeniedError, mysql.SSAccessDeniedError, "Access denied for user '%v': Account is locked", user)
}

if userEntry.Plugin != "" {
authplugin, ok := db.plugins[userEntry.Plugin]
Expand Down
Loading