Browse Source

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

master
age 14 years ago
parent
commit
6f05e1d091
  1. 5
      bin/cryptobox.conf
  2. 1
      plugins/logs/language.hdf
  3. 46
      plugins/logs/logs.py
  4. 12
      plugins/logs/show_log.cs
  5. 4
      src/cryptobox/web/sites.py

5
bin/cryptobox.conf

@ -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

1
plugins/logs/language.hdf

@ -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 {

46
plugins/logs/logs.py

@ -25,7 +25,7 @@
__revision__ = "$Id$"
import cryptobox.plugins.base
import re, os
import re
import datetime
import cherrypy
@ -69,52 +69,32 @@ class logs(cryptobox.plugins.base.CryptoBoxPlugin):
level = None
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.hdf[self.hdf_prefix + "Destination"] = \
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 ""
else:
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):
"""The current status includes the log configuration details.

12
plugins/logs/show_log.cs

@ -66,18 +66,10 @@
</table>
<?cs call:print_form_header("download-log", "downloads/logs") ?>
<p style="text-align:center">
<button type="submit" value="refresh"><?cs
var:html_escape(Lang.Plugins.logs.Text.DownloadLogFile) ?></button>
<button type="submit" value="refresh"><?cs
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") ?>

4
src/cryptobox/web/sites.py

@ -434,9 +434,7 @@ class WebInterfaceSites:
time.sleep(1)
yield "</ul></p></html>"
##################### input checker ##########################
##################### input checker ##########################
def __check_environment(self):
"""inform the user of suspicious environmental problems

Loading…
Cancel
Save