Add file mode support for NodeUtility::CreateBackupFile()

refs #8260
This commit is contained in:
Michael Friedrich 2015-02-07 20:41:04 +01:00
parent 289ca2ec24
commit 1d4065ba94
2 changed files with 6 additions and 2 deletions

View File

@ -591,7 +591,7 @@ bool NodeUtility::CheckAgainstBlackAndWhiteList(const String& type, const String
/*
* We generally don't overwrite files without backup before
*/
bool NodeUtility::CreateBackupFile(const String& target)
bool NodeUtility::CreateBackupFile(const String& target, mode_t mode)
{
if (!Utility::PathExists(target))
return false;
@ -606,6 +606,10 @@ bool NodeUtility::CreateBackupFile(const String& target)
Utility::CopyFile(target, backup);
#ifndef _WIN32
chmod(backup.CStr(), mode);
#endif /* _WIN32 */
Log(LogInformation, "cli")
<< "Created backup file '" << backup << "'.";

View File

@ -51,7 +51,7 @@ public:
static std::vector<Dictionary::Ptr> GetNodes(void);
static bool CreateBackupFile(const String& target);
static bool CreateBackupFile(const String& target, mode_t mode = 0640);
static bool WriteNodeConfigObjects(const String& filename, const Array::Ptr& objects);