3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-13 07:29:30 +01:00
strip local_ from oper capab names, also consolidate unban into ban
This commit is contained in:
Shivaram Lingamneni 2021-01-15 08:24:42 -05:00
parent 8769e2d92a
commit e195854851
7 changed files with 15 additions and 18 deletions

View File

@ -584,9 +584,8 @@ oper-classes:
# capability names # capability names
capabilities: capabilities:
- "local_kill" - "kill"
- "local_ban" - "ban"
- "local_unban"
- "nofakelag" - "nofakelag"
- "roleplay" - "roleplay"
- "relaymsg" - "relaymsg"

View File

@ -930,9 +930,8 @@ oper-classes:
# capability names # capability names
capabilities: capabilities:
- "local_kill" - "kill"
- "local_ban" - "ban"
- "local_unban"
- "nofakelag" - "nofakelag"
# ircd operators # ircd operators

View File

@ -170,7 +170,7 @@ func init() {
handler: killHandler, handler: killHandler,
minParams: 1, minParams: 1,
oper: true, oper: true,
capabs: []string{"local_kill"}, //TODO(dan): when we have S2S, this will be checked in the command handler itself capabs: []string{"kill"},
}, },
"KLINE": { "KLINE": {
handler: klineHandler, handler: klineHandler,

View File

@ -649,7 +649,7 @@ type OperClass struct {
// OperatorClasses returns a map of assembled operator classes from the given config. // OperatorClasses returns a map of assembled operator classes from the given config.
func (conf *Config) OperatorClasses() (map[string]*OperClass, error) { func (conf *Config) OperatorClasses() (map[string]*OperClass, error) {
fixupCapability := func(capab string) string { fixupCapability := func(capab string) string {
return strings.TrimPrefix(capab, "oper:") // #868 return strings.TrimPrefix(strings.TrimPrefix(capab, "oper:"), "local_") // #868, #1442
} }
ocs := make(map[string]*OperClass) ocs := make(map[string]*OperClass)

View File

@ -826,7 +826,7 @@ func formatBanForListing(client *Client, key string, info IPBanInfo) string {
func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
// check oper permissions // check oper permissions
oper := client.Oper() oper := client.Oper()
if oper == nil || !oper.Class.Capabilities.Has("local_ban") { if oper == nil || !oper.Class.Capabilities.Has("ban") {
rb.Add(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs")) rb.Add(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs"))
return false return false
} }
@ -1364,7 +1364,7 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
details := client.Details() details := client.Details()
// check oper permissions // check oper permissions
oper := client.Oper() oper := client.Oper()
if oper == nil || !oper.Class.Capabilities.Has("local_ban") { if oper == nil || !oper.Class.Capabilities.Has("ban") {
rb.Add(nil, server.name, ERR_NOPRIVS, details.nick, msg.Command, client.t("Insufficient oper privs")) rb.Add(nil, server.name, ERR_NOPRIVS, details.nick, msg.Command, client.t("Insufficient oper privs"))
return false return false
} }
@ -2814,7 +2814,7 @@ func topicHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
func unDLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { func unDLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
// check oper permissions // check oper permissions
oper := client.Oper() oper := client.Oper()
if oper == nil || !oper.Class.Capabilities.Has("local_unban") { if oper == nil || !oper.Class.Capabilities.Has("ban") {
rb.Add(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs")) rb.Add(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs"))
return false return false
} }
@ -2853,7 +2853,7 @@ func unKLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R
details := client.Details() details := client.Details()
// check oper permissions // check oper permissions
oper := client.Oper() oper := client.Oper()
if oper == nil || !oper.Class.Capabilities.Has("local_unban") { if oper == nil || !oper.Class.Capabilities.Has("ban") {
rb.Add(nil, server.name, ERR_NOPRIVS, details.nick, msg.Command, client.t("Insufficient oper privs")) rb.Add(nil, server.name, ERR_NOPRIVS, details.nick, msg.Command, client.t("Insufficient oper privs"))
return false return false
} }

View File

@ -1090,7 +1090,7 @@ func nsClientsHandler(service *ircService, server *Server, client *Client, comma
func nsClientsListHandler(service *ircService, server *Server, client *Client, params []string, rb *ResponseBuffer) { func nsClientsListHandler(service *ircService, server *Server, client *Client, params []string, rb *ResponseBuffer) {
target := client target := client
hasPrivs := client.HasRoleCapabs("local_ban") hasPrivs := client.HasRoleCapabs("ban")
if 0 < len(params) { if 0 < len(params) {
target = server.clients.Get(params[0]) target = server.clients.Get(params[0])
if target == nil { if target == nil {
@ -1141,10 +1141,10 @@ func nsClientsLogoutHandler(service *ircService, server *Server, client *Client,
service.Notice(rb, client.t("No such nick")) service.Notice(rb, client.t("No such nick"))
return return
} }
// User must have "local_kill" privileges to logout other user sessions. // User must have "kill" privileges to logout other user sessions.
if target != client { if target != client {
oper := client.Oper() oper := client.Oper()
if oper == nil || !oper.Class.Capabilities.Has("local_kill") { if oper == nil || !oper.Class.Capabilities.Has("kill") {
service.Notice(rb, client.t("Insufficient oper privs")) service.Notice(rb, client.t("Insufficient oper privs"))
return return
} }

View File

@ -556,9 +556,8 @@ oper-classes:
# capability names # capability names
capabilities: capabilities:
- "local_kill" - "kill"
- "local_ban" - "ban"
- "local_unban"
- "nofakelag" - "nofakelag"
- "roleplay" - "roleplay"
- "relaymsg" - "relaymsg"