[llvm-commits] CVS: llvm/tools/gccld/gccld.cpp

John Criswell criswell at cs.uiuc.edu
Fri Aug 29 09:47:01 PDT 2003


Changes in directory llvm/tools/gccld:

gccld.cpp updated: 1.41 -> 1.42

---
Log message:

"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.


---
Diffs of the changes:

Index: llvm/tools/gccld/gccld.cpp
diff -u llvm/tools/gccld/gccld.cpp:1.41 llvm/tools/gccld/gccld.cpp:1.42
--- llvm/tools/gccld/gccld.cpp:1.41	Fri Aug 22 14:18:45 2003
+++ llvm/tools/gccld/gccld.cpp	Fri Aug 29 09:46:12 2003
@@ -433,6 +433,9 @@
   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 @@
     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;





More information about the llvm-commits mailing list