mirror of
https://github.com/vxcontrol/soldr-modules.git
synced 2026-07-18 18:44:30 -04:00
auditd: refactoring
This commit is contained in:
@@ -24,7 +24,7 @@ local function ensure_audit(pm)
|
||||
return ok, string.format("audit not available: %s", err)
|
||||
end
|
||||
|
||||
--:: pkg.Manager, {managed.File,...} -> ok?, err::string?
|
||||
--:: pkg.Manager, [managed.File] -> ok?, err::string?
|
||||
local function setup(pm, files)
|
||||
return try(function()
|
||||
assert(ensure_audit(pm))
|
||||
|
||||
@@ -16,10 +16,12 @@ end
|
||||
--:: string -> output::string?, err::string?
|
||||
local function exec(cmd)
|
||||
local result, err = try(function()
|
||||
local f = assert(io.popen("exec <&- 2>&1;"..cmd), "io.popen failed")
|
||||
local output = f:read("a") or ""
|
||||
local ok, status, code = f:close()
|
||||
assert(ok, string.format("%s=%d: %s", status, code, show_output(output)))
|
||||
local stdout = assert(
|
||||
io.popen("exec <&- 2>&1;"..cmd), "io.popen failed")
|
||||
local output = stdout:read("a") or ""
|
||||
local ok, status, code = stdout:close()
|
||||
assert(ok,
|
||||
string.format("%s=%d: %s", status, code, show_output(output)))
|
||||
return trim_end(output)
|
||||
end)
|
||||
return result, string.format("exec(%s): %s", cmd, err)
|
||||
|
||||
@@ -18,8 +18,8 @@ if not pm then
|
||||
end
|
||||
|
||||
local function update_config()
|
||||
local c = cjson.decode(__config.get_current_config())
|
||||
event.update_config()
|
||||
local c = cjson.decode(__config.get_current_config())
|
||||
audit.file_auditd_conf:set(c.auditd_conf)
|
||||
audit.file_audit_rules:set(c.audit_rules)
|
||||
watcher:reset(c.check_interval)
|
||||
|
||||
@@ -74,7 +74,7 @@ end
|
||||
-- Calls `ensure` for every item of `list`.
|
||||
-- Returns MODIFIED if any of list returns MODIFIED.
|
||||
-- Immediately returns false if any of list failed.
|
||||
--:: File... -> boolean|MODIFIED, err::string?
|
||||
--:: [File] -> boolean|MODIFIED, err::string?
|
||||
local function ensure_all(list)
|
||||
return try(function()
|
||||
local status = true
|
||||
|
||||
Reference in New Issue
Block a user