Browse Source

log: avoid qubesd restart on logrotate

Fixes QubesOS/qubes-issues#5004
Rusty Bird 3 years ago
parent
commit
bb6e73c43e
2 changed files with 4 additions and 5 deletions
  1. 0 3
      linux/system-config/logrotate-qubes
  2. 4 2
      qubes/log.py

+ 0 - 3
linux/system-config/logrotate-qubes

@@ -9,9 +9,6 @@
 /var/log/qubes/qubes.log {
     create 0640 root qubes
     su root qubes
-    postrotate
-        /bin/systemctl restart qubesd.service >/dev/null 2>/dev/null || true
-    endscript
 }
 
 /var/log/qubes/vm-*.log {

+ 4 - 2
qubes/log.py

@@ -24,6 +24,7 @@ See also: :py:attr:`qubes.vm.qubesvm.QubesVM.log`
 '''
 
 import logging
+import logging.handlers
 import os
 import sys
 import fcntl
@@ -102,7 +103,8 @@ def enable():
         log_path = '/tmp/qubes.log'
     old_umask = os.umask(0o007)
     try:
-        handler_log = logging.FileHandler(log_path, 'a', encoding='utf-8')
+        handler_log = logging.handlers.WatchedFileHandler(
+            log_path, 'a', encoding='utf-8')
         fcntl.fcntl(handler_log.stream.fileno(),
             fcntl.F_SETFD, fcntl.FD_CLOEXEC)
     finally:
@@ -136,7 +138,7 @@ def get_vm_logger(vmname):
         return logger
     old_umask = os.umask(0o007)
     try:
-        handler = logging.FileHandler(
+        handler = logging.handlers.WatchedFileHandler(
             os.path.join(LOGPATH, 'vm-{}.log'.format(vmname)))
         fcntl.fcntl(handler.stream.fileno(),
             fcntl.F_SETFD, fcntl.FD_CLOEXEC)