* reverted changes [996] and [998] for good old logfile download

This commit is contained in:
age 2008-01-15 00:14:19 +00:00
parent 8aa7eaf225
commit 6f05e1d091
5 changed files with 16 additions and 52 deletions

View File

@ -100,8 +100,3 @@ CryptoBoxRootActions = CryptoBoxRootActionsLocal
#[[network]]
#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

View File

@ -8,7 +8,6 @@ Text {
AtLeastWarnings = Show warnings and errors
OnlyErrors = Show errors only
DownloadLogFile = Download complete log
DownloadSysLogFile = Download complete syslog
AgeOfEvent = Time passed
EventText = Description
TimeUnits {

View File

@ -25,7 +25,7 @@
__revision__ = "$Id$"
import cryptobox.plugins.base
import re, os
import re
import datetime
import cherrypy
@ -71,43 +71,14 @@ class logs(cryptobox.plugins.base.CryptoBoxPlugin):
self.__set_line_hdf_data(self.hdf_prefix + "Content.%d" % index, line)
self.hdf[self.hdf_prefix + "Destination"] = \
self.cbox.prefs["Log"]["Destination"].lower()
## this generates more download buttons if the files are available
if "syslogfile" in self.defaults:
try:
syslogfile = self.defaults["syslogfile"]
except KeyError:
self.cbox.log.error("could not evaluate the config setting: "
+ "[logs]->syslogfile")
if syslogfile and os.access(syslogfile, os.R_OK):
self.cbox.log.info("[logs]->syslogfile: '%s' will be exported" % syslogfile)
self.hdf[self.hdf_prefix + "syslogfile"] = "readable"
self.cbox.prefs["Log"]["syslogfile"] = syslogfile
else:
self.cbox.log.warn("[logs]->syslogfile: '%s' is not readable for cryptobox user" % syslogfile)
self.hdf[self.hdf_prefix + "syslogfile"] = "not readable"
return "show_log"
@cherrypy.expose
def download(self, **kargs):
"""Download the complete log file
**kargs are necessary - we have to ignore 'weblang' and so on ...
"""
##TODO: check the download url to know which file is wanted
if self.cbox.prefs["Log"]["syslogfile"]:
try:
syslogfile = self.cbox.prefs["Log"]["syslogfile"]
except KeyError:
self.cbox.log.error("could not evaluate the config setting: "
+ "[logs]->syslogfile %s")
if syslogfile and os.access(syslogfile, os.R_OK):
return cherrypy.lib.cptools.serveFile(syslogfile,
disposition="attachment", name="syslog.txt")
else:
self.cbox.log.error("'%s' could not be exposed" % syslogfile)
log_file = self.__get_log_destination_file()
if log_file is None:
return ""
@ -125,6 +96,15 @@ class logs(cryptobox.plugins.base.CryptoBoxPlugin):
self.cbox.prefs["Log"]["Details"])
def get_status(self):
"""The current status includes the log configuration details.
"""
return "%s:%s:%s" % (
self.cbox.prefs["Log"]["Level"],
self.cbox.prefs["Log"]["Destination"],
self.cbox.prefs["Log"]["Details"])
def __filter_log_content(self, lines, max_size, level):
"""Filter, sort and shorten the log content.
"""

View File

@ -70,14 +70,6 @@
var:html_escape(Lang.Plugins.logs.Text.DownloadLogFile) ?></button>
</p>
</form>
<?cs if:Data.Plugins.logs.syslogfile == "readable" ?>
<?cs call:print_form_header("download-syslog", "downloads/logs/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 ?>
<p style="text-align:center">
<?cs call:hint("Plugins.logs.EmptyLog") ?>

View File

@ -434,8 +434,6 @@ class WebInterfaceSites:
time.sleep(1)
yield "</ul></p></html>"
##################### input checker ##########################
def __check_environment(self):