diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-29 16:23:57 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-29 16:23:57 +0100 |
commit | 6b0894cdb41d9698e593af717f4857313ea81c22 (patch) | |
tree | 8cd219a512c3d66a5eb2a675f771f3ca42587c36 /lib | |
parent | 7b0cc50bedbb5be2dc06ec1efec9467844eb6904 (diff) | |
download | abrt-6b0894cdb41d9698e593af717f4857313ea81c22.tar.gz abrt-6b0894cdb41d9698e593af717f4857313ea81c22.tar.xz abrt-6b0894cdb41d9698e593af717f4857313ea81c22.zip |
Logger: create log file with mode 0600
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Plugins/Logger.cpp | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp index f428aec5..3424d73d 100644 --- a/lib/Plugins/Logger.cpp +++ b/lib/Plugins/Logger.cpp @@ -63,29 +63,23 @@ std::string CLogger::Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs) { - std::string description = make_description_logger(pCrashData); - description += "\n\n\n"; - FILE *fOut; - if (m_bAppendLogs) - { - fOut = fopen(m_sLogPath.c_str(), "a"); - } - else - { - fOut = fopen(m_sLogPath.c_str(), "w"); - } + /* open, not fopen - want to set mode if we create the file, not just open */ + const char *fname = m_sLogPath.c_str(); + int fd = open(fname, + m_bAppendLogs ? O_WRONLY|O_CREAT|O_APPEND : O_WRONLY|O_CREAT|O_TRUNC, + 0600); + if (fd < 0) + throw CABRTException(EXCEP_PLUGIN, "Can't open '%s'", fname); - if (fOut) - { - update_client(_("Writing report to '%s'"), m_sLogPath.c_str()); - fputs(description.c_str(), fOut); - fclose(fOut); - return "file://" + m_sLogPath; - } + update_client(_("Writing report to '%s'"), fname); + description += "\n\n\n"; + const char *desc = description.c_str(); + full_write(fd, desc, strlen(desc)); + close(fd); - throw CABRTException(EXCEP_PLUGIN, "Can't open '%s'", m_sLogPath.c_str()); + return "file://" + m_sLogPath; } PLUGIN_INFO(REPORTER, |