* reverted changes [996] and [998] for good old logfile download
This commit is contained in:
parent
8aa7eaf225
commit
6f05e1d091
|
@ -100,8 +100,3 @@ 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,7 +8,6 @@ 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, os
|
import re
|
||||||
import datetime
|
import datetime
|
||||||
import cherrypy
|
import cherrypy
|
||||||
|
|
||||||
|
@ -69,52 +69,32 @@ class logs(cryptobox.plugins.base.CryptoBoxPlugin):
|
||||||
level = None
|
level = None
|
||||||
for (index, line) in enumerate(self.__filter_log_content(lines, size, level)):
|
for (index, line) in enumerate(self.__filter_log_content(lines, size, level)):
|
||||||
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
|
|
||||||
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"
|
return "show_log"
|
||||||
|
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def download(self, **kargs):
|
def download(self, **kargs):
|
||||||
"""Download the complete log file
|
"""Download the complete log file
|
||||||
|
|
||||||
**kargs are necessary - we have to ignore 'weblang' and so on ...
|
**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()
|
log_file = self.__get_log_destination_file()
|
||||||
if log_file is None:
|
if log_file is None:
|
||||||
return ""
|
return ""
|
||||||
else:
|
else:
|
||||||
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):
|
||||||
|
"""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 get_status(self):
|
def get_status(self):
|
||||||
"""The current status includes the log configuration details.
|
"""The current status includes the log configuration details.
|
||||||
|
|
|
@ -66,18 +66,10 @@
|
||||||
</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", "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 ?>
|
<?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,9 +434,7 @@ class WebInterfaceSites:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
yield "</ul></p></html>"
|
yield "</ul></p></html>"
|
||||||
|
|
||||||
|
##################### input checker ##########################
|
||||||
|
|
||||||
##################### input checker ##########################
|
|
||||||
|
|
||||||
def __check_environment(self):
|
def __check_environment(self):
|
||||||
"""inform the user of suspicious environmental problems
|
"""inform the user of suspicious environmental problems
|
||||||
|
|
Loading…
Reference in New Issue