Commit 9ce591e4 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Override permissions for disk recording.

parent 3bd9a1db
...@@ -53,6 +53,10 @@ func (client *Client) Credentials() group.ClientCredentials { ...@@ -53,6 +53,10 @@ func (client *Client) Credentials() group.ClientCredentials {
return group.ClientCredentials{"RECORDING", ""} return group.ClientCredentials{"RECORDING", ""}
} }
func (client *Client) OverridePermissions(g *group.Group) bool {
return true
}
func (client *Client) SetPermissions(perms group.ClientPermissions) { func (client *Client) SetPermissions(perms group.ClientPermissions) {
return return
} }
......
...@@ -20,6 +20,7 @@ type Client interface { ...@@ -20,6 +20,7 @@ type Client interface {
Id() string Id() string
Credentials() ClientCredentials Credentials() ClientCredentials
SetPermissions(ClientPermissions) SetPermissions(ClientPermissions)
OverridePermissions(*Group) bool
PushConn(id string, conn conn.Up, tracks []conn.UpTrack, label string) error PushConn(id string, conn conn.Up, tracks []conn.UpTrack, label string) error
PushClient(id, username string, add bool) error PushClient(id, username string, add bool) error
} }
......
...@@ -271,29 +271,34 @@ func AddClient(name string, c Client) (*Group, error) { ...@@ -271,29 +271,34 @@ func AddClient(name string, c Client) (*Group, error) {
return nil, err return nil, err
} }
override := c.OverridePermissions(g)
g.mu.Lock() g.mu.Lock()
defer g.mu.Unlock() defer g.mu.Unlock()
perms, err := g.description.GetPermission(c.Credentials()) perms, err := g.description.GetPermission(c.Credentials())
if err != nil { if !override && err != nil {
return nil, err return nil, err
} }
c.SetPermissions(perms) c.SetPermissions(perms)
if !perms.Op && g.locked != nil { if !override {
m := *g.locked if !perms.Op && g.locked != nil {
if m == "" { m := *g.locked
m = "group is locked" if m == "" {
m = "group is locked"
}
return nil, UserError(m)
} }
return nil, UserError(m)
}
if !perms.Op && g.description.MaxClients > 0 { if !perms.Op && g.description.MaxClients > 0 {
if len(g.clients) >= g.description.MaxClients { if len(g.clients) >= g.description.MaxClients {
return nil, UserError("too many users") return nil, UserError("too many users")
}
} }
} }
if g.clients[c.Id()] != nil { if g.clients[c.Id()] != nil {
return nil, ProtocolError("duplicate client id") return nil, ProtocolError("duplicate client id")
} }
......
...@@ -73,6 +73,10 @@ func (c *webClient) SetPermissions(perms group.ClientPermissions) { ...@@ -73,6 +73,10 @@ func (c *webClient) SetPermissions(perms group.ClientPermissions) {
c.permissions = perms c.permissions = perms
} }
func (c *webClient) OverridePermissions(g *group.Group) bool {
return false
}
func (c *webClient) PushClient(id, username string, add bool) error { func (c *webClient) PushClient(id, username string, add bool) error {
kind := "add" kind := "add"
if !add { if !add {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment