added mounting and unmounting of config partition

moved config partition handling to CryptoBoxSettings
implemented environment checks (writeable config, https (off for now))
chown mounted directory after mount to the cryptobox user
This commit is contained in:
lars 2006-11-03 14:27:19 +00:00
parent 2c350207c9
commit 0fe6d426ed
5 changed files with 180 additions and 66 deletions

View file

@ -5,6 +5,16 @@ import Plugins
from CryptoBoxExceptions import *
import cherrypy
import types
import os
try:
import neo_cgi, neo_util, neo_cs
except ImportError:
errorMsg = "Could not import clearsilver module. Try 'apt-get install python-clearsilver'."
self.log.error(errorMsg)
sys.stderr.write(errorMsg)
raise ImportError, errorMsg
class WebInterfacePlugins:
@ -115,6 +125,7 @@ class WebInterfaceSites:
def index(self, weblang=""):
self.__resetDataset()
self.__setWebLang(weblang)
self.__checkEnvironment()
## do not forget the language!
param_dict = {"weblang":weblang}
## render "disks" plugin by default
@ -124,6 +135,7 @@ class WebInterfaceSites:
def return_plugin_action(self, plugin):
def handler(self, **args):
self.__resetDataset()
self.__checkEnvironment()
args_orig = dict(args)
try:
self.__setWebLang(args["weblang"])
@ -180,6 +192,7 @@ class WebInterfaceSites:
def test(self, weblang=""):
self.__resetDataset()
self.__setWebLang(weblang)
self.__checkEnvironment()
return "test passed"
@ -197,6 +210,36 @@ class WebInterfaceSites:
##################### input checker ##########################
def __checkEnvironment(self):
"""here we should place all interesting checks to inform the user of problems
examples are: non-https, readonly-config, ...
"""
if not self.cbox.prefs.isWriteable():
self.dataset["Data.EnvironmentWarning"] = "ReadOnlyConfig"
# TODO: turn this on soon (add "not") - for now it is annoying
if self.__checkHTTPS():
self.dataset["Data.EnvironmentWarning"] = "NoSSL"
def __checkHTTPS(self):
## check the request scheme
if cherrypy.request.scheme == "https": return True
## check an environment setting - this is quite common behind proxies
try:
if os.environ["HTTPS"]: return True
except KeyError:
pass
## check http header TODO (check pound for the name)
try:
if cherrypy.request.headers["TODO"]: return True
except KeyError:
pass
## the connection seems to be unencrypted
return False
def __setWebLang(self, value):
guess = value
availLangs = self.cbox.getAvailableLanguages()
@ -229,7 +272,6 @@ class WebInterfaceSites:
"""guess the preferred language of the user (as sent by the browser)
take the first language, that is part of 'availLangs'
"""
import cherrypy
try:
pref_lang_header = cherrypy.request.headers["Accept-Language"]
except KeyError:
@ -277,7 +319,6 @@ class WebInterfaceSites:
def __getLanguageData(self, web_lang="en"):
import neo_cgi, neo_util, os
default_lang = "en"
conf_lang = self.prefs["WebSettings"]["Language"]
hdf = neo_util.HDF()
@ -302,15 +343,6 @@ class WebInterfaceSites:
def __render(self, renderInfo, plugin=None):
'''renders from clearsilver templates and returns the resulting html
'''
import os, types
try:
import neo_cgi, neo_util, neo_cs
except ImportError:
errorMsg = "Could not import clearsilver module. Try 'apt-get install python-clearsilver'."
self.log.error(errorMsg)
sys.stderr.write(errorMsg)
raise ImportError, errorMsg
## is renderInfo a string (filename of the template) or a dictionary?
if type(renderInfo) == types.DictType:
template = renderInfo["template"]