]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
rotatingfile: mark log files as close-on-exec
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 4 Dec 2015 17:23:15 +0000 (17:23 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 4 Dec 2015 18:18:39 +0000 (18:18 +0000)
The log file descriptor associated with the virRotatingFile
struct should be marked close-on-exec, as even when virtlogd
re-exec's itself it expect to open the log file fresh. It
does not need to preserve the logfile handles, only the network
client FDs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/util/virrotatingfile.c

index a32759abe66d069d60ea4bbc27dd4fd8d0f09a32..6654affcd8aa3c48b56cb81ee6e969f9a566b9c6 100644 (file)
@@ -108,7 +108,7 @@ virRotatingFileWriterEntryNew(const char *path,
     if (VIR_ALLOC(entry) < 0)
         return NULL;
 
-    if ((entry->fd = open(path, O_CREAT|O_APPEND|O_WRONLY, mode)) < 0) {
+    if ((entry->fd = open(path, O_CREAT|O_APPEND|O_WRONLY|O_CLOEXEC, mode)) < 0) {
         virReportSystemError(errno,
                              _("Unable to open file: %s"), path);
         goto error;
@@ -151,7 +151,7 @@ virRotatingFileReaderEntryNew(const char *path)
     if (VIR_ALLOC(entry) < 0)
         return NULL;
 
-    if ((entry->fd = open(path, O_RDONLY)) < 0) {
+    if ((entry->fd = open(path, O_RDONLY|O_CLOEXEC)) < 0) {
         if (errno != ENOENT) {
             virReportSystemError(errno,
                                  _("Unable to open file: %s"), path);