Commit 1373281a authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

slapgrid: run promise with clean environment

This fixes bug https://project.nexedi.net/#/bug_module/20210603-1C66F4F
parent 19151e03
...@@ -43,6 +43,7 @@ import json ...@@ -43,6 +43,7 @@ import json
import shutil import shutil
import six import six
import errno import errno
import pwd
if six.PY3: if six.PY3:
import subprocess import subprocess
...@@ -73,7 +74,8 @@ from slapos.grid.svcbackend import (launchSupervisord, ...@@ -73,7 +74,8 @@ from slapos.grid.svcbackend import (launchSupervisord,
from slapos.grid.utils import (md5digest, from slapos.grid.utils import (md5digest,
dropPrivileges, dropPrivileges,
SlapPopen, SlapPopen,
updateFile) updateFile,
getCleanEnvironment)
from slapos.grid.promise import PromiseLauncher, PromiseError from slapos.grid.promise import PromiseLauncher, PromiseError
from slapos.grid.promise.generic import PROMISE_LOG_FOLDER_NAME from slapos.grid.promise.generic import PROMISE_LOG_FOLDER_NAME
from slapos.human import human2bytes from slapos.human import human2bytes
...@@ -754,6 +756,8 @@ stderr_logfile_backups=1 ...@@ -754,6 +756,8 @@ stderr_logfile_backups=1
command, command,
preexec_fn=preexec_fn, preexec_fn=preexec_fn,
cwd=instance_path, cwd=instance_path,
env=getCleanEnvironment(self.logger,
home_path=pwd.getpwuid(uid).pw_dir),
universal_newlines=True, universal_newlines=True,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
...@@ -1694,7 +1698,8 @@ stderr_logfile_backups=1 ...@@ -1694,7 +1698,8 @@ stderr_logfile_backups=1
process_handler = SlapPopen(invocation_list, process_handler = SlapPopen(invocation_list,
preexec_fn=lambda: dropPrivileges(uid, gid, logger=self.logger), preexec_fn=lambda: dropPrivileges(uid, gid, logger=self.logger),
cwd=os.path.join(instance_path, 'etc', 'report'), cwd=os.path.join(instance_path, 'etc', 'report'),
env=None, env=getCleanEnvironment(self.logger,
home_path=pwd.getpwuid(uid).pw_dir),
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
logger=self.logger) logger=self.logger)
......
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