summaryrefslogtreecommitdiffstats
path: root/lib/modelfunctions.lua
diff options
context:
space:
mode:
authorNathan Angelacos <nangel@tetrasec.net>2008-11-09 00:27:32 +0000
committerNathan Angelacos <nangel@tetrasec.net>2008-11-09 00:27:32 +0000
commit95e743197047cc4c2550563ea8ef323c9b1230fd (patch)
treeef2f16f60fd30b3bdd405a177aa3ff3e3125556e /lib/modelfunctions.lua
parent004f2adfc85bed299c762e019120732fe90d597d (diff)
downloadacf-core-95e743197047cc4c2550563ea8ef323c9b1230fd.tar.bz2
acf-core-95e743197047cc4c2550563ea8ef323c9b1230fd.tar.xz
per-controller auditing now allowed via acf-hooks.lua
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1582 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lib/modelfunctions.lua')
-rw-r--r--lib/modelfunctions.lua34
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/modelfunctions.lua b/lib/modelfunctions.lua
index d94db78..57897ad 100644
--- a/lib/modelfunctions.lua
+++ b/lib/modelfunctions.lua
@@ -106,7 +106,10 @@ function setfiledetails(filedetails, validatefilename, validatefiledetails)
success, filedetails = validatefiledetails(filedetails)
end
if success then
- fs.write_file(filedetails.value.filename.value, filedetails.value.filecontent.value)
+ --fs.write_file(filedetails.value.filename.value, filedetails.value.filecontent.value)
+ -- NBA - FIXME? we pass the global "APP" to write_file_with_audit because it needs self
+ -- is that correct? Is there a better way to do it?
+ write_file_with_audit( APP, filedetails.value.filename.value, filedetails.value.filecontent.value)
filedetails = getfiledetails(filedetails.value.filename.value)
else
filedetails.errtxt = "Failed to set file"
@@ -154,21 +157,38 @@ function write_file_with_audit (self, path, str)
CONFFILE=path
_G.self=self
- pre = format.expand_bash_syntax_vars(self.conf.audit_precommit or "" )
- post = format.expand_bash_syntax_vars(self.conf.audit_postcommit or "")
+ pre = self.conf.audit_precommit or ""
+ post = self.conf.audit_postcommit or ""
+
+ local m = self.conf.app_hooks[self.conf.controller] or {}
+ if m.audit_precommit then pre = m.audit_precommit end
+ if m.audit_postcommit then post = m.audit_postcommit end
+ m=nil
+
+ if (type(pre) == "string") then
+ pre = format.expand_bash_syntax_vars(pre)
+ end
+ if type (post) == "string" then
+ post = format.expand_bash_syntax_vars(post)
+ end
TEMPFILE,CONFFILE,_G.self = a,b,c
end
-
+
fs.write_file(tmpfile,str)
- if #pre then
+ if (type(pre) == "string" and #pre) then
os.execute(pre)
+ elseif (type(pre) == "function") then
+ pre(self, path, tmpfile)
end
os.rename (tmpfile, path)
-
- if #post then
+
+ if (type(post) == "string" and #post) then
os.execute(post)
+ elseif (type(post) == "function") then
+ post(self, path, tmpfile)
end
return
+
end