log: avoid qubesd restart on logrotate

Fixes QubesOS/qubes-issues#5004
This commit is contained in:
Rusty Bird 2021-02-04 18:21:55 +00:00
parent c2c8db066e
commit bb6e73c43e
No known key found for this signature in database
GPG Key ID: 469D78F47AAF2ADF
2 changed files with 4 additions and 5 deletions

View File

@ -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 {

View File

@ -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)