3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00
This commit is contained in:
Shivaram Lingamneni 2020-03-18 05:42:52 -04:00
parent 39d3194104
commit 65ebe7f64a
6 changed files with 28 additions and 24 deletions

View File

@ -683,9 +683,9 @@ oper-classes:
# capability names
capabilities:
- "oper:local_kill"
- "oper:local_ban"
- "oper:local_unban"
- "local_kill"
- "local_ban"
- "local_unban"
- "nofakelag"
# ircd operators

View File

@ -973,7 +973,7 @@ func (client *Client) HasRoleCapabs(capabs ...string) bool {
}
for _, capab := range capabs {
if !oper.Class.Capabilities[capab] {
if !oper.Class.Capabilities.Has(capab) {
return false
}
}

View File

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

View File

@ -584,12 +584,16 @@ type Config struct {
// OperClass defines an assembled operator class.
type OperClass struct {
Title string
WhoisLine string `yaml:"whois-line"`
Capabilities map[string]bool // map to make lookups much easier
WhoisLine string `yaml:"whois-line"`
Capabilities StringSet // map to make lookups much easier
}
// OperatorClasses returns a map of assembled operator classes from the given config.
func (conf *Config) OperatorClasses() (map[string]*OperClass, error) {
fixupCapability := func(capab string) string {
return strings.TrimPrefix(capab, "oper:") // #868
}
ocs := make(map[string]*OperClass)
// loop from no extends to most extended, breaking if we can't add any more
@ -619,21 +623,21 @@ func (conf *Config) OperatorClasses() (map[string]*OperClass, error) {
// create new operclass
var oc OperClass
oc.Capabilities = make(map[string]bool)
oc.Capabilities = make(StringSet)
// get inhereted info from other operclasses
if len(info.Extends) > 0 {
einfo := ocs[info.Extends]
for capab := range einfo.Capabilities {
oc.Capabilities[capab] = true
oc.Capabilities.Add(fixupCapability(capab))
}
}
// add our own info
oc.Title = info.Title
for _, capab := range info.Capabilities {
oc.Capabilities[capab] = true
oc.Capabilities.Add(fixupCapability(capab))
}
if len(info.WhoisLine) > 0 {
oc.WhoisLine = info.WhoisLine

View File

@ -716,7 +716,7 @@ func debugHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
rb.Notice(fmt.Sprintf("CPU profiling stopped"))
case "CRASHSERVER":
if !client.HasRoleCapabs("oper:rehash") {
if !client.HasRoleCapabs("rehash") {
rb.Notice(client.t("You must have rehash permissions in order to execute DEBUG CRASHSERVER"))
return false
}
@ -770,7 +770,7 @@ func formatBanForListing(client *Client, key string, info IPBanInfo) string {
func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
// check oper permissions
oper := client.Oper()
if oper == nil || !oper.Class.Capabilities["oper:local_ban"] {
if oper == nil || !oper.Class.Capabilities.Has("local_ban") {
rb.Add(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs"))
return false
}
@ -1229,7 +1229,7 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
details := client.Details()
// check oper permissions
oper := client.Oper()
if oper == nil || !oper.Class.Capabilities["oper:local_ban"] {
if oper == nil || !oper.Class.Capabilities.Has("local_ban") {
rb.Add(nil, server.name, ERR_NOPRIVS, details.nick, msg.Command, client.t("Insufficient oper privs"))
return false
}
@ -2383,7 +2383,7 @@ func topicHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
func unDLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
// check oper permissions
oper := client.Oper()
if oper == nil || !oper.Class.Capabilities["oper:local_unban"] {
if oper == nil || !oper.Class.Capabilities.Has("local_unban") {
rb.Add(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs"))
return false
}
@ -2417,7 +2417,7 @@ func unKLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R
details := client.Details()
// check oper permissions
oper := client.Oper()
if oper == nil || !oper.Class.Capabilities["oper:local_unban"] {
if oper == nil || !oper.Class.Capabilities.Has("local_unban") {
rb.Add(nil, server.name, ERR_NOPRIVS, details.nick, msg.Command, client.t("Insufficient oper privs"))
return false
}

View File

@ -484,9 +484,9 @@ oper-classes:
# capability names
capabilities:
- "oper:local_kill"
- "oper:local_ban"
- "oper:local_unban"
- "local_kill"
- "local_ban"
- "local_unban"
- "nofakelag"
# network operator
@ -499,9 +499,9 @@ oper-classes:
# capability names
capabilities:
- "oper:remote_kill"
- "oper:remote_ban"
- "oper:remote_unban"
- "remote_kill"
- "remote_ban"
- "remote_unban"
# server admin
"server-admin":
@ -513,8 +513,8 @@ oper-classes:
# capability names
capabilities:
- "oper:rehash"
- "oper:die"
- "rehash"
- "die"
- "accreg"
- "sajoin"
- "samode"