summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--syslog-basic-html.lsp47
-rw-r--r--syslog-controller.lua39
-rw-r--r--syslog-model.lua44
-rw-r--r--syslog.menu2
5 files changed, 136 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index c476d95..8bda23b 100644
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,10 @@ APP_DIST=hostname-controller.lua \
logfiles-delete-html.lsp \
logfiles-view-html.lsp \
logfiles-download-html.lsp \
+ syslog.menu \
+ syslog-controller.lua \
+ syslog-model.lua \
+ syslog-basic-html.lsp \
template-logfiles-download-html.lsp
EXTRA_DIST=README Makefile config.mk
diff --git a/syslog-basic-html.lsp b/syslog-basic-html.lsp
new file mode 100644
index 0000000..0e5cab3
--- /dev/null
+++ b/syslog-basic-html.lsp
@@ -0,0 +1,47 @@
+<? ctl = ... ?>
+<h1>System logging</h1>
+<form>
+<p>
+<input type="radio" name="status" value="enabled" <?= ctl.enabled ?>/>
+Enable
+</p>
+<p>
+<input type="radio" name="status" value="disabled" <?= ctl.disabled ?>/>
+Disable
+</p>
+
+<p>
+<input type="checkbox" name="remote" <?= ctl.remote ?>/>
+Enable remote logging
+</p>
+
+<p>
+Remote host: <input type="text" value="<?= ctl.host ?>" name="host"/>
+</p>
+
+<p>
+<br/>
+<input type="submit" value="Apply"/>
+</p>
+<!-- DEBUG:
+
+<?
+for k,v in pairs(ctl) do
+ io.write(k..": "..tostring(v).."\n")
+end
+
+if ctl.pidlist then
+ io.write("pidlist:\n")
+ for k,v in pairs(ctl.pidlist) do
+ io.write(k..": "..tostring(v).."\n")
+ end
+end
+if ctl.opts then
+ io.write("opts:\n")
+ for k,v in pairs(ctl.opts) do
+ io.write(k..": "..tostring(v).."\n")
+ end
+end
+?>
+-->
+</form>
diff --git a/syslog-controller.lua b/syslog-controller.lua
new file mode 100644
index 0000000..be3e322
--- /dev/null
+++ b/syslog-controller.lua
@@ -0,0 +1,39 @@
+
+module(..., package.seeall)
+
+require("privsep")
+require("join")
+
+-- those should go into acf.conf
+local user="nobody"
+local group="nobody"
+
+-- drop privileges and put privileged model funcs in self.priv
+mvc = {}
+function mvc.on_load(self)
+ self.priv = privsep.drop_privs(user, group, self.model.priv)
+end
+
+function basic(self)
+ local ctl = {}
+ local opts = self.model.readopts()
+ ctl.pidlist = self.priv.is_enabled()
+ if pidlist then
+ ctl.enabled = "checked=yes"
+ ctl.disabled = ""
+ else
+ ctl.enabled = ""
+ ctl.disabled = "checked=yes"
+ end
+ ctl.opts = opts
+ if opts and opts.remote then
+ ctl.remote = "checked"
+ ctl.host = opts.remote
+ else
+ ctl.remote = ""
+ ctl.host = ""
+ end
+ ctl.debug="opts="..tostring(opts)
+
+ return ctl
+end
diff --git a/syslog-model.lua b/syslog-model.lua
new file mode 100644
index 0000000..7391cfe
--- /dev/null
+++ b/syslog-model.lua
@@ -0,0 +1,44 @@
+module(..., package.seeall)
+
+require("pidof")
+require("split")
+
+-- we actually need root permissions to get the process list
+priv = {}
+function priv.is_enabled()
+ return (pidof.pidof("syslogd"))
+end
+
+function priv.enable(opts)
+ if opts and opts.remote then
+ local f = io.open("/etc/conf.d/syslog", "w")
+ if f == nil then
+ return nil
+ end
+ f:write("# this file was written by and will be overwritten by acf\n")
+ f:write("SYSLOGD_OPTS=\"-R "..opts.remote.."\"")
+ f:close()
+ end
+ os.system("/etc/init.d/syslogd restart; rc_add -k -s 20 syslog")
+end
+
+
+-- this func does not need privileges
+function readopts()
+ local opts = {}
+ local line
+ local f = io.open("/etc/conf.d/syslog", "r")
+ if f == nil then
+ return nil
+ end
+ for line in f:lines() do
+ local optstr = string.match(line, "^SYSLOGD_OPTS=\"?(.*)\"?")
+ if optstr then
+ opts.remote = string.match(optstr, "-R%s*(.*)%s*.*$")
+ opts.optstr = optstr
+ end
+ end
+ return opts
+end
+
+
diff --git a/syslog.menu b/syslog.menu
new file mode 100644
index 0000000..c600d6d
--- /dev/null
+++ b/syslog.menu
@@ -0,0 +1,2 @@
+#CAT GROUP/DESC TAB ACTION
+System System_Logging basic basic