summaryrefslogtreecommitdiffhomepage
path: root/src/ffluci/dispatcher.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/ffluci/dispatcher.lua')
-rw-r--r--src/ffluci/dispatcher.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/ffluci/dispatcher.lua b/src/ffluci/dispatcher.lua
index 139b0e3083..b60a9beefa 100644
--- a/src/ffluci/dispatcher.lua
+++ b/src/ffluci/dispatcher.lua
@@ -84,8 +84,20 @@ limitations under the License.
module("ffluci.dispatcher", package.seeall)
require("ffluci.http")
require("ffluci.template")
+require("ffluci.config")
+require("ffluci.sys")
+-- Sets privilege for given category
+function assign_privileges(category)
+ local cp = ffluci.config.category_privileges
+ if cp and cp[category] then
+ local u, g = cp[category]:match("([^:]+):([^:]+)")
+ ffluci.sys.process.setuser(u)
+ ffluci.sys.process.setgroup(g)
+ end
+end
+
-- Dispatches the "request"
function dispatch(req)
request = req
@@ -137,6 +149,7 @@ function httpdispatch()
local mod = sanitize(parts(), "index")
local act = sanitize(parts(), "index")
+ assign_privileges(cat)
dispatch({category=cat, module=mod, action=act})
end