mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-22 11:59:40 +01:00
slightly more defensive implementation of /OPER check
This commit is contained in:
parent
78da024b24
commit
01488bfe2e
@ -2177,22 +2177,27 @@ func operHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// must have a matching oper block and not fail any enabled checks
|
// must pass at least one check, and all enabled checks
|
||||||
// (config validation ensures that there is at least one check)
|
var checkPassed, checkFailed bool
|
||||||
oper := server.GetOperator(msg.Params[0])
|
oper := server.GetOperator(msg.Params[0])
|
||||||
authorized := oper != nil
|
|
||||||
if oper != nil {
|
if oper != nil {
|
||||||
if oper.Fingerprint != "" && !utils.CertfpsMatch(oper.Fingerprint, client.certfp) {
|
if oper.Fingerprint != "" {
|
||||||
authorized = false
|
if utils.CertfpsMatch(oper.Fingerprint, client.certfp) {
|
||||||
} else if oper.Pass != nil {
|
checkPassed = true
|
||||||
if len(msg.Params) == 1 {
|
} else {
|
||||||
authorized = false
|
checkFailed = true
|
||||||
} else if bcrypt.CompareHashAndPassword(oper.Pass, []byte(msg.Params[1])) != nil {
|
}
|
||||||
authorized = false
|
}
|
||||||
|
if !checkFailed && oper.Pass != nil {
|
||||||
|
if len(msg.Params) == 1 || bcrypt.CompareHashAndPassword(oper.Pass, []byte(msg.Params[1])) != nil {
|
||||||
|
checkFailed = true
|
||||||
|
} else {
|
||||||
|
checkPassed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !authorized {
|
|
||||||
|
if !checkPassed || checkFailed {
|
||||||
rb.Add(nil, server.name, ERR_PASSWDMISMATCH, client.Nick(), client.t("Password incorrect"))
|
rb.Add(nil, server.name, ERR_PASSWDMISMATCH, client.Nick(), client.t("Password incorrect"))
|
||||||
client.Quit(client.t("Password incorrect"), rb.session)
|
client.Quit(client.t("Password incorrect"), rb.session)
|
||||||
return true
|
return true
|
||||||
|
Loading…
Reference in New Issue
Block a user