summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2018-08-06 17:19:55 +0200
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-08-12 05:54:36 +0000
commit322cab58e255916da10e0a59ae91e92f50898504 (patch)
tree674c41825ba2909196f4f5fd30d6217a3816016d
parentccf6e479df23c2f28ea56f237459d32086af1406 (diff)
downloadbuildstream-322cab58e255916da10e0a59ae91e92f50898504.tar.gz
Use deterministic umask when staging sources.
This fix is applied to plugins bzr, git, patch. Fixes #543 #544 #555.
-rw-r--r--buildstream/utils.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/buildstream/utils.py b/buildstream/utils.py
index 93ab6fb0e..149ee7b90 100644
--- a/buildstream/utils.py
+++ b/buildstream/utils.py
@@ -1010,6 +1010,15 @@ def _call(*popenargs, terminate=False, **kwargs):
process = None
+ old_preexec_fn = kwargs.get('preexec_fn')
+ if 'preexec_fn' in kwargs:
+ del kwargs['preexec_fn']
+
+ def preexec_fn():
+ os.umask(stat.S_IWGRP | stat.S_IWOTH)
+ if old_preexec_fn is not None:
+ old_preexec_fn()
+
# Handle termination, suspend and resume
def kill_proc():
if process:
@@ -1054,7 +1063,7 @@ def _call(*popenargs, terminate=False, **kwargs):
os.killpg(group_id, signal.SIGCONT)
with _signals.suspendable(suspend_proc, resume_proc), _signals.terminator(kill_proc):
- process = subprocess.Popen(*popenargs, **kwargs)
+ process = subprocess.Popen(*popenargs, preexec_fn=preexec_fn, **kwargs)
output, _ = process.communicate()
exit_code = process.poll()