diff options
| author | Jiri Moskovcak <jmoskovc@redhat.com> | 2010-01-29 17:19:48 +0100 |
|---|---|---|
| committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2010-01-29 17:19:48 +0100 |
| commit | 3583c9184c37fc13e9a5135a8d99312bfceaa39c (patch) | |
| tree | 3d8c46079ac88dced18c49ec712d300df3de2832 /lib/Plugins/Logger.cpp | |
| parent | cfbb554000b1e3fdce90bbf14c4c2f78a5a73340 (diff) | |
| parent | e362e4141068671638865b19996bf44341c6af11 (diff) | |
Merge branch 'rhel6' of ssh://git.fedorahosted.org/git/abrt into rhel6
Diffstat (limited to 'lib/Plugins/Logger.cpp')
| -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 f428aec..3424d73 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, |
