mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-06 02:28:02 +02:00
access-default.lua: use default rules if none are defined
This commit is contained in:
parent
119b99dc23
commit
4bb949fd89
2 changed files with 59 additions and 42 deletions
|
|
@ -6,44 +6,43 @@ wireplumber.settings = {
|
|||
|
||||
## The list of access rules
|
||||
access.rules = [
|
||||
{
|
||||
matches = [
|
||||
{
|
||||
pipewire.access = "flatpak"
|
||||
media.category = "Manager"
|
||||
}
|
||||
]
|
||||
actions = {
|
||||
update-props = {
|
||||
default_permissions = "all",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
matches = [
|
||||
{
|
||||
pipewire.access = "flatpak"
|
||||
}
|
||||
]
|
||||
actions = {
|
||||
update-props = {
|
||||
default_permissions = "rx"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
matches = [
|
||||
{
|
||||
pipewire.access = "restricted"
|
||||
}
|
||||
]
|
||||
actions = {
|
||||
update-props = {
|
||||
default_permissions = "rx"
|
||||
}
|
||||
}
|
||||
}
|
||||
## The following are the default rules applied if none overrides them.
|
||||
# {
|
||||
# matches = [
|
||||
# {
|
||||
# pipewire.access = "flatpak"
|
||||
# media.category = "Manager"
|
||||
# }
|
||||
# ]
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# default_permissions = "all",
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# {
|
||||
# matches = [
|
||||
# {
|
||||
# pipewire.access = "flatpak"
|
||||
# }
|
||||
# ]
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# default_permissions = "rx"
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# {
|
||||
# matches = [
|
||||
# {
|
||||
# pipewire.access = "restricted"
|
||||
# }
|
||||
# ]
|
||||
# actions = {
|
||||
# update-props = {
|
||||
# default_permissions = "rx"
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,12 +5,27 @@
|
|||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
function rulesGetDefaultPermissions(properties)
|
||||
function getDefaultPermissions (properties)
|
||||
local pw_access = properties["pipewire.access"]
|
||||
local media_category = properties["media.category"]
|
||||
|
||||
if pw_access == "flatpak" and media_category == "Manager" then
|
||||
return "all"
|
||||
elseif pw_access == "flatpak" or pw_access == "restricted" then
|
||||
return "rx"
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
function getPermissions (properties)
|
||||
local matched, mprops = Settings.apply_rule ("access.rules", properties)
|
||||
|
||||
if (matched and mprops["default_permissions"]) then
|
||||
return mprops["default_permissions"]
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
clients_om = ObjectManager {
|
||||
|
|
@ -21,9 +36,12 @@ clients_om:connect("object-added", function (om, client)
|
|||
local id = client["bound-id"]
|
||||
local properties = client["properties"]
|
||||
|
||||
local perms = rulesGetDefaultPermissions(properties)
|
||||
local perms = getPermissions (properties)
|
||||
if perms == nil then
|
||||
perms = getDefaultPermissions (properties)
|
||||
end
|
||||
|
||||
if perms then
|
||||
if perms ~= nil then
|
||||
Log.info(client, "Granting permissions to client " .. id .. ": " .. perms)
|
||||
client:update_permissions { ["any"] = perms }
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue