Commit 8d0161c8
(Trust umask for file permissions, 2010-01-12) taught
these commands to set permissions to 0666 explicitly. The intention was
to let the open() call inside ofstream handle permsisions so that umask
would be honored. Now we set permissions only when we need to preserve
those on an existing file. New files will be created with umask-based
permissions.
This commit is contained in:
parent
3ac3dea6f0
commit
85cbdaade2
|
@ -183,24 +183,16 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
|
||||||
std::string dir = cmSystemTools::GetFilenamePath(fileName);
|
std::string dir = cmSystemTools::GetFilenamePath(fileName);
|
||||||
cmSystemTools::MakeDirectory(dir.c_str());
|
cmSystemTools::MakeDirectory(dir.c_str());
|
||||||
|
|
||||||
mode_t mode =
|
mode_t mode = 0;
|
||||||
#if defined( _MSC_VER ) || defined( __MINGW32__ )
|
|
||||||
S_IREAD | S_IWRITE
|
|
||||||
#elif defined( __BORLANDC__ )
|
|
||||||
S_IRUSR | S_IWUSR
|
|
||||||
#else
|
|
||||||
0666
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
// Set permissions to writable
|
// Set permissions to writable
|
||||||
if ( cmSystemTools::GetPermissions(fileName.c_str(), mode) )
|
if ( cmSystemTools::GetPermissions(fileName.c_str(), mode) )
|
||||||
{
|
{
|
||||||
cmSystemTools::SetPermissions(fileName.c_str(),
|
cmSystemTools::SetPermissions(fileName.c_str(),
|
||||||
#if defined( _MSC_VER ) || defined( __MINGW32__ )
|
#if defined( _MSC_VER ) || defined( __MINGW32__ )
|
||||||
S_IREAD | S_IWRITE
|
mode | S_IWRITE
|
||||||
#else
|
#else
|
||||||
0666
|
mode | S_IWUSR | S_IWGRP
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -217,7 +209,10 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
|
||||||
}
|
}
|
||||||
file << message;
|
file << message;
|
||||||
file.close();
|
file.close();
|
||||||
cmSystemTools::SetPermissions(fileName.c_str(), mode);
|
if(mode)
|
||||||
|
{
|
||||||
|
cmSystemTools::SetPermissions(fileName.c_str(), mode);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,24 +54,16 @@ bool cmWriteFileCommand
|
||||||
std::string dir = cmSystemTools::GetFilenamePath(fileName);
|
std::string dir = cmSystemTools::GetFilenamePath(fileName);
|
||||||
cmSystemTools::MakeDirectory(dir.c_str());
|
cmSystemTools::MakeDirectory(dir.c_str());
|
||||||
|
|
||||||
mode_t mode =
|
mode_t mode = 0;
|
||||||
#if defined( _MSC_VER ) || defined( __MINGW32__ )
|
|
||||||
S_IREAD | S_IWRITE
|
|
||||||
#elif defined( __BORLANDC__ )
|
|
||||||
S_IRUSR | S_IWUSR
|
|
||||||
#else
|
|
||||||
0666
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
// Set permissions to writable
|
// Set permissions to writable
|
||||||
if ( cmSystemTools::GetPermissions(fileName.c_str(), mode) )
|
if ( cmSystemTools::GetPermissions(fileName.c_str(), mode) )
|
||||||
{
|
{
|
||||||
cmSystemTools::SetPermissions(fileName.c_str(),
|
cmSystemTools::SetPermissions(fileName.c_str(),
|
||||||
#if defined( _MSC_VER ) || defined( __MINGW32__ )
|
#if defined( _MSC_VER ) || defined( __MINGW32__ )
|
||||||
S_IREAD | S_IWRITE
|
mode | S_IWRITE
|
||||||
#else
|
#else
|
||||||
0666
|
mode | S_IWUSR | S_IWGRP
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -89,7 +81,10 @@ bool cmWriteFileCommand
|
||||||
}
|
}
|
||||||
file << message << std::endl;
|
file << message << std::endl;
|
||||||
file.close();
|
file.close();
|
||||||
cmSystemTools::SetPermissions(fileName.c_str(), mode);
|
if(mode)
|
||||||
|
{
|
||||||
|
cmSystemTools::SetPermissions(fileName.c_str(), mode);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue