* logs plugin prepares download button for syslogfile, activate in configfile
This commit is contained in:
parent
d2d974c18b
commit
91f54ffa66
|
@ -99,3 +99,8 @@ CryptoBoxRootActions = CryptoBoxRootActionsLocal
|
||||||
#[[network]]
|
#[[network]]
|
||||||
#interface = eth0
|
#interface = eth0
|
||||||
|
|
||||||
|
## Uncomment the following lines to enable downloads of system
|
||||||
|
## logfiles via frontend. Make sure they are readable for the uid the
|
||||||
|
## cryptobox server runs with.
|
||||||
|
#[[logs]]
|
||||||
|
#syslogfile = /var/log/syslog
|
||||||
|
|
|
@ -8,6 +8,7 @@ Text {
|
||||||
AtLeastWarnings = Show warnings and errors
|
AtLeastWarnings = Show warnings and errors
|
||||||
OnlyErrors = Show errors only
|
OnlyErrors = Show errors only
|
||||||
DownloadLogFile = Download complete log
|
DownloadLogFile = Download complete log
|
||||||
|
DownloadSysLogFile = Download complete syslog
|
||||||
AgeOfEvent = Time passed
|
AgeOfEvent = Time passed
|
||||||
EventText = Description
|
EventText = Description
|
||||||
TimeUnits {
|
TimeUnits {
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import cryptobox.plugins.base
|
import cryptobox.plugins.base
|
||||||
import re
|
import re, os
|
||||||
import datetime
|
import datetime
|
||||||
import cherrypy
|
import cherrypy
|
||||||
|
|
||||||
|
@ -71,6 +71,20 @@ class logs(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||||
self.__set_line_hdf_data(self.hdf_prefix + "Content.%d" % index, line)
|
self.__set_line_hdf_data(self.hdf_prefix + "Content.%d" % index, line)
|
||||||
self.hdf[self.hdf_prefix + "Destination"] = \
|
self.hdf[self.hdf_prefix + "Destination"] = \
|
||||||
self.cbox.prefs["Log"]["Destination"].lower()
|
self.cbox.prefs["Log"]["Destination"].lower()
|
||||||
|
|
||||||
|
## this generates more download buttons if the files are available
|
||||||
|
try:
|
||||||
|
syslogfile = self.defaults["syslogfile"].lower()
|
||||||
|
if os.access(syslogfile, os.R_OK):
|
||||||
|
self.cbox.log.info("[logs]->syslogfile: '%s' will be exported" % syslogfile)
|
||||||
|
self.hdf[self.hdf_prefix + "syslogfile"] = "readable"
|
||||||
|
else:
|
||||||
|
self.cbox.log.warn("[logs]->syslogfile: '%s' is not readable for cryptobox user" % syslogfile)
|
||||||
|
self.hdf[self.hdf_prefix + "syslogfile"] = "not readable"
|
||||||
|
except KeyError:
|
||||||
|
self.cbox.log.error(
|
||||||
|
"could not evaluate the config setting: "
|
||||||
|
+ "[logs]->syslogfile")
|
||||||
return "show_log"
|
return "show_log"
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,7 +101,6 @@ class logs(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||||
return cherrypy.lib.cptools.serveFile(log_file,
|
return cherrypy.lib.cptools.serveFile(log_file,
|
||||||
disposition="attachment", name="cryptobox_logfile.txt")
|
disposition="attachment", name="cryptobox_logfile.txt")
|
||||||
|
|
||||||
|
|
||||||
def get_status(self):
|
def get_status(self):
|
||||||
"""The current status includes the log configuration details.
|
"""The current status includes the log configuration details.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -66,10 +66,18 @@
|
||||||
</table>
|
</table>
|
||||||
<?cs call:print_form_header("download-log", "downloads/logs") ?>
|
<?cs call:print_form_header("download-log", "downloads/logs") ?>
|
||||||
<p style="text-align:center">
|
<p style="text-align:center">
|
||||||
<button type="submit" value="refresh"><?cs
|
<button type="submit" value="refresh"><?cs
|
||||||
var:html_escape(Lang.Plugins.logs.Text.DownloadLogFile) ?></button>
|
var:html_escape(Lang.Plugins.logs.Text.DownloadLogFile) ?></button>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
<?cs if:Data.Plugins.logs.syslogfile == "readable" ?>
|
||||||
|
<?cs call:print_form_header("download-syslog", "syslog") ?>
|
||||||
|
<p style="text-align:center">
|
||||||
|
<button type="submit" value="refresh"><?cs
|
||||||
|
var:html_escape(Lang.Plugins.logs.Text.DownloadSysLogFile) ?></button>
|
||||||
|
</p>
|
||||||
|
</form><?cs
|
||||||
|
/if ?>
|
||||||
<?cs else ?>
|
<?cs else ?>
|
||||||
<p style="text-align:center">
|
<p style="text-align:center">
|
||||||
<?cs call:hint("Plugins.logs.EmptyLog") ?>
|
<?cs call:hint("Plugins.logs.EmptyLog") ?>
|
||||||
|
|
|
@ -434,7 +434,22 @@ class WebInterfaceSites:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
yield "</ul></p></html>"
|
yield "</ul></p></html>"
|
||||||
|
|
||||||
|
@cherrypy.expose
|
||||||
|
def syslog(self, weblang="", help="0", device=None):
|
||||||
|
"""export syslog
|
||||||
|
"""
|
||||||
|
from cherrypy.lib.cptools import serveFile
|
||||||
|
try:
|
||||||
|
syslogfile = self.cbox.prefs["PluginSettings"]["logs"]["syslogfile"]
|
||||||
|
if os.access(syslogfile, os.R_OK):
|
||||||
|
return serveFile(syslogfile, disposition="attachment", name="syslog")
|
||||||
|
else:
|
||||||
|
self.cbox.log.error("'%s' could not be exposed" % syslogfile)
|
||||||
|
except KeyError:
|
||||||
|
self.cbox.log.error(
|
||||||
|
"could not evaluate the config setting: "
|
||||||
|
+ "[logs]->syslogfile %s")
|
||||||
|
|
||||||
|
|
||||||
##################### input checker ##########################
|
##################### input checker ##########################
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue