Skip to content

Commit

Permalink
minstall: use follow_symlinks to check executable
Browse files Browse the repository at this point in the history
This could happen when setting an default install mode but with broken
symlinks.

Fixes #3914
  • Loading branch information
3v1n0 committed Aug 17, 2018
1 parent 4374ff3 commit b0fa3fc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mesonbuild/minstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def __exit__(self, type, value, traceback):
for d in self.dirs:
append_to_log(self.lf, d)

def is_executable(path):
def is_executable(path, follow_symlinks=False):
'''Checks whether any of the "x" bits are set in the source file mode.'''
return bool(os.stat(path).st_mode & 0o111)
return bool(os.stat(path, follow_symlinks=follow_symlinks).st_mode & 0o111)

def append_to_log(lf, line):
lf.write(line)
Expand Down Expand Up @@ -107,7 +107,7 @@ def set_chmod(path, mode, dir_fd=None, follow_symlinks=True):
def sanitize_permissions(path, umask):
if umask is None:
return
new_perms = 0o777 if is_executable(path) else 0o666
new_perms = 0o777 if is_executable(path, follow_symlinks=False) else 0o666
new_perms &= ~umask
try:
set_chmod(path, new_perms, follow_symlinks=False)
Expand Down

0 comments on commit b0fa3fc

Please sign in to comment.