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.
This commit is contained in:
parent
5031f4981d
commit
c3d0b95a58
|
@ -21,6 +21,7 @@ import re
|
||||||
import json
|
import json
|
||||||
import shlex
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
|
import stat
|
||||||
import textwrap
|
import textwrap
|
||||||
import platform
|
import platform
|
||||||
from typing import Any, Dict, List, Optional, Tuple, Type, Union
|
from typing import Any, Dict, List, Optional, Tuple, Type, Union
|
||||||
|
@ -1859,10 +1860,11 @@ class ExternalProgram:
|
||||||
|
|
||||||
def _is_executable(self, path):
|
def _is_executable(self, path):
|
||||||
suffix = os.path.splitext(path)[-1].lower()[1:]
|
suffix = os.path.splitext(path)[-1].lower()[1:]
|
||||||
|
execmask = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
|
||||||
if mesonlib.is_windows():
|
if mesonlib.is_windows():
|
||||||
if suffix in self.windows_exts:
|
if suffix in self.windows_exts:
|
||||||
return True
|
return True
|
||||||
elif os.access(path, os.X_OK):
|
elif os.stat(path).st_mode & execmask:
|
||||||
return not os.path.isdir(path)
|
return not os.path.isdir(path)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue