mirror of
https://github.com/jech/galene.git
synced 2024-11-09 18:25:58 +01:00
Override permissions for disk recording.
This commit is contained in:
parent
3bd9a1db4e
commit
9ce591e4c5
4 changed files with 25 additions and 11 deletions
|
@ -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 {
|
||||||
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) {
|
||||||
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
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) {
|
||||||
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 {
|
||||||
|
|
Loading…
Reference in a new issue