3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 10:42:52 +01:00

disallow /SAMODE nick +o

This commit is contained in:
Shivaram Lingamneni 2020-03-17 13:19:27 -04:00
parent 76d3ecca71
commit d98e3581b3
2 changed files with 6 additions and 4 deletions

View File

@ -1602,7 +1602,7 @@ func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
} }
// apply mode changes // apply mode changes
applied = ApplyUserModeChanges(target, changes, msg.Command == "SAMODE") applied = ApplyUserModeChanges(target, changes, msg.Command == "SAMODE", nil)
} }
if len(applied) > 0 { if len(applied) > 0 {
@ -2117,7 +2117,7 @@ func applyOper(client *Client, oper *Oper, rb *ResponseBuffer) {
Op: modes.Add, Op: modes.Add,
} }
copy(modeChanges[1:], oper.Modes) copy(modeChanges[1:], oper.Modes)
applied := ApplyUserModeChanges(client, modeChanges, true) applied := ApplyUserModeChanges(client, modeChanges, true, oper)
client.server.snomasks.Send(sno.LocalOpers, fmt.Sprintf(ircfmt.Unescape("Client opered up $c[grey][$r%s$c[grey], $r%s$c[grey]]"), newDetails.nickMask, oper.Name)) client.server.snomasks.Send(sno.LocalOpers, fmt.Sprintf(ircfmt.Unescape("Client opered up $c[grey][$r%s$c[grey], $r%s$c[grey]]"), newDetails.nickMask, oper.Name))

View File

@ -23,7 +23,9 @@ var (
) )
// ApplyUserModeChanges applies the given changes, and returns the applied changes. // ApplyUserModeChanges applies the given changes, and returns the applied changes.
func ApplyUserModeChanges(client *Client, changes modes.ModeChanges, force bool) modes.ModeChanges { // `oper` is the operclass of the client gaining +o, when applicable (this is just
// to confirm that the client actually has a valid operclass)
func ApplyUserModeChanges(client *Client, changes modes.ModeChanges, force bool, oper *Oper) modes.ModeChanges {
applied := make(modes.ModeChanges, 0) applied := make(modes.ModeChanges, 0)
for _, change := range changes { for _, change := range changes {
@ -31,7 +33,7 @@ func ApplyUserModeChanges(client *Client, changes modes.ModeChanges, force bool)
case modes.Bot, modes.Invisible, modes.WallOps, modes.UserRoleplaying, modes.Operator, modes.LocalOperator, modes.RegisteredOnly: case modes.Bot, modes.Invisible, modes.WallOps, modes.UserRoleplaying, modes.Operator, modes.LocalOperator, modes.RegisteredOnly:
switch change.Op { switch change.Op {
case modes.Add: case modes.Add:
if !force && (change.Mode == modes.Operator || change.Mode == modes.LocalOperator) { if (change.Mode == modes.Operator || change.Mode == modes.LocalOperator) && !(force && oper != nil) {
continue continue
} }