]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/log/Log.cc
update sources to 12.2.10
[ceph.git] / ceph / src / log / Log.cc
index 5f7e23b4b048c0343972e53355463a864ea2a108..88e10746cebeabe375d136c4322bf9f935caf1a0 100644 (file)
@@ -4,6 +4,7 @@
 #include "Log.h"
 
 #include <errno.h>
+#include <fcntl.h>
 #include <syslog.h>
 
 #include "common/errno.h"
@@ -138,12 +139,11 @@ void Log::reopen_log_file()
   if (m_fd >= 0)
     VOID_TEMP_FAILURE_RETRY(::close(m_fd));
   if (m_log_file.length()) {
-    m_fd = ::open(m_log_file.c_str(), O_CREAT|O_WRONLY|O_APPEND, 0644);
+    m_fd = ::open(m_log_file.c_str(), O_CREAT|O_WRONLY|O_APPEND|O_CLOEXEC, 0644);
     if (m_fd >= 0 && (m_uid || m_gid)) {
-      int r = ::fchown(m_fd, m_uid, m_gid);
-      if (r < 0) {
-       r = -errno;
-       cerr << "failed to chown " << m_log_file << ": " << cpp_strerror(r)
+      if (::fchown(m_fd, m_uid, m_gid) < 0) {
+       int e = errno;
+       std::cerr << "failed to chown " << m_log_file << ": " << cpp_strerror(e)
             << std::endl;
       }
     }