You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:35:55 UTC

[buildstream] 01/01: _process_list: Make files readable before copying/linking

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch jmac/vdir_import_unreadable_files
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit c8677af0a175438926c1f7d163d05acbff261837
Author: Jim MacArthur <ji...@codethink.co.uk>
AuthorDate: Fri Sep 28 17:57:27 2018 +0100

    _process_list: Make files readable before copying/linking
---
 buildstream/utils.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/buildstream/utils.py b/buildstream/utils.py
index 1e04a31..28ba0fb 100644
--- a/buildstream/utils.py
+++ b/buildstream/utils.py
@@ -831,8 +831,18 @@ def _process_list(srcdir, destdir, filelist, actionfunc, result,
                 result.ignored.append(path)
                 continue
 
+            if not file_stat.st_mode & stat.S_IRUSR:
+                os.chmod(srcpath, file_stat.st_mode | stat.S_IRUSR)
+
             actionfunc(srcpath, destpath, result=result)
 
+            if not file_stat.st_mode & stat.S_IRUSR:
+                # actionfunc would normally preserve permissions, but
+                # if we changed them before copying, we need to reset
+                # the permissions on both.
+                os.chmod(destpath, file_stat.st_mode)
+                os.chmod(srcpath, file_stat.st_mode)
+
         elif stat.S_ISCHR(mode) or stat.S_ISBLK(mode):
             # Block or character device. Put contents of st_dev in a mknod.
             if not safe_remove(destpath):