diff options
author | Nathan Angelacos <nangel@tetrasec.net> | 2008-11-09 01:16:41 +0000 |
---|---|---|
committer | Nathan Angelacos <nangel@tetrasec.net> | 2008-11-09 01:16:41 +0000 |
commit | 46dcaec8888f7dfbda43852d3f1a5c94c9b1ac54 (patch) | |
tree | 87c4618d4aa434fe791df8f7475fbd5982e0e3bb | |
parent | 95e743197047cc4c2550563ea8ef323c9b1230fd (diff) | |
download | acf-core-46dcaec8888f7dfbda43852d3f1a5c94c9b1ac54.tar.bz2 acf-core-46dcaec8888f7dfbda43852d3f1a5c94c9b1ac54.tar.xz |
annotated acf-hooks.lua
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1583 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | acf-hooks.lua | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/acf-hooks.lua b/acf-hooks.lua index 203733a..41119bf 100644 --- a/acf-hooks.lua +++ b/acf-hooks.lua @@ -1,15 +1,42 @@ --- This file is loaded into self.conf.app_hooks as lua source code --- The purpose is to add user-specified hooks into the acf code - +-- +-- This file is loaded into self.conf.app_hooks using loadfile; +-- it must be correct lua source code. +-- The current format for this file is a table for each controller, +-- and then values (or tables) under the controller. +-- +-- The purpose of this file is to add user-specified hooks into the +-- acf code. +-- +-- Currently the only use for this is a per-controller audit function +-- (this overrides the acf.conf audit_precommit / postcommit globals) +-- +-- audit_precommit | audit_postcommit can be strings (like in acf.conf) -- or functions. For functions, three variables are passed: -- self, CONFFILE, and TEMPFILE ---[[ This is commented out example code.. +-- Example of a general logging function +local precommit=function(self, conf, temp) + local logfile = "/var/log/acf-" .. self.conf.controller .. ".log" + fs.write_line_file (logfile, "#---- BEGIN TRANSACTION - " .. + os.date() .. "\n" .. self.sessiondata.userinfo.userid .. + " modifed " .. conf .. " as follows:") + os.execute ("diff -u " .. conf .. " " .. temp .. " >>" .. logfile) + fs.write_line_file (logfile, "\n#---- END TRANSACTION -") + end + + -tinydns={ - audit_precommit = function (self, CONFFILE, TEMPFILE) - os.execute("echo this is tinydns's precommit command >> /var/log/acf.log") +interfaces = { + -- note that we must define the audit command as a + -- new function to wrap the local func: + audit_precommit=function(self,conf,temp) + precommit(self, conf, temp) end - audit_postcommit = "echo 'this is the tinydns postcommit command.' >>/var/log/acf.log " + +-- audit_postcommit = [[ echo "this is tinydns's postcommit command." >>/var/log/acf.log ]] } -]]-- + +-- but after defining the audit_* commands as direct functions, +-- assining other controllers to be the same is fine... +tinydns=interfaces + |