mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-20 06:10:00 -08:00
Fix SuperUser handling on new servers.
This commit is contained in:
parent
5a2e3331d9
commit
fec890da2f
2 changed files with 11 additions and 6 deletions
15
freeze.go
15
freeze.go
|
|
@ -17,11 +17,12 @@ import (
|
|||
)
|
||||
|
||||
type frozenServer struct {
|
||||
Id int "id"
|
||||
Config map[string]string "config"
|
||||
Bans []ban.Ban "bans"
|
||||
Channels []frozenChannel "channels"
|
||||
Users []frozenUser "users"
|
||||
Id int "id"
|
||||
SuperUserPassword string "supw"
|
||||
Config map[string]string "config"
|
||||
Bans []ban.Ban "bans"
|
||||
Channels []frozenChannel "channels"
|
||||
Users []frozenUser "users"
|
||||
}
|
||||
|
||||
type frozenUser struct {
|
||||
|
|
@ -104,7 +105,7 @@ func (server *Server) FreezeToFile(filename string) (err os.Error) {
|
|||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Rename(filename, filename + ".old")
|
||||
err = os.Rename(filename, filename+".old")
|
||||
if e, ok := err.(*os.LinkError); ok {
|
||||
if e.Error != os.ENOENT {
|
||||
return err
|
||||
|
|
@ -125,6 +126,7 @@ func (server *Server) FreezeToFile(filename string) (err os.Error) {
|
|||
func (server *Server) Freeze() (fs frozenServer, err os.Error) {
|
||||
fs.Id = int(server.Id)
|
||||
fs.Config = server.cfg.GetAll()
|
||||
fs.SuperUserPassword = server.SuperUserPassword
|
||||
|
||||
server.banlock.RLock()
|
||||
fs.Bans = make([]ban.Ban, len(server.Bans))
|
||||
|
|
@ -258,6 +260,7 @@ func NewServerFromFrozen(filename string) (s *Server, err os.Error) {
|
|||
s.cfg = serverconf.New(fs.Config)
|
||||
}
|
||||
|
||||
s.SuperUserPassword = fs.SuperUserPassword
|
||||
s.Bans = fs.Bans
|
||||
|
||||
// Add all channels, but don't hook up parent/child relationships
|
||||
|
|
|
|||
|
|
@ -155,6 +155,8 @@ func NewServer(id int64, addr string, port int) (s *Server, err os.Error) {
|
|||
s.clientAuthenticated = make(chan *Client)
|
||||
|
||||
s.Users[0], err = NewUser(0, "SuperUser")
|
||||
s.UserNameMap["SuperUser"] = s.Users[0]
|
||||
|
||||
s.Channels = make(map[int]*Channel)
|
||||
s.root = s.NewChannel(0, "Root")
|
||||
s.aclcache = NewACLCache()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue