diff options
Diffstat (limited to 'buildstream/utils.py')
-rw-r--r-- | buildstream/utils.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/buildstream/utils.py b/buildstream/utils.py index 2960348e9..f4a329210 100644 --- a/buildstream/utils.py +++ b/buildstream/utils.py @@ -1307,3 +1307,18 @@ def _with_gc_disabled(func): # used by other objects during the course of running BuildStream. gc.collect() return _gc_disabled + + +# _deterministic_umask() +# +# Context managed to apply a umask to a section that may be affected by a users +# umask. Restores old mask afterwards. +# +@contextmanager +def _deterministic_umask(): + old_umask = os.umask(0o022) + + try: + yield + finally: + os.umask(old_umask) |