1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-12-22 23:35:46 +01:00

Override permissions for disk recording.

This commit is contained in:
Juliusz Chroboczek 2020-10-01 13:38:09 +02:00
parent 3bd9a1db4e
commit 9ce591e4c5
4 changed files with 25 additions and 11 deletions

View file

@ -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
}

View file

@ -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
}

View file

@ -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)
}
if !perms.Op && g.description.MaxClients > 0 {
if len(g.clients) >= g.description.MaxClients {
return nil, UserError("too many users")
}
}
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 g.clients[c.Id()] != nil {
return nil, ProtocolError("duplicate client id")
}

View file

@ -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 {