diff options
| author | John Criswell <criswell@uiuc.edu> | 2003-08-29 14:46:12 +0000 |
|---|---|---|
| committer | John Criswell <criswell@uiuc.edu> | 2003-08-29 14:46:12 +0000 |
| commit | c907487c227abaf932911ec049077bb20c057f6b (patch) | |
| tree | 131cf7a8b042c2f51c537330ddde1e7fdd4b32a5 /llvm/tools/gccld/gccld.cpp | |
| parent | 5f9be67e072d0b7b0c2785c12dd0b0fc096bf226 (diff) | |
| download | bcm5719-llvm-c907487c227abaf932911ec049077bb20c057f6b.tar.gz bcm5719-llvm-c907487c227abaf932911ec049077bb20c057f6b.zip | |
"Help keep our secrets secret."
Added code to respect the umask value. Before, files were generated world
readable, which may not be desirable for all installations.
llvm-svn: 8215
Diffstat (limited to 'llvm/tools/gccld/gccld.cpp')
| -rw-r--r-- | llvm/tools/gccld/gccld.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/tools/gccld/gccld.cpp b/llvm/tools/gccld/gccld.cpp index ba398b2919d..4133de547d6 100644 --- a/llvm/tools/gccld/gccld.cpp +++ b/llvm/tools/gccld/gccld.cpp @@ -433,6 +433,9 @@ int main(int argc, char **argv) { Out.close(); if (!LinkAsLibrary) { + // Permissions masking value of the user + mode_t mask; + // Output the script to start the program... std::ofstream Out2(OutputFilename.c_str()); if (!Out2.good()) @@ -441,11 +444,22 @@ int main(int argc, char **argv) { Out2 << "#!/bin/sh\nlli -q -abort-on-exception $0.bc $*\n"; Out2.close(); + // + // Grab the umask value from the operating system. We want to use it when + // changing the file's permissions. + // + // Note: + // Umask() is one of those annoying system calls. You have to call it + // to get the current value and then set it back. + // + mask = umask (0); + umask (mask); + // Make the script executable... - chmod(OutputFilename.c_str(), 0755); + chmod(OutputFilename.c_str(), (0755 & ~mask)); // Make the bytecode file directly executable in LLEE as well - chmod(RealBytecodeOutput.c_str(), 0755); + chmod(RealBytecodeOutput.c_str(), (0755 & ~mask)); } return 0; |

