aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Perkin <jperkin@joyent.com>2019-12-11 12:06:23 +0000
committerJussi Pakkanen <jpakkane@gmail.com>2019-12-11 22:39:29 +0200
commitc3d0b95a58695257cc40cbc9a51dfa6c7f172ec4 (patch)
tree3911d6d52a3a92365ca52227594d8c7e5c2884b8
parent5031f4981d4fcf6eb0bc950669a0a77a7df22939 (diff)
downloadmeson-c3d0b95a58695257cc40cbc9a51dfa6c7f172ec4.zip
meson-c3d0b95a58695257cc40cbc9a51dfa6c7f172ec4.tar.gz
meson-c3d0b95a58695257cc40cbc9a51dfa6c7f172ec4.tar.bz2
dependencies: Fix executable file test on Unix.
access(2) tests for X_OK that return true do not always guarantee that the file is executable. Instead check the stat(2) mode bits explicitly. This fixes any builds or installs executed as root on Solaris and illumos that contain non-executable scripts.
-rw-r--r--mesonbuild/dependencies/base.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 2abd243..9170400 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -21,6 +21,7 @@ import re
import json
import shlex
import shutil
+import stat
import textwrap
import platform
from typing import Any, Dict, List, Optional, Tuple, Type, Union
@@ -1859,10 +1860,11 @@ class ExternalProgram:
def _is_executable(self, path):
suffix = os.path.splitext(path)[-1].lower()[1:]
+ execmask = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
if mesonlib.is_windows():
if suffix in self.windows_exts:
return True
- elif os.access(path, os.X_OK):
+ elif os.stat(path).st_mode & execmask:
return not os.path.isdir(path)
return False