diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2023-04-14 00:00:56 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-14 00:00:56 +0800 |
| commit | 59a603593f06ca2935a376b17a91ec42657f1ef8 (patch) | |
| tree | 16147c6952e526c536597c816bf7ccc4f40f94cd /source/core/slang-io.cpp | |
| parent | c7e5601bb67d2a5ebadb7f84c6968b5912e7566d (diff) | |
Set the executable bit on Executable artifact files (#2796)
* Set the executable bit on Executable artifact files
* Don't zero out other permission bits in makeExecutable
Diffstat (limited to 'source/core/slang-io.cpp')
| -rw-r--r-- | source/core/slang-io.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp index 6f97ef45d..5c57a4b3a 100644 --- a/source/core/slang-io.cpp +++ b/source/core/slang-io.cpp @@ -154,8 +154,22 @@ namespace Slang // As long as file extension is executable, it can be executed return SLANG_OK; #else - const int ret = ::chmod(fileName.getBuffer(), S_IXUSR); - return (ret == 0) ? SLANG_OK : SLANG_FAIL; + struct stat st; + if(::stat(fileName.getBuffer(), &st) != 0) + { + return SLANG_FAIL; + } + if(st.st_mode & S_IXUSR) + { + return SLANG_OK; + } + // It would probably be slightly neater to set all executable bits + // aside from those in umask.. + if(::chmod(fileName.getBuffer(), st.st_mode & 07777 | S_IXUSR) != 0) + { + return SLANG_FAIL; + } + return SLANG_OK; #endif } |
