From a6a3dfaf765d825088ee19a7747c3ed88098382b Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: May 09 2016 12:35:40 +0000 Subject: install: server-install: abort installation on permission issue Abort installation if we do not have permissions to open the install log for writing. We use an environment variable to get the location to log the install output to, since at the time the logging is initialized, the arguments to ipsilon-server-install have not yet been parsed. Fixes: #207 Signed-off-by: Patrick Uiterwijk Reviewed-by: Pierre-Yves Chibon --- diff --git a/ipsilon/install/ipsilon-server-install b/ipsilon/install/ipsilon-server-install index d351f4a..2559357 100755 --- a/ipsilon/install/ipsilon-server-install +++ b/ipsilon/install/ipsilon-server-install @@ -41,7 +41,7 @@ class ConfigurationError(StandardError): cherrypy.log.screen = False # Regular logging -LOGFILE = '/var/log/ipsilon-install.log' +LOGFILE = os.environ.get('LOGFILE', '/var/log/ipsilon-install.log') logger = logging.getLogger() @@ -57,8 +57,7 @@ def openlogs(): try: lh = logging.FileHandler(LOGFILE) except IOError, e: - print >> sys.stderr, 'Unable to open %s (%s)' % (LOGFILE, str(e)) - lh = logging.StreamHandler(sys.stderr) + sys.exit('Unable to open %s (%s)' % (LOGFILE, str(e))) formatter = logging.Formatter('[%(asctime)s] %(message)s') lh.setFormatter(formatter) lh.setLevel(logging.DEBUG) diff --git a/tests/helpers/common.py b/tests/helpers/common.py index e06dcb2..5e17952 100755 --- a/tests/helpers/common.py +++ b/tests/helpers/common.py @@ -207,6 +207,11 @@ basicConstraints = CA:false""" % {'certdir': os.path.join(self.testdir, def setup_idp_server(self, profile, name, addr, port, env): http_conf_file = self.setup_http(name, addr, port) + logfile = os.path.join(self.testdir, name, 'logs', 'install.log') + if env: + env['LOGFILE'] = logfile + else: + env = {'LOGFILE': logfile} cmd = [os.path.join(self.rootdir, 'ipsilon/install/ipsilon-server-install'), '--config-profile=%s' % profile]