Commit c8177767 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

slapgrid: fix invocation of bootstrapBuildout

This commit reverts ddd77222.

as stated in
slapos.buildout!25 (comment 149333)
we should never overwrite os.environ variable (because os.environ is a
mapping object so overwriting it remove the mapping functionality, see
https://docs.python.org/3/library/os.html#os.environ)

Instead change the environment only when calling SlapPopen
parent b562062f
......@@ -266,9 +266,6 @@ class Software(object):
""" Fetches buildout configuration from the server, run buildout with
it. If it fails, we notify the server.
"""
root_stat = os.stat(self.software_root)
os.environ = getCleanEnvironment(logger=self.logger,
home_path=pwd.getpwuid(root_stat.st_uid).pw_dir)
try:
os.mkdir(self.software_path)
except OSError as e:
......@@ -604,8 +601,6 @@ class Partition(object):
'permissions are: 0%o, wanted are 0%o' %
(self.instance_path, permission,
REQUIRED_COMPUTER_PARTITION_PERMISSION))
os.environ = getCleanEnvironment(logger=self.logger,
home_path=pwd.getpwuid(instance_stat_info.st_uid).pw_dir)
# Check that Software Release directory is present
if not os.path.exists(self.software_path):
......
......@@ -341,6 +341,8 @@ def bootstrapBuildout(path, logger, buildout=None,
process_handler = SlapPopen(invocation_list,
preexec_fn=lambda: dropPrivileges(uid, gid, logger=logger),
cwd=path,
env=getCleanEnvironment(logger,
home_path=pwd.getpwuid(os.stat(path).st_uid).pw_dir),
logger=logger)
if process_handler.returncode is None or process_handler.returncode != 0:
message = 'Failed to run buildout profile in directory %r' % path
......
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