Commit 9f8210c8 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

slapgrid: fix invocation of bootstrapBuildout

This commit reverts ddd77222.

The goal is to fix nexedi/slapos.buildout!25 (comment 148861)

os.environ is a special mapping object that transparently modifies the
actual environment and we should never make os.environ make point to
something else (see
nexedi/slapos.buildout!25 (comment 149333)
and https://docs.python.org/3/library/os.html#os.environ)

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