Commit 1d9e2b88 authored by Marco Mariani's avatar Marco Mariani

whitespace

parent 05abf98d
...@@ -181,15 +181,15 @@ def dropPrivileges(uid, gid, logger): ...@@ -181,15 +181,15 @@ def dropPrivileges(uid, gid, logger):
# twice # twice
current_uid, current_gid = os.getuid(), os.getgid() current_uid, current_gid = os.getuid(), os.getgid()
if uid == 0 or gid == 0: if uid == 0 or gid == 0:
raise OSError('Dropping privileges to uid = %r or ' \ raise OSError('Dropping privileges to uid = %r or '
'gid = %r is too dangerous' % (uid, gid)) 'gid = %r is too dangerous' % (uid, gid))
if current_uid or current_gid: if current_uid or current_gid:
logger.debug('Running as uid = %r, gid = %r, dropping not needed and not ' logger.debug('Running as uid = %r, gid = %r, dropping '
'possible' % (current_uid, current_gid)) 'not needed and not possible' % (current_uid, current_gid))
return return
# drop privileges # drop privileges
user_name = pwd.getpwuid(uid)[0] user_name = pwd.getpwuid(uid)[0]
group_list = set([x.gr_gid for x in grp.getgrall() if user_name in x.gr_mem]) group_list = set(x.gr_gid for x in grp.getgrall() if user_name in x.gr_mem)
group_list.add(gid) group_list.add(gid)
os.initgroups(pwd.getpwuid(uid)[0], gid) os.initgroups(pwd.getpwuid(uid)[0], gid)
os.setgid(gid) os.setgid(gid)
...@@ -253,7 +253,7 @@ def bootstrapBuildout(path, logger, buildout=None, ...@@ -253,7 +253,7 @@ def bootstrapBuildout(path, logger, buildout=None,
else: else:
# buildout is importable, so use this one # buildout is importable, so use this one
invocation_list.extend(["-c", "import sys ; sys.path=" + str(sys.path) + invocation_list.extend(["-c", "import sys ; sys.path=" + str(sys.path) +
" ; import zc.buildout.buildout ; sys.argv[1:1]=" + \ " ; import zc.buildout.buildout ; sys.argv[1:1]=" +
repr(additional_buildout_parametr_list + ['bootstrap']) + " ; " repr(additional_buildout_parametr_list + ['bootstrap']) + " ; "
"zc.buildout.buildout.main()"]) "zc.buildout.buildout.main()"])
...@@ -271,7 +271,7 @@ def bootstrapBuildout(path, logger, buildout=None, ...@@ -271,7 +271,7 @@ def bootstrapBuildout(path, logger, buildout=None,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
logger=logger) logger=logger)
if process_handler.returncode is None or process_handler.returncode != 0: if process_handler.returncode is None or process_handler.returncode != 0:
message = 'Failed to run buildout profile in directory %r' % (path) message = 'Failed to run buildout profile in directory %r' % path
logger.error(message) logger.error(message)
raise BuildoutFailedError('%s:\n%s\n' % (message, process_handler.output)) raise BuildoutFailedError('%s:\n%s\n' % (message, process_handler.output))
except OSError as exc: except OSError as exc:
...@@ -314,7 +314,7 @@ def launchBuildout(path, buildout_binary, logger, ...@@ -314,7 +314,7 @@ def launchBuildout(path, buildout_binary, logger,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
logger=logger) logger=logger)
if process_handler.returncode is None or process_handler.returncode != 0: if process_handler.returncode is None or process_handler.returncode != 0:
message = 'Failed to run buildout profile in directory %r' % (path) message = 'Failed to run buildout profile in directory %r' % path
logger.error(message) logger.error(message)
raise BuildoutFailedError('%s:\n%s\n' % (message, process_handler.output)) raise BuildoutFailedError('%s:\n%s\n' % (message, process_handler.output))
except OSError as exc: except OSError as exc:
...@@ -328,7 +328,7 @@ def updateFile(file_path, content, mode=0o600): ...@@ -328,7 +328,7 @@ def updateFile(file_path, content, mode=0o600):
"""Creates an executable with "content" as content.""" """Creates an executable with "content" as content."""
altered = False altered = False
if not (os.path.isfile(file_path)) or \ if not (os.path.isfile(file_path)) or \
not(hashlib.md5(open(file_path).read()).digest() ==\ not (hashlib.md5(open(file_path).read()).digest() ==
hashlib.md5(content).digest()): hashlib.md5(content).digest()):
with open(file_path, 'w') as fout: with open(file_path, 'w') as fout:
fout.write(content) fout.write(content)
...@@ -352,6 +352,6 @@ def createPrivateDirectory(path): ...@@ -352,6 +352,6 @@ def createPrivateDirectory(path):
os.chmod(path, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC) os.chmod(path, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)
permission = stat.S_IMODE(os.stat(path).st_mode) permission = stat.S_IMODE(os.stat(path).st_mode)
if permission != 0o700: if permission != 0o700:
raise WrongPermissionError('Wrong permissions in %s: ' \ raise WrongPermissionError('Wrong permissions in %s: '
'is 0%o, should be 0700' 'is 0%o, should be 0700'
% (path, permission)) % (path, permission))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment