From 1a389072417e154adea4ac5e30db7216c31479c2 Mon Sep 17 00:00:00 2001 From: Ferry Boender Date: Wed, 12 Aug 2015 08:17:00 +0200 Subject: [PATCH] Code quality. --- src/runscript.py | 6 ++++-- src/webapp.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/runscript.py b/src/runscript.py index e57550d..37660f6 100644 --- a/src/runscript.py +++ b/src/runscript.py @@ -12,6 +12,7 @@ import subprocess log = logging.getLogger('RUNSCRIPT') + def run_as(uid, gid, groups): """Closure that changes the current running user and groups. Called before executing scripts by Subprocess.""" @@ -22,6 +23,7 @@ def run_as(uid, gid, groups): os.setuid(uid) return set_acc + def run_script(form_def, form_values, stdout=None, stderr=None): """ Perform a callback for the form `form_def`. This calls a script. @@ -60,12 +62,12 @@ def run_script(form_def, form_values, stdout=None, stderr=None): msg = "Running script as user={0}, gid={1}, groups={2}" run_as_fn = run_as(runas_pw.pw_uid, runas_pw.pw_gid, groups) log.info(msg.format(runas_pw.pw_name, runas_gr.gr_name, - str(groups))) + str(groups))) else: run_as_fn = None if form_def.run_as is not None: log.critical("Not running as root, so we can't run the " - "script as user '{0}'".format(form_def.run_as)) + "script as user '{0}'".format(form_def.run_as)) # If the form output type is 'raw', we directly stream the output to # the browser. Otherwise we store it for later displaying. diff --git a/src/webapp.py b/src/webapp.py index 604b03b..255f259 100644 --- a/src/webapp.py +++ b/src/webapp.py @@ -420,7 +420,7 @@ class ScriptFormWebApp(RequestHandler): form_def = form_config.get_form_def(form_name) result = runscript.run_script(form_def, form_values, self.wfile, - self.wfile) + self.wfile) if form_def.output != 'raw': # Ignore everything if we're doing raw output, since it's the # scripts responsibility.