Browse Source

fix #868

tags/v2.1.0-rc1
Shivaram Lingamneni 4 years ago
parent
commit
65ebe7f64a
6 changed files with 28 additions and 24 deletions
  1. 3
    3
      docs/MANUAL.md
  2. 1
    1
      irc/client.go
  3. 2
    2
      irc/commands.go
  4. 9
    5
      irc/config.go
  5. 5
    5
      irc/handlers.go
  6. 8
    8
      oragono.yaml

+ 3
- 3
docs/MANUAL.md View File

@@ -683,9 +683,9 @@ oper-classes:
683 683
 
684 684
         # capability names
685 685
         capabilities:
686
-        - "oper:local_kill"
687
-        - "oper:local_ban"
688
-        - "oper:local_unban"
686
+        - "local_kill"
687
+        - "local_ban"
688
+        - "local_unban"
689 689
         - "nofakelag"
690 690
 
691 691
 # ircd operators

+ 1
- 1
irc/client.go View File

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

+ 2
- 2
irc/commands.go View File

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

+ 9
- 5
irc/config.go View File

@@ -584,12 +584,16 @@ type Config struct {
584 584
 // OperClass defines an assembled operator class.
585 585
 type OperClass struct {
586 586
 	Title        string
587
-	WhoisLine    string          `yaml:"whois-line"`
588
-	Capabilities map[string]bool // map to make lookups much easier
587
+	WhoisLine    string    `yaml:"whois-line"`
588
+	Capabilities StringSet // map to make lookups much easier
589 589
 }
590 590
 
591 591
 // OperatorClasses returns a map of assembled operator classes from the given config.
592 592
 func (conf *Config) OperatorClasses() (map[string]*OperClass, error) {
593
+	fixupCapability := func(capab string) string {
594
+		return strings.TrimPrefix(capab, "oper:") // #868
595
+	}
596
+
593 597
 	ocs := make(map[string]*OperClass)
594 598
 
595 599
 	// 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) {
619 623
 
620 624
 			// create new operclass
621 625
 			var oc OperClass
622
-			oc.Capabilities = make(map[string]bool)
626
+			oc.Capabilities = make(StringSet)
623 627
 
624 628
 			// get inhereted info from other operclasses
625 629
 			if len(info.Extends) > 0 {
626 630
 				einfo := ocs[info.Extends]
627 631
 
628 632
 				for capab := range einfo.Capabilities {
629
-					oc.Capabilities[capab] = true
633
+					oc.Capabilities.Add(fixupCapability(capab))
630 634
 				}
631 635
 			}
632 636
 
633 637
 			// add our own info
634 638
 			oc.Title = info.Title
635 639
 			for _, capab := range info.Capabilities {
636
-				oc.Capabilities[capab] = true
640
+				oc.Capabilities.Add(fixupCapability(capab))
637 641
 			}
638 642
 			if len(info.WhoisLine) > 0 {
639 643
 				oc.WhoisLine = info.WhoisLine

+ 5
- 5
irc/handlers.go View File

@@ -716,7 +716,7 @@ func debugHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
716 716
 		rb.Notice(fmt.Sprintf("CPU profiling stopped"))
717 717
 
718 718
 	case "CRASHSERVER":
719
-		if !client.HasRoleCapabs("oper:rehash") {
719
+		if !client.HasRoleCapabs("rehash") {
720 720
 			rb.Notice(client.t("You must have rehash permissions in order to execute DEBUG CRASHSERVER"))
721 721
 			return false
722 722
 		}
@@ -770,7 +770,7 @@ func formatBanForListing(client *Client, key string, info IPBanInfo) string {
770 770
 func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
771 771
 	// check oper permissions
772 772
 	oper := client.Oper()
773
-	if oper == nil || !oper.Class.Capabilities["oper:local_ban"] {
773
+	if oper == nil || !oper.Class.Capabilities.Has("local_ban") {
774 774
 		rb.Add(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs"))
775 775
 		return false
776 776
 	}
@@ -1229,7 +1229,7 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
1229 1229
 	details := client.Details()
1230 1230
 	// check oper permissions
1231 1231
 	oper := client.Oper()
1232
-	if oper == nil || !oper.Class.Capabilities["oper:local_ban"] {
1232
+	if oper == nil || !oper.Class.Capabilities.Has("local_ban") {
1233 1233
 		rb.Add(nil, server.name, ERR_NOPRIVS, details.nick, msg.Command, client.t("Insufficient oper privs"))
1234 1234
 		return false
1235 1235
 	}
@@ -2383,7 +2383,7 @@ func topicHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
2383 2383
 func unDLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
2384 2384
 	// check oper permissions
2385 2385
 	oper := client.Oper()
2386
-	if oper == nil || !oper.Class.Capabilities["oper:local_unban"] {
2386
+	if oper == nil || !oper.Class.Capabilities.Has("local_unban") {
2387 2387
 		rb.Add(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs"))
2388 2388
 		return false
2389 2389
 	}
@@ -2417,7 +2417,7 @@ func unKLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R
2417 2417
 	details := client.Details()
2418 2418
 	// check oper permissions
2419 2419
 	oper := client.Oper()
2420
-	if oper == nil || !oper.Class.Capabilities["oper:local_unban"] {
2420
+	if oper == nil || !oper.Class.Capabilities.Has("local_unban") {
2421 2421
 		rb.Add(nil, server.name, ERR_NOPRIVS, details.nick, msg.Command, client.t("Insufficient oper privs"))
2422 2422
 		return false
2423 2423
 	}

+ 8
- 8
oragono.yaml View File

@@ -484,9 +484,9 @@ oper-classes:
484 484
 
485 485
         # capability names
486 486
         capabilities:
487
-            - "oper:local_kill"
488
-            - "oper:local_ban"
489
-            - "oper:local_unban"
487
+            - "local_kill"
488
+            - "local_ban"
489
+            - "local_unban"
490 490
             - "nofakelag"
491 491
 
492 492
     # network operator
@@ -499,9 +499,9 @@ oper-classes:
499 499
 
500 500
         # capability names
501 501
         capabilities:
502
-            - "oper:remote_kill"
503
-            - "oper:remote_ban"
504
-            - "oper:remote_unban"
502
+            - "remote_kill"
503
+            - "remote_ban"
504
+            - "remote_unban"
505 505
 
506 506
     # server admin
507 507
     "server-admin":
@@ -513,8 +513,8 @@ oper-classes:
513 513
 
514 514
         # capability names
515 515
         capabilities:
516
-            - "oper:rehash"
517
-            - "oper:die"
516
+            - "rehash"
517
+            - "die"
518 518
             - "accreg"
519 519
             - "sajoin"
520 520
             - "samode"

Loading…
Cancel
Save