llvm.org GIT mirror llvm / 3a9ce67
"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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8215 91177308-0d34-0410-b5e6-96231b3b80d8 John Criswell 16 years ago
1 changed file(s) with 16 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
432432 Out.close();
433433
434434 if (!LinkAsLibrary) {
435 // Permissions masking value of the user
436 mode_t mask;
437
435438 // Output the script to start the program...
436439 std::ofstream Out2(OutputFilename.c_str());
437440 if (!Out2.good())
440443 Out2 << "#!/bin/sh\nlli -q -abort-on-exception $0.bc $*\n";
441444 Out2.close();
442445
446 //
447 // Grab the umask value from the operating system. We want to use it when
448 // changing the file's permissions.
449 //
450 // Note:
451 // Umask() is one of those annoying system calls. You have to call it
452 // to get the current value and then set it back.
453 //
454 mask = umask (0);
455 umask (mask);
456
443457 // Make the script executable...
444 chmod(OutputFilename.c_str(), 0755);
458 chmod(OutputFilename.c_str(), (0755 & ~mask));
445459
446460 // Make the bytecode file directly executable in LLEE as well
447 chmod(RealBytecodeOutput.c_str(), 0755);
461 chmod(RealBytecodeOutput.c_str(), (0755 & ~mask));
448462 }
449463
450464 return 0;