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 {
return group.ClientCredentials{"RECORDING", ""}
}
func (client *Client) OverridePermissions(g *group.Group) bool {
return true
}
func (client *Client) SetPermissions(perms group.ClientPermissions) {
return
}
......
......@@ -20,6 +20,7 @@ type Client interface {
Id() string
Credentials() ClientCredentials
SetPermissions(ClientPermissions)
OverridePermissions(*Group) bool
PushConn(id string, conn conn.Up, tracks []conn.UpTrack, label string) error
PushClient(id, username string, add bool) error
}
......
......@@ -271,29 +271,34 @@ func AddClient(name string, c Client) (*Group, error) {
return nil, err
}
override := c.OverridePermissions(g)
g.mu.Lock()
defer g.mu.Unlock()
perms, err := g.description.GetPermission(c.Credentials())
if err != nil {
if !override && err != nil {
return nil, err
}
c.SetPermissions(perms)
if !perms.Op && g.locked != nil {
m := *g.locked
if m == "" {
m = "group is locked"
if !override {
if !perms.Op && g.locked != nil {
m := *g.locked
if m == "" {
m = "group is locked"
}
return nil, UserError(m)
}
return nil, UserError(m)
}
if !perms.Op && g.description.MaxClients > 0 {
if len(g.clients) >= g.description.MaxClients {
return nil, UserError("too many users")
if !perms.Op && g.description.MaxClients > 0 {
if len(g.clients) >= g.description.MaxClients {
return nil, UserError("too many users")
}
}
}
if g.clients[c.Id()] != nil {
return nil, ProtocolError("duplicate client id")
}
......
......@@ -73,6 +73,10 @@ func (c *webClient) SetPermissions(perms group.ClientPermissions) {
c.permissions = perms
}
func (c *webClient) OverridePermissions(g *group.Group) bool {
return false
}
func (c *webClient) PushClient(id, username string, add bool) error {
kind := "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