diff options
| author | John Criswell <criswell@uiuc.edu> | 2003-09-02 20:30:16 +0000 |
|---|---|---|
| committer | John Criswell <criswell@uiuc.edu> | 2003-09-02 20:30:16 +0000 |
| commit | 44375ca7d67a9536b28ae10f4533894cec72488d (patch) | |
| tree | fd76c1e6ed86a5542225d5b1128c7d837beb2908 /llvm/lib/Support | |
| parent | 06327da723e57008c8af94c9c598a02129481117 (diff) | |
| download | bcm5719-llvm-44375ca7d67a9536b28ae10f4533894cec72488d.tar.gz bcm5719-llvm-44375ca7d67a9536b28ae10f4533894cec72488d.zip | |
Added a description of the algorithm.
Return failure if the chmod() fails.
llvm-svn: 8326
Diffstat (limited to 'llvm/lib/Support')
| -rw-r--r-- | llvm/lib/Support/FileUtilities.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/llvm/lib/Support/FileUtilities.cpp b/llvm/lib/Support/FileUtilities.cpp index 01d7ca2126c..16c41bc7b9e 100644 --- a/llvm/lib/Support/FileUtilities.cpp +++ b/llvm/lib/Support/FileUtilities.cpp @@ -98,12 +98,14 @@ std::string getUniqueFilename(const std::string &FilenameBase) { /// /// Description: /// This method makes the specified filename executable by giving it -/// execute permission. +/// execute permission. It respects the umask value of the process, and it +/// does not enable any unnecessary access bits. /// -/// For the UNIX version of this method, we turn on all of the read and -/// execute bits and then turn off anything specified in the umask. This -/// should help ensure that access to the file remains at the level that -/// the user desires. +/// Algorithm: +/// o Get file's current permissions. +/// o Get the process's current umask. +/// o Take the set of all execute bits and disable those found in the umask. +/// o Add the remaining permissions to the file's permissions. /// bool MakeFileExecutable (const std::string & Filename) @@ -134,8 +136,13 @@ MakeFileExecutable (const std::string & Filename) return false; } - // Make the script executable... - chmod(Filename.c_str(), (fstat.st_mode | (0111 & ~mask))); + // + // Make the file executable... + // + if ((chmod(Filename.c_str(), (fstat.st_mode | (0111 & ~mask)))) == -1) + { + return false; + } return true; } |

