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
 
683
 
684
         # capability names
684
         # capability names
685
         capabilities:
685
         capabilities:
686
-        - "oper:local_kill"
687
-        - "oper:local_ban"
688
-        - "oper:local_unban"
686
+        - "local_kill"
687
+        - "local_ban"
688
+        - "local_unban"
689
         - "nofakelag"
689
         - "nofakelag"
690
 
690
 
691
 # ircd operators
691
 # ircd operators

+ 1
- 1
irc/client.go View File

973
 	}
973
 	}
974
 
974
 
975
 	for _, capab := range capabs {
975
 	for _, capab := range capabs {
976
-		if !oper.Class.Capabilities[capab] {
976
+		if !oper.Class.Capabilities.Has(capab) {
977
 			return false
977
 			return false
978
 		}
978
 		}
979
 	}
979
 	}

+ 2
- 2
irc/commands.go View File

160
 			handler:   killHandler,
160
 			handler:   killHandler,
161
 			minParams: 1,
161
 			minParams: 1,
162
 			oper:      true,
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
 		"KLINE": {
165
 		"KLINE": {
166
 			handler:   klineHandler,
166
 			handler:   klineHandler,
289
 			handler:   rehashHandler,
289
 			handler:   rehashHandler,
290
 			minParams: 0,
290
 			minParams: 0,
291
 			oper:      true,
291
 			oper:      true,
292
-			capabs:    []string{"oper:rehash"},
292
+			capabs:    []string{"rehash"},
293
 		},
293
 		},
294
 		"TIME": {
294
 		"TIME": {
295
 			handler:   timeHandler,
295
 			handler:   timeHandler,

+ 9
- 5
irc/config.go View File

584
 // OperClass defines an assembled operator class.
584
 // OperClass defines an assembled operator class.
585
 type OperClass struct {
585
 type OperClass struct {
586
 	Title        string
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
 // OperatorClasses returns a map of assembled operator classes from the given config.
591
 // OperatorClasses returns a map of assembled operator classes from the given config.
592
 func (conf *Config) OperatorClasses() (map[string]*OperClass, error) {
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
 	ocs := make(map[string]*OperClass)
597
 	ocs := make(map[string]*OperClass)
594
 
598
 
595
 	// loop from no extends to most extended, breaking if we can't add any more
599
 	// loop from no extends to most extended, breaking if we can't add any more
619
 
623
 
620
 			// create new operclass
624
 			// create new operclass
621
 			var oc OperClass
625
 			var oc OperClass
622
-			oc.Capabilities = make(map[string]bool)
626
+			oc.Capabilities = make(StringSet)
623
 
627
 
624
 			// get inhereted info from other operclasses
628
 			// get inhereted info from other operclasses
625
 			if len(info.Extends) > 0 {
629
 			if len(info.Extends) > 0 {
626
 				einfo := ocs[info.Extends]
630
 				einfo := ocs[info.Extends]
627
 
631
 
628
 				for capab := range einfo.Capabilities {
632
 				for capab := range einfo.Capabilities {
629
-					oc.Capabilities[capab] = true
633
+					oc.Capabilities.Add(fixupCapability(capab))
630
 				}
634
 				}
631
 			}
635
 			}
632
 
636
 
633
 			// add our own info
637
 			// add our own info
634
 			oc.Title = info.Title
638
 			oc.Title = info.Title
635
 			for _, capab := range info.Capabilities {
639
 			for _, capab := range info.Capabilities {
636
-				oc.Capabilities[capab] = true
640
+				oc.Capabilities.Add(fixupCapability(capab))
637
 			}
641
 			}
638
 			if len(info.WhoisLine) > 0 {
642
 			if len(info.WhoisLine) > 0 {
639
 				oc.WhoisLine = info.WhoisLine
643
 				oc.WhoisLine = info.WhoisLine

+ 5
- 5
irc/handlers.go View File

716
 		rb.Notice(fmt.Sprintf("CPU profiling stopped"))
716
 		rb.Notice(fmt.Sprintf("CPU profiling stopped"))
717
 
717
 
718
 	case "CRASHSERVER":
718
 	case "CRASHSERVER":
719
-		if !client.HasRoleCapabs("oper:rehash") {
719
+		if !client.HasRoleCapabs("rehash") {
720
 			rb.Notice(client.t("You must have rehash permissions in order to execute DEBUG CRASHSERVER"))
720
 			rb.Notice(client.t("You must have rehash permissions in order to execute DEBUG CRASHSERVER"))
721
 			return false
721
 			return false
722
 		}
722
 		}
770
 func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
770
 func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
771
 	// check oper permissions
771
 	// check oper permissions
772
 	oper := client.Oper()
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
 		rb.Add(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs"))
774
 		rb.Add(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs"))
775
 		return false
775
 		return false
776
 	}
776
 	}
1229
 	details := client.Details()
1229
 	details := client.Details()
1230
 	// check oper permissions
1230
 	// check oper permissions
1231
 	oper := client.Oper()
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
 		rb.Add(nil, server.name, ERR_NOPRIVS, details.nick, msg.Command, client.t("Insufficient oper privs"))
1233
 		rb.Add(nil, server.name, ERR_NOPRIVS, details.nick, msg.Command, client.t("Insufficient oper privs"))
1234
 		return false
1234
 		return false
1235
 	}
1235
 	}
2383
 func unDLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
2383
 func unDLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
2384
 	// check oper permissions
2384
 	// check oper permissions
2385
 	oper := client.Oper()
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
 		rb.Add(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs"))
2387
 		rb.Add(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs"))
2388
 		return false
2388
 		return false
2389
 	}
2389
 	}
2417
 	details := client.Details()
2417
 	details := client.Details()
2418
 	// check oper permissions
2418
 	// check oper permissions
2419
 	oper := client.Oper()
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
 		rb.Add(nil, server.name, ERR_NOPRIVS, details.nick, msg.Command, client.t("Insufficient oper privs"))
2421
 		rb.Add(nil, server.name, ERR_NOPRIVS, details.nick, msg.Command, client.t("Insufficient oper privs"))
2422
 		return false
2422
 		return false
2423
 	}
2423
 	}

+ 8
- 8
oragono.yaml View File

484
 
484
 
485
         # capability names
485
         # capability names
486
         capabilities:
486
         capabilities:
487
-            - "oper:local_kill"
488
-            - "oper:local_ban"
489
-            - "oper:local_unban"
487
+            - "local_kill"
488
+            - "local_ban"
489
+            - "local_unban"
490
             - "nofakelag"
490
             - "nofakelag"
491
 
491
 
492
     # network operator
492
     # network operator
499
 
499
 
500
         # capability names
500
         # capability names
501
         capabilities:
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
     # server admin
506
     # server admin
507
     "server-admin":
507
     "server-admin":
513
 
513
 
514
         # capability names
514
         # capability names
515
         capabilities:
515
         capabilities:
516
-            - "oper:rehash"
517
-            - "oper:die"
516
+            - "rehash"
517
+            - "die"
518
             - "accreg"
518
             - "accreg"
519
             - "sajoin"
519
             - "sajoin"
520
             - "samode"
520
             - "samode"

Loading…
Cancel
Save