From 84208523f9d4f6d35bbf732e4276d583a37ff911 Mon Sep 17 00:00:00 2001 From: George Hartzell Date: Thu, 6 Apr 2017 14:25:13 -0700 Subject: [PATCH] set_executable can set S_IX{GRP,OTH} (#3742) `set_executable` now checks if a user/group.other had read permission on a file and if it does then it sets the corresponding executable bit. See #1483. --- lib/spack/llnl/util/filesystem.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index 8922010e703..71d50965239 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -394,8 +394,14 @@ def traverse_tree(source_root, dest_root, rel_path='', **kwargs): def set_executable(path): - st = os.stat(path) - os.chmod(path, st.st_mode | stat.S_IEXEC) + mode = os.stat(path).st_mode + if mode & stat.S_IRUSR: + mode |= stat.S_IXUSR + if mode & stat.S_IRGRP: + mode |= stat.S_IXGRP + if mode & stat.S_IROTH: + mode |= stat.S_IXOTH + os.chmod(path, mode) def remove_dead_links(root):