Commit a224be6c authored by Julien Muchembled's avatar Julien Muchembled

grid: always check ownership of software path before building

When reinstalling a computer, 'node software' may run before
'node format' has created users, then it fails because it can't set
ownership of the directory it created. The directory already exists
on next runs and before this commit, it didn't fix the ownership.
parent 3eddb0a4
...@@ -251,10 +251,14 @@ class Software(object): ...@@ -251,10 +251,14 @@ class Software(object):
root_stat = os.stat(self.software_root) root_stat = os.stat(self.software_root)
os.environ = getCleanEnvironment(logger=self.logger, os.environ = getCleanEnvironment(logger=self.logger,
home_path=pwd.getpwuid(root_stat.st_uid).pw_dir) home_path=pwd.getpwuid(root_stat.st_uid).pw_dir)
if not os.path.isdir(self.software_path): try:
os.mkdir(self.software_path) os.mkdir(self.software_path)
self._set_ownership(self.software_path) except OSError as e:
if e.errno != errno.EEXIST:
raise
else:
os.chmod(self.software_path, 0o755) os.chmod(self.software_path, 0o755)
self._set_ownership(self.software_path)
extends_cache = tempfile.mkdtemp() extends_cache = tempfile.mkdtemp()
self._set_ownership(extends_cache) self._set_ownership(extends_cache)
......
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