auditd: refactoring

This commit is contained in:
Aleksey Nikitin
2023-02-05 21:13:52 +03:00
parent 69886543bb
commit 2445f9bb0c
4 changed files with 9 additions and 7 deletions
+1 -1
View File
@@ -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))
+6 -4
View File
@@ -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)
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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