From 8e14e610cb2cc21eb05808074036a7bf8edaa3c1 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Fri, 30 Oct 2015 15:14:11 +0000 Subject: Modify logfile to get logging info from the config and use common view --- ipsectools-controller.lua | 4 ++++ ipsectools-logfile-html.lsp | 7 +------ ipsectools-model.lua | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) mode change 100644 => 120000 ipsectools-logfile-html.lsp diff --git a/ipsectools-controller.lua b/ipsectools-controller.lua index 85bcab6..e5f183c 100644 --- a/ipsectools-controller.lua +++ b/ipsectools-controller.lua @@ -38,4 +38,8 @@ function mymodule.viewcert(self) return self.handle_form(self, self.model.get_view_cert, self.model.view_cert, self.clientdata, "View", "View Certificate") end +function mymodule.logfile(self) + return self.model.get_logfile(self, self.clientdata) +end + return mymodule diff --git a/ipsectools-logfile-html.lsp b/ipsectools-logfile-html.lsp deleted file mode 100644 index 5b2cd47..0000000 --- a/ipsectools-logfile-html.lsp +++ /dev/null @@ -1,6 +0,0 @@ -<% local data, viewlibrary = ... -%> - -<% if viewlibrary and viewlibrary.dispatch_component then - viewlibrary.dispatch_component("alpine-baselayout/logfiles/view", {filename="/var/log/messages", grep="racoon"}) -end %> diff --git a/ipsectools-logfile-html.lsp b/ipsectools-logfile-html.lsp new file mode 120000 index 0000000..ac8854f --- /dev/null +++ b/ipsectools-logfile-html.lsp @@ -0,0 +1 @@ +../logfile-html.lsp \ No newline at end of file diff --git a/ipsectools-model.lua b/ipsectools-model.lua index 5af6556..e3e7c99 100644 --- a/ipsectools-model.lua +++ b/ipsectools-model.lua @@ -8,6 +8,7 @@ format = require("acf.format") validator = require("acf.validator") -- Set variables +local confdfile = "/etc/conf.d/racoon" local configfile = "/etc/racoon/racoon.conf" local configfile2 = "/etc/ipsec.conf" local processname = "racoon" @@ -271,4 +272,25 @@ mymodule.view_cert = function(self, viewcert) return viewcert end +function mymodule.get_logfile(self, clientdata) + -- Can override syslog with logfile specified in command-line options "-l logfile" + -- Otherwise, uses syslog with facility LOG_DAEMON + local retval = cfe({ type="group", value={}, label="Log File Configuration" }) + retval.value.facility = cfe({value="daemon", label="Syslog Facility"}) + retval.value.grep = cfe({ value="racoon", label="Grep" }) + local opts = format.parse_ini_file(fs.read_file(confdfile), "", "RACOON_OPTS") + if opts then + -- remove quotes + local opts2 = string.match(opts, "\"(.*)\"") + local opts = " "..(opts2 or "") + local logfile = string.match(opts, "%s%-l%s+(%S+)") + if logfile then + retval.value.filename = cfe({value=logfile, label="File name"}) + retval.value.facility = nil + retval.value.grep = nil + end + end + return retval +end + return mymodule -- cgit v1.2.3