Implement permission inheritance in log module

Quick-and-dirty matching of permissions when new log directories are
created. Currently gets tripped up by the umask with some perms.
This commit is contained in:
dgw
2013-08-21 00:50:15 +04:00
parent cec2fa66be
commit 3e1a2d9ea7

View File

@@ -97,7 +97,9 @@ void CLogMod::PutLog(const CString& sLine, const CString& sWindow /*= "Status"*/
CFile LogFile(sPath);
CString sLogDir = LogFile.GetDir();
if (!CFile::Exists(sLogDir)) CDir::MakeDir(sLogDir);
struct stat ModDirInfo;
CFile::GetInfo(GetSavePath(), ModDirInfo);
if (!CFile::Exists(sLogDir)) CDir::MakeDir(sLogDir, ModDirInfo.st_mode);
if (LogFile.Open(O_WRONLY | O_APPEND | O_CREAT))
{
LogFile.Write(CUtils::FormatTime(curtime, "[%H:%M:%S] ", m_pUser->GetTimezone()) + (m_bSanitize ? sLine.StripControls_n() : sLine) + "\n");